{"id":437,"date":"2025-09-21T19:16:50","date_gmt":"2025-09-21T19:16:50","guid":{"rendered":"https:\/\/phpsupreme.de\/?p=437"},"modified":"2025-09-21T19:16:50","modified_gmt":"2025-09-21T19:16:50","slug":"dock","status":"publish","type":"post","link":"https:\/\/phpsupreme.de\/?p=437","title":{"rendered":"Dock"},"content":{"rendered":"\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-lang=\"PHP\"><code>&lt;?php\nclass dock extends Plugin {\n\tpublic $location = &quot;taskbar&quot;;\n\tpublic $width = 128;\n\tprivate $supreme;\n\tprivate $conf_dock, $DOCKBOX, $css_provider, $style_context, $icon_theme;\n\tprivate $INSTALLED_APPS;\n\tprivate $ITEMS;\n\tprivate $ITEM;\n\tprivate $MENU;\n\tprivate $old_windows_state, $new_windows_state;\n\tprivate $temp;\n\tprivate $sleep;\n\tprivate $CONF_MTIME, $DOCK_MTIME;\n\tprivate $TEMP_NAMES;\n\tprivate $css_dock = &quot;\n\t#item1 {background: none; padding: 0px;background: none; border: 2px solid alpha(@selected_bg_color, 0);opacity: 0.9;}\n\t#item1:hover {background: none; padding: 0px;background: none; border-bottom: 2px solid alpha(@selected_bg_color, 255);opacity: 0.9;}\n\t#item:hover{background: none; border-bottom: 2px solid alpha(@selected_bg_color, 1); opacity: 1;}\n\t#dialog_entry: {margin-bottom: 5px;}\n\t&quot;;\n\t\n\tprivate function d2s($src) {\n\tif (substr_count($src, &quot;%u&quot;) &gt; 0) {\n\t\t$src = str_replace(&quot;%u&quot;, &#39;&#39;, $src);\n\t}\n\tif (substr_count($src, &quot;%U&quot;) &gt; 0) {\n\t\t$src = str_replace(&quot;%U&quot;, &#39;&#39;, $src);\n\t}\n\tif (substr_count($src, &quot;%f&quot;) &gt; 0) {\n\t\t$src = str_replace(&quot;%f&quot;, &#39;&#39;, $src);\n\t}\n\tif (substr_count($src, &quot;%F&quot;) &gt; 0) {\n\t\t$src = str_replace(&quot;%F&quot;, &#39;&#39;, $src);\n\t}\n\treturn $src;\n\t}\n\t\n\tprivate function compare_arrays(array $array1, array $array2): array\n{\n    $changes = [];\n\n    \/\/ \u041f\u043e\u0438\u0441\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432\n    foreach ($array1 as $key =&gt; $value) {\n        if (!isset($array2[$key])) {\n            $changes[&#39;deleted&#39;][$key] = $value; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\n        } elseif ($array1[$key] != $array2[$key]) {\n            $changes[&#39;changed&#39;][$key] = [\n                &#39;old&#39; =&gt; $value,\n                &#39;new&#39; =&gt; $array2[$key],\n            ]; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\n        }\n    }\n\n    \/\/ \u041f\u043e\u0438\u0441\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432\n    foreach ($array2 as $key =&gt; $value) {\n        if (!isset($array1[$key])) {\n            $changes[&#39;added&#39;][$key] = $value; \/\/ \u042d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\n        }\n    }\n\n    return $changes;\n}\n\t\n\tprivate function click_process($button, $event) {\n\t\t$key = $button-&gt;get_data(&quot;key&quot;);\n\/\/\t\tprint_r($this-&gt;ITEMS[&quot;$key&quot;]);\n\t\t\n\t\tif ($event-&gt;button-&gt;button == 3) { \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438\n\t\t\t$this-&gt;MENU = new GtkMenu();\n\t\t\t$menu_item=GtkMenuItem::new_with_label($this-&gt;ITEMS[$key][&quot;display_name&quot;]);\n\t\t\t$menu_item-&gt;set_sensitive(false);\n\t\t\t$this-&gt;MENU-&gt;append($menu_item);\n\t\t\tif (isset($this-&gt;ITEMS[&quot;$key&quot;][&quot;desktop_file&quot;])) {\/\/ \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c - \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0444\u0438\u0448\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0437 .desktop-\u0444\u0430\u0439\u043b\u0430\n\t\t\t\t$ini=pif($this-&gt;ITEMS[&quot;$key&quot;][&quot;desktop_file&quot;], array(&quot;Desktop Entry&quot;));\n\t\t\t\t\/\/$menu_item=GtkMenuItem::new_with_label($ini[&quot;Desktop Entry&quot;][&quot;Name&quot;]);\n\t\t\t\tif (isset($ini[&quot;Desktop Entry&quot;][&quot;Actions&quot;])) {\n\t\t\t\t\t$tmp = explode(&#39;;&#39;, $ini[&quot;Desktop Entry&quot;][&quot;Actions&quot;]);\n\t\t\t\t\tfor ($i = 0; $i &lt;= count($tmp)-1; $i++) {\n\t\t\t\t\t\tif ($tmp[$i]!=&quot;&quot;) {\n\t\t\t\t\t\t\t$ini=pif($this-&gt;ITEMS[&quot;$key&quot;][&quot;desktop_file&quot;], array(&quot;Desktop Action $tmp[$i]&quot;));\n\t\t\t\t\t\t\t$action[$i][&quot;Name&quot;] = $ini[&quot;Desktop Action &quot;.$tmp[$i]][&quot;Name&quot;];\n\t\t\t\t\t\t\t$action[$i][&quot;Exec&quot;] = $ini[&quot;Desktop Action &quot;.$tmp[$i]][&quot;Exec&quot;];\t\n\t\t\t\t\t\t\tif (isset($action[$i][&quot;Name&quot;])) {\n\t\t\t\t\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label($action[$i][&quot;Name&quot;]));\t\t\n\t\t\t\t\t\t\t\t$menu_item-&gt;set_name($action[$i][&quot;Exec&quot;]);\n\t\t\t\t\t\t\t\t$this-&gt;temp = str_replace(&quot;%U&quot;, &quot;~&quot;, $action[$i][&quot;Exec&quot;]);\n\t\t\t\t\t\t\t\t$menu_item-&gt;set_data(&quot;exec&quot;, $action[$i][&quot;Exec&quot;]);\n\t\t\t\t\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) { \/\/ connect menu to event activate\n\t\t\t\t\t\t\t\t\t$exec = $widget-&gt;get_data(&quot;exec&quot;);\n\t\t\t\t\t\t\t\t\texecute($exec);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\t\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t$this-&gt;MENU-&gt;append(new GtkSeparatorMenuItem());\n\t\t\t\t}\n\t\t\t\t\n\t\t\t} \/\/ \u041a\u043e\u043d\u0435\u0446 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u0444\u0438\u0448\u0435\u043a \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0437 .desktop-\u0444\u0430\u0439\u043b\u0430\n\t\t\t\n\t\t\tif ($this-&gt;ITEMS[&quot;$key&quot;][&quot;docked&quot;]==&quot;1&quot;) { \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0434\u043e\u043a \u0438\u043b\u0438 \u0438\u0437\u044c\u044f\u0442\u0438\u0435 \u0438\u0437 \u0434\u043e\u043a\u0430\n\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label(&quot;Remove from dock items&quot;));\n\t\t\t\t$menu_item-&gt;set_data(&quot;key&quot;, $key);\n\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) {\n\t\t\t\t\t$key = $widget-&gt;get_data(&quot;key&quot;);\n\/\/\t\t\t\t\techo &quot;KEY: $key \\n&quot;;\n\t\t\t\t\t$this-&gt;remove_from_dock($widget-&gt;get_data(&quot;key&quot;));\n\t\t\t\t});\n\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label(&quot;Dock item properties&quot;));\n\t\t\t\t$menu_item-&gt;set_data(&quot;key&quot;, $key);\n\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) {\n\t\t\t\t\t$key = $widget-&gt;get_data(&quot;key&quot;);\n\t\t\t\t\texecute(&quot;\/usr\/local\/supreme\/panel\/plugins\/dock\/item_property.php &quot;.$this-&gt;ITEMS[&quot;$key&quot;][&quot;dockfile&quot;]);\n\t\t\t\t});\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\tif ($this-&gt;ITEMS[&quot;$key&quot;][&quot;docked&quot;]==&quot;0&quot;) {\n\t\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label(&quot;Add to dock items&quot;));\n\t\t\t\t\t$menu_item-&gt;set_data(&quot;key&quot;, $key);\n\t\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) {\n\t\t\t\t\t\t$key = $widget-&gt;get_data(&quot;key&quot;);\n\/\/\t\t\t\t\t\techo &quot;KEY: $key \\n&quot;;\n\t\t\t\t\t$this-&gt;add_to_dock($widget-&gt;get_data(&quot;key&quot;));\n\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (isset($this-&gt;ITEMS[&quot;$key&quot;][&quot;xid&quot;])) { \/\/ \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u043c \u043c\u0435\u043d\u044e \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\n\t\t\t\t$this-&gt;MENU-&gt;append(new GtkSeparatorMenuItem());\n\t\t\t\t\n\t\t\t\tif ($this-&gt;conf_dock[&quot;dockbar_use_extended_menu&quot;]==1) {\n\t\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label(&quot;Process details&quot;));\n\t\t\t\t\t$menu_item-&gt;set_data(&quot;pid&quot;, $this-&gt;ITEMS[&quot;$key&quot;][&quot;pid&quot;]);\n\t\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) {\n\t\t\t\t\t\t$pid = $widget-&gt;get_data(&quot;pid&quot;);\n\t\t\t\t\t\t$this-&gt;supreme-&gt;execute(&quot;\/system\/php\/bin\/php \/usr\/local\/supreme\/utils\/pidinfo.php $pid&quot;);\n\t\t\t\t\t\techo &quot;:)&quot;;\n\t\t\t\t\t});\n\t\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label(&quot;Set temporary name&quot;));\n\t\t\t\t\t$menu_item-&gt;set_data(&quot;key&quot;, $key);\n\t\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) {\n\t\t\t\t\t\t$key = $widget-&gt;get_data(&quot;key&quot;);\n\t\t\t\t\t\t\/\/$exec = $this-&gt;d2s($this-&gt;INSTALLED_APPS[&quot;$key&quot;][&quot;exec&quot;]);\n\t\t\t\t\t\t\/\/$this-&gt;supreme-&gt;execute($exec);\n\t\t\t\t\t\t$dialog = new GtkDialog();\n\t\t\t\t\t\t$entry = new GtkEntry();\n\t\t\t\t\t\t$area = $dialog-&gt;get_content_area();\n\t\t\t\t\t\t$area-&gt;add($entry);\n\t\t\t\t\t\t$entry-&gt;show_all();\n\t\t\t\t\t\t$dialog-&gt;add_button(&quot;Apply&quot;,1);\n\t\t\t\t\t\t$dialog-&gt;add_button(&quot;Close&quot;,2);\n\t\t\t\t\t\t$dialog-&gt;set_default_response(1);\n\t\t\t\t\t\t$dialog-&gt;set_vexpand(true);\n\t\t\t\t\t\t$dialog-&gt;set_size_request(-1,100);\n\t\t\t\t\t\t$entry-&gt;set_name(&quot;dialog_entry&quot;);\n\t\t\t\t\t\t$entry-&gt;connect(&quot;activate&quot;, function($widget) {\n\t\t\t\t\t\t\t$parent = $widget-&gt;get_parent()-&gt;get_parent();\n\t\t\t\t\t\t\t$parent-&gt;response(1);\n\t\t\t\t\t\t});\n\t\t\t\t\t\t$dialog-&gt;set_title(&quot;New temporary name&quot;);\n\t\t\t\t\t\t$responce = $dialog-&gt;run();\n\t\t\t\t\t\tif ($responce==1) {\n\t\t\t\t\t\t\t$name = $entry-&gt;get_text();\n\t\t\t\t\t\t\tif ($name!=&quot;&quot;) {\n\t\t\t\t\t\t\t\t$this-&gt;TEMP_NAMES[&quot;$key&quot;] = $name;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tunset($this-&gt;TEMP_NAMES[&quot;$key&quot;]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttouch(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock&quot;);\n\t\t\t\t\t\t\t$dialog-&gt;destroy();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ($responce==2) {\n\t\t\t\t\t\t\t$dialog-&gt;destroy();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label(&quot;Run another instance&quot;));\n\t\t\t\t\t$menu_item-&gt;set_data(&quot;key&quot;, $key);\n\t\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) {\n\t\t\t\t\t\t$key = $widget-&gt;get_data(&quot;key&quot;);\n\t\t\t\t\t\t$exec = $this-&gt;d2s($this-&gt;INSTALLED_APPS[&quot;$key&quot;][&quot;exec&quot;]);\n\t\t\t\t\t\t$this-&gt;supreme-&gt;execute($exec);\n\t\t\t\t\t});\n\t\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label(&quot;Forced close&quot;));\n\t\t\t\t\t$menu_item-&gt;set_data(&quot;pid&quot;, $this-&gt;ITEMS[&quot;$key&quot;][&quot;pid&quot;]);\n\t\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) { \/\/ connect menu to event activate\n\t\t\t\t\t$pid = $widget-&gt;get_data(&quot;pid&quot;);\n\t\t\t\t\t\texec(&quot;kill -9 $pid&quot;);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t$this-&gt;MENU-&gt;append($menu_item=GtkMenuItem::new_with_label(&quot;Close&quot;));\n\t\t\t\t$menu_item-&gt;set_data(&quot;xid&quot;, $this-&gt;ITEMS[&quot;$key&quot;][&quot;xid&quot;]);\n\t\t\t\t$menu_item-&gt;connect(&quot;activate&quot;, function($widget) { \/\/ connect menu to event activate\n\t\t\t\t$this-&gt;supreme-&gt;toggleWindowFromDock($widget-&gt;get_data(&quot;xid&quot;));\n\t\t\t\t$this-&gt;supreme-&gt;closeWindow($widget-&gt;get_data(&quot;xid&quot;));\n\t\t\t\t});\n\t\t\n\t\t\t}\n\t\t\t$this-&gt;MENU-&gt;connect(&quot;deactivate&quot;, function($widget) {\n\t\t\t\tunset($this-&gt;MENU);\n\/\/\t\t\t\techo gc_collect_cycles() . &quot; \u0446\u0438\u043a\u043b\u043e\u0432 \u043c\u0443\u0441\u043e\u0440\u0430 \u0431\u044b\u043b\u043e \u0441\u043e\u0431\u0440\u0430\u043d\u043e.\\n&quot;;\n\t\t\t});\n\t\t\t$this-&gt;MENU-&gt;show_all();\n\t\t\t$this-&gt;MENU-&gt;popup_at_pointer();\n\t\t}\/\/ \u0417\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438\n\t\t\n\t\tif ($event-&gt;button-&gt;button == 1) { \/\/ \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043b\u0435\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438\n\t\t\tif (isset($this-&gt;ITEMS[$key][&quot;xid&quot;])) { \/\/ \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438\u043c\u0435\u044e\u0449\u0435\u0435 xid, \u0442\u043e \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e\n\t\t\t\t$this-&gt;supreme-&gt;toggleWindowFromDock($this-&gt;ITEMS[$key][&quot;xid&quot;]);\n\t\t\t} else { \/\/ \u0418\u043d\u0430\u0447\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\n\t\t\t\t$exec = $this-&gt;d2s($this-&gt;ITEMS[$key][&quot;exec&quot;]); \/\/ \u041f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u0438 if&#39;\u044b \u043f\u043e\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430\n\t\t\t\techo &quot;Exec = $exec \\n&quot;;\n\t\t\t\texecute($exec);\n\t\t\t}\n\t\t\n\t\t} \/\/ \u0417\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043b\u0435\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438\n\t\t\n\t}\n\t\n\t\n\tprivate function add_to_dock($key) {\n\t\t\/\/print_r($this-&gt;ITEMS[$key]);\n\/\/\t\tprint_r($this-&gt;ITEMS[$key]);\n\t\t$icon = $this-&gt;ITEMS[$key][&quot;icon&quot;];\n\t\t$name = $this-&gt;ITEMS[$key][&quot;canonical_name&quot;];\n\t\t$desktop = $this-&gt;ITEMS[$key][&quot;desktop_file&quot;];\n\t\tif (isset($this-&gt;ITEMS[$key][&quot;desktop_file&quot;])) {\n\t\t\t\/\/$exec = $ini[&quot;Desktop Entry&quot;][&quot;Exec&quot;];\n\t\t\t$exec = $cmd = readlink(&quot;\/proc\/&quot;.$this-&gt;ITEMS[$key][&quot;pid&quot;].&quot;\/exe&quot;);\n\t\t\t$ini=pif($this-&gt;ITEMS[$key][&quot;desktop_file&quot;], array(&quot;Desktop Entry&quot;));\n\t\t\tif (isset($ini[&quot;Desktop Entry&quot;][&quot;StartupWMClass&quot;])) {\n\t\t\t\t$id = strtolower(basename($ini[&quot;Desktop Entry&quot;][&quot;StartupWMClass&quot;]));\n\t\t\t} elseif (isset($ini[&quot;Desktop Entry&quot;][&quot;Exec&quot;])) {\n\t\t\t\t$id = $this-&gt;d2s(strtolower(basename($ini[&quot;Desktop Entry&quot;][&quot;Exec&quot;])));\n\t\t\t}\n\t\t} else {\n\t\t\t$id = strtolower($name);\n\t\t\t$exec = $cmd = readlink(&quot;\/proc\/&quot;.$this-&gt;ITEMS[$key][&quot;pid&quot;].&quot;\/exe&quot;);\n\t\t}\n\t\t$id = trim($id);\n\t\t$file = &quot;[Item]\\n&quot;;\n\t\t$file .= &quot;Launcher=$desktop\\n&quot;;\n\t\t$file .= &quot;Icon=$icon\\n&quot;;\n\t\t$file .= &quot;Name=$name\\n&quot;;\n\t\t$file .= &quot;Exec=$exec\\n&quot;;\n\t\t\n\t\tfile_put_contents(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock\/$id.desktop&quot;, $file);\n\t}\n\t\n\tprivate function remove_from_dock($key) {\n\t\t$dock_file = $this-&gt;ITEMS[$key][&quot;dockfile&quot;];\n\t\tunlink($dock_file);\n\t}\n\t\n\tprivate function get_installed_apps_by_group() {\n\t\t$this-&gt;INSTALLED_APPS = [];\n\t\t$scan = scandir(&quot;\/usr\/share\/applications\/&quot;);\n\t\tforeach ($scan as $file) {\n\t\t\t$ini=pif(&quot;\/usr\/share\/applications\/$file&quot;, array(&quot;Desktop Entry&quot;));\n\t\t\tif (isset($ini[&quot;Desktop Entry&quot;][&quot;Exec&quot;])) {\n\t\t\t\tif (isset($ini[&quot;Desktop Entry&quot;][&quot;StartupWMClass&quot;])) {\n\t\t\t\t\t$cmd = trim(strtolower($ini[&quot;Desktop Entry&quot;][&quot;StartupWMClass&quot;]));\n\t\t\t\t} else {\n\t\t\t\t\t$cmd = trim($this-&gt;d2s(strtolower(basename($ini[&quot;Desktop Entry&quot;][&quot;Exec&quot;]))));\n\t\t\t\t}\n\t\t\t\t$this-&gt;INSTALLED_APPS[$cmd][&#39;exec&#39;] = $ini[&quot;Desktop Entry&quot;][&quot;Exec&quot;];\n\t\t\t\t$this-&gt;INSTALLED_APPS[$cmd][&#39;icon&#39;] = $ini[&quot;Desktop Entry&quot;][&quot;Icon&quot;];\n\t\t\t\t$this-&gt;INSTALLED_APPS[$cmd][&#39;name&#39;] = $ini[&quot;Desktop Entry&quot;][&quot;Name&quot;];\n\t\t\t\t$this-&gt;INSTALLED_APPS[$cmd][&#39;desktop_file&#39;] = &quot;\/usr\/share\/applications\/$file&quot;;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprivate function get_running_windows () {\n\t\t$array = [];\n\t\t$windows = $this-&gt;supreme-&gt;ListActiveWindows();\n\/\/\t\tprint_r($windows);\n\t\tif (!is_array($windows)) {return null;}\n\t\tfor ($i = 1; $i &lt;= count($windows[&quot;xid&quot;]); $i++) {\n\t\t\t$id = strtolower($windows[&quot;class_group_name&quot;][$i]);\n\t\t\tif (isset($array[$id])) {$id = $id.$windows[&#39;xid&#39;][$i];}\n\t\t\t$array[$id][&quot;window_name&quot;] = $windows[&#39;window_name&#39;][$i];\n\t\t\t$array[$id][&quot;display_name&quot;] = $windows[&#39;application_name&#39;][$i];\n\t\t\t$array[$id][&quot;application_name&quot;] = $windows[&#39;application_name&#39;][$i];\n\t\t\t$array[$id][&quot;window_class&quot;] = $windows[&#39;class_group_name&#39;][$i];\n\t\t\t$array[$id][&quot;canonical_name&quot;] = $windows[&#39;class_group_name&#39;][$i];\n\t\t\t$array[$id][&quot;icon_from_window&quot;] = strtolower($windows[&#39;class_group_name&#39;][$i]);\n\t\t\t$array[$id][&quot;running&quot;] = 1;\n\t\t\t$array[$id][&quot;docked&quot;] = 0;\n\t\t\tif (isset($this-&gt;INSTALLED_APPS[strtolower($windows[&#39;class_group_name&#39;][$i])][&quot;desktop_file&quot;])) {\n\t\t\t\t$array[$id][&quot;desktop_file&quot;] = $this-&gt;INSTALLED_APPS[strtolower($windows[&#39;class_group_name&#39;][$i])][&quot;desktop_file&quot;];\n\t\t\t\t$array[$id][&quot;icon_from_desktop&quot;] = $this-&gt;INSTALLED_APPS[strtolower($windows[&#39;class_group_name&#39;][$i])][&quot;icon&quot;];\n\t\t\t\t} else {\n\t\t\t\t$array[$id][&quot;desktop_file&quot;] = $this-&gt;INSTALLED_APPS[strtolower($windows[&#39;class_name&#39;][$i])][&quot;desktop_file&quot;];\n\t\t\t\t$array[$id][&quot;icon_from_desktop&quot;] = $this-&gt;INSTALLED_APPS[strtolower($windows[&#39;class_name&#39;][$i])][&quot;icon&quot;];\n\t\t\t}\n\t\t\t$array[$id][&quot;xid&quot;] = $windows[&#39;xid&#39;][$i];\n\t\t\t$array[$id][&quot;pid&quot;] = $windows[&#39;pid&#39;][$i];\n\t\t\t$array[$id][&quot;state&quot;] = $windows[&#39;state&#39;][$i];\n\t\t\t$array[$id][&quot;active&quot;] = $windows[&#39;active&#39;][$i];\n\t\t\t$array[$id][&quot;urgent&quot;] = $windows[&#39;urgent&#39;][$i];\n\t\t\t$array[$id][&quot;pixbuf&quot;] = $windows[&#39;pixbuf&#39;][$i];\n\t\t}\n\t\t$scan = scandir(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock\/&quot;);\n\t\tforeach ($scan as $file) {\n\t\t\tif (($file==&quot;.&quot;) or ($file==&quot;..&quot;)) {continue;}\n\t\t\t$id = explode(&quot;.desktop&quot;,$file)[0];\n\t\t\t$ini=pif(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock\/&quot;.$file, array(&quot;Item&quot;));\n\t\t\t\n\t\t\tif (is_array($array[$id])) {\n\t\t\t\t$array[$id][&quot;docked&quot;] = 1;\n\t\t\t\t$array[$id][&quot;dockfile&quot;] = &quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock\/&quot;.$file;\n\t\t\t\t$array[$id][&quot;icon_from_dock&quot;] = $ini[&quot;Item&quot;][&quot;Icon&quot;]; \/\/ \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0438\u043a\u043e\u043d\u043a\u0443 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a .desktop-\u0444\u0430\u0439\u043b\u0430 \u0434\u043e\u043a\u0430\n\t\t\t} else {\n\/\/\t\t\t\techo &quot;Docked element $id is NOT running now \\n&quot;;\n\t\t\t\t$array[$id][&quot;docked&quot;] = 1;\n\t\t\t\t$array[$id][&quot;running&quot;] = 0;\n\t\t\t\t$array[$id][&quot;icon_from_dock&quot;] = $ini[&quot;Item&quot;][&quot;Icon&quot;];\n\t\t\t\t$array[$id][&quot;icon_from_window&quot;] = strtolower($ini[&quot;Item&quot;][&quot;Name&quot;]);\n\t\t\t\t$array[$id][&quot;desktop_file&quot;] = $ini[&quot;Item&quot;][&quot;Launcher&quot;];\n\t\t\t\t$array[$id][&quot;display_name&quot;] = $ini[&quot;Item&quot;][&quot;Name&quot;];\n\t\t\t\t$array[$id][&quot;dockfile&quot;] = &quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock\/&quot;.$file;\n\t\t\t\t\/\/$array[$id][&quot;exec&quot;] = $array[$id][&quot;exec&quot;] = $ini[&quot;Item&quot;][&quot;Exec&quot;];\n\t\t\t\tif (isset($ini[&quot;Item&quot;][&quot;Exec&quot;])) {$array[$id][&quot;exec&quot;] = $ini[&quot;Item&quot;][&quot;Exec&quot;];} else {\n\t\t\t\t\t$array[$id][&quot;exec&quot;] = $this-&gt;INSTALLED_APPS[$id][&quot;exec&quot;];\n\t\t\t\t}\n\t\t\t\t\/*\n\t\t\t\tif (isset($this-&gt;INSTALLED_APPS[$id][&quot;exec&quot;])) {\n\t\t\t\t\t$array[$id][&quot;exec&quot;] = $this-&gt;INSTALLED_APPS[$id][&quot;exec&quot;];\n\t\t\t\t} else {\n\t\t\t\t\t$array[$id][&quot;exec&quot;] = $array[$id][&quot;exec&quot;] = $ini[&quot;Item&quot;][&quot;Exec&quot;];\n\t\t\t\t}\n\t\t\t\t*\/\n\t\t\t}\n\t\t}\n\t\t$this-&gt;ITEMS = $array;\n\t\tif (is_array($this-&gt;ITEMS)) {ksort($this-&gt;ITEMS);}\n\t\treturn $array;\n\t}\n\t\n\tprivate function get_id_by_xid($xid) {\n\t\tforeach ($this-&gt;ITEMS as $key =&gt; $value) {\n\t\t\tif ($this-&gt;ITEMS[$key][&quot;xid&quot;] == &quot;$xid&quot;) {\n\t\t\t\treturn $key;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate function remove_icon($key) {\n\t\tif (isset($this-&gt;ITEM[$key])) {$this-&gt;ITEM[$key]-&gt;destroy();}\n\t\tunset($this-&gt;ITEM[$key]);\n\t}\n\n\tprivate function draw_icon($key) {\n\t\t$name = $this-&gt;ITEMS[$key][&quot;display_name&quot;];\n\t\t\/\/$icon = &quot;inode-symlink&quot;;\n\t\tunset($gd);\n\t\t\n\t\t\/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043a\u0430\u043a\u0430\u044f \u0438\u0437 \u0438\u043a\u043e\u043d\u043e\u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442\n\t\tif ($this-&gt;icon_theme-&gt;has_icon($this-&gt;ITEMS[$key][&quot;icon_from_window&quot;])) {$icon = $this-&gt;ITEMS[$key][&quot;icon_from_window&quot;];} \/\/ \u0418\u043a\u043e\u043d\u043a\u0430 \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f - \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u0430\n\t\tif ($this-&gt;icon_theme-&gt;has_icon($this-&gt;ITEMS[$key][&quot;icon_from_desktop&quot;])) {$icon = $this-&gt;ITEMS[$key][&quot;icon_from_desktop&quot;];} \/\/ \u0418\u043a\u043e\u043d\u043a\u0430 \u0438\u0437 \u0434\u0435\u0441\u043a\u0442\u043e\u043f\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 - \u0432\u0442\u043e\u0440\u0438\u0447\u043d\u0430\n\t\tif ($this-&gt;icon_theme-&gt;has_icon($this-&gt;ITEMS[$key][&quot;icon_from_dock&quot;])) {$icon = $this-&gt;ITEMS[$key][&quot;icon_from_dock&quot;];}  \/\/ \u041d\u043e \u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u0438\u043a\u043e\u043d\u043a\u0430 \u0432 \u0434\u043e\u043a\u0435 - \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0435\u0435\n\t\t\n\t\tif ((!isset($icon)) and ($this-&gt;ITEMS[$key][&quot;pixbuf&quot;]!=&quot;&quot;)) { \/\/ \u0415\u0441\u043b\u0438 \u0438\u043a\u043e\u043d\u043a\u0430 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430, \u043d\u043e pixbuf \u0438\u043a\u043e\u043d\u043a\u0438 \u043e\u043a\u043d\u0430 \u043d\u0430\u0439\u0434\u0435\u043d - \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c pixbuf \u043e\u043a\u043d\u0430\n\t\t\t$gd = imagecreatefromstring(base64_decode($this-&gt;ITEMS[$key][&quot;pixbuf&quot;]));\n\t\t}\n\t\t\n\t\tif ((!isset($icon)) and ($this-&gt;ITEMS[$key][&quot;pixbuf&quot;]==&quot;&quot;)) { \/\/ \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u0438\u043a\u043e\u043d\u043a\u0438, \u0438 \u043d\u0435\u0442 pixbuf&#39;\u0430 \u043e\u043a\u043d\u0430 - \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c fallback-\u0438\u043a\u043e\u043d\u043a\u0443\n\t\t\t$gd = gdk_pixbuf_to_gd(GdkPixbuf::new_from_icon_theme(&quot;inode-symlink&quot;,32));\n\t\t}\n\t\t\n\t\tif ((isset($icon)) and ($this-&gt;conf_dock[&quot;dockbar_use_native_icons&quot;]==&quot;1&quot;)) { \/\/ \u0415\u0441\u043b\u0438 \u0438\u043a\u043e\u043d\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430, \u043d\u043e \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u043a\u043e\u043d\u043e\u043a - \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c pixbuf\n\t\t\t$gd = imagecreatefromstring(base64_decode($this-&gt;ITEMS[$key][&quot;pixbuf&quot;]));\n\t\t}\n\t\t\n\t\tif ((isset($icon)) and ($this-&gt;conf_dock[&quot;dockbar_use_native_icons&quot;]!=&quot;1&quot;)) { \/\/ \u0415\u0441\u043b\u0438 \u0438\u043a\u043e\u043d\u043a\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430, \u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u0445 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0438\u043a\u043e\u043d\u043e\u043a - \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043a\u043e\u043d\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\n\t\t\t$gd = gdk_pixbuf_to_gd(GdkPixbuf::new_from_icon_theme($icon,32));\n\t\t}\n\t\techo &quot;ICON: $icon \\n&quot;;\n\t\t\/\/ \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e\u0431 $gd \u0431\u044b\u043b PHP-GD\n\/\/\t\tif (!is_object($gd)) {$gd = gdk_pixbuf_to_gd(GdkPixbuf::new_from_icon_theme($this-&gt;ITEMS[$key][&quot;icon_from_window&quot;],32));}\t\t\n\t\tif (!is_object($gd)) {\n\t\t    print_r($this-&gt;ITEMS[$key]);\n\t\t    $gd = gdk_pixbuf_to_gd(GdkPixbuf::new_from_icon_theme(&quot;inode-symlink&quot;,32));\n\t\t}\n\t\t\t\n\t\t$x = imagesx($gd);\n\t\t$y = imagesx($gd);\n\t\t$pid = $this-&gt;ITEMS[$key][&quot;pid&quot;];\n\t\tif ($this-&gt;ITEMS[$key][&quot;running&quot;]==1) {\n\t\t\tif (($this-&gt;ITEMS[$key][&quot;active&quot;]==0) and ($this-&gt;ITEMS[$key][&quot;urgent&quot;]==0)) { \/\/ \u0415\u0441\u043b\u0438 \u043e\u043a\u043e\u0448\u043a\u043e \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435, \u0438 \u043d\u0435\u0432\u0430\u0436\u043d\u043e\u0435 - \u0442\u043e\u0433\u0434\u0430 \u0440\u0438\u0441\u0443\u0435\u043c \u0431\u0438\u0440\u044e\u0437\u043e\u0432\u044b\u0439 \u043a\u0440\u0443\u0436\u043e\u0447\u0435\u043a\n\t\t\t\timagefilledellipse($gd, $x\/2+1, $y-4+1, 6, 6, imagecolorallocatealpha($gd, 0, 0, 0, 0));\n\t\t\t\tpcntl_setpriority(10,$pid);\n\t\t\t\tfor ($i = 6; $i &gt;= 1; $i--) {\n\t\t\t\t\timagefilledellipse($gd, $x\/2, $y-4, $i, $i, imagecolorallocatealpha($gd, $i*20, 150+$i*17, 150+$i*17, 0));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif (($this-&gt;ITEMS[$key][&quot;active&quot;]==1) and ($this-&gt;ITEMS[$key][&quot;urgent&quot;]==0)) { \/\/ \u0415\u0441\u043b\u0438 \u043e\u043a\u043e\u0448\u043a\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0435, \u0438 \u043d\u0435\u0432\u0430\u0436\u043d\u043e\u0435 - \u0442\u043e\u0433\u0434\u0430 \u0440\u0438\u0441\u0443\u0435\u043c \u0431\u0438\u0440\u044e\u0437\u043e\u0432\u044b\u0439 \u044d\u043b\u043b\u0438\u043f\u0441\n\t\t\t\timagefilledellipse($gd, $x\/2+1, $y-4+1, 12, 6, imagecolorallocatealpha($gd, 0, 0, 0, 0));\n\t\t\t\tpcntl_setpriority(-10,$pid);\n\t\t\t\tfor ($i = 6; $i &gt;= 1; $i--) {\n\t\t\t\t\timagefilledellipse($gd, $x\/2, $y-4, $i*2, $i, imagecolorallocatealpha($gd, $i*20, 150+$i*17, 150+$i*17, 0));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tif ($this-&gt;ITEMS[$key][&quot;urgent&quot;]==1) { \/\/ \u0415\u0441\u043b\u0438 \u043e\u043a\u043e\u0448\u043a\u043e \u0432\u0430\u0436\u043d\u043e\u0435 - \u0442\u043e\u0433\u0434\u0430 \u0440\u0438\u0441\u0443\u0435\u043c \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u043a\u0440\u0443\u0436\u043e\u0447\u0435\u043a\n\t\t\t\timagefilledellipse($gd, $x\/2+1, $y-4+1, 6, 6, imagecolorallocatealpha($gd, 0, 0, 0, 0));\n\t\t\t\tfor ($i = 6; $i &gt;= 1; $i--) {\n\t\t\t\t\timagefilledellipse($gd, $x\/2, $y-4, $i, $i, imagecolorallocatealpha($gd, 150+$i*17, $i*20, $i*20, 0));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\timagefilledellipse($gd, $x\/2+1, $y-4+1, 6, 6, imagecolorallocatealpha($gd, 0, 0, 0, 0));\n\t\t\t\tfor ($i = 6; $i &gt;= 1; $i--) {\n\t\t\t\t\timagefilledellipse($gd, $x\/2, $y-4, $i, $i, imagecolorallocatealpha($gd, 150+$i*17, 150+$i*17, 150+$i*17, 0));\n\t\t\t\t}\n\t\t}\n\t\t\n\t\tif ((isset($this-&gt;TEMP_NAMES[$key])) and ($this-&gt;TEMP_NAMES[$key]!=&quot;&quot;)) {\n\t\t\t$temp_name = $this-&gt;TEMP_NAMES[$key];\n\t\t\techo &quot;==== setting $temp_name ===== \\n&quot;;\n\t\t\timagettftext($gd, 8, 0, 1, 9, imagecolorallocatealpha($gd, 0, 0, 0, 0), &quot;\/usr\/share\/fonts\/truetype\/dejavu\/DejaVuSans.ttf&quot;, &quot;$temp_name&quot;);\n\t\t\timagettftext($gd, 8, 0, 0, 8, imagecolorallocatealpha($gd, 255, 255, 255, 0), &quot;\/usr\/share\/fonts\/truetype\/dejavu\/DejaVuSans.ttf&quot;, &quot;$temp_name&quot;);\n\t\t}\n\t\t\n\t\tif ($gd) {\n\t\t\timagesavealpha($gd,true);\n\t\t\t$img = GtkImage::new_from_pixbuf(gd_to_pixbuf($gd));\n\t\t\t} else {$img = GtkImage::new_from_icon_theme(&quot;folder&quot;, 32);}\n\t\tif (!isset($this-&gt;ITEM[$key])) {$new = true;} else {$new = false;}\n\t\tif ($new) {$this-&gt;ITEM[$key] = new GtkButton($img);\n\t\t\t$this-&gt;ITEM[$key]-&gt;set_relief(GtkReliefStyle::NONE);\n\t\t\t}\n\t\t$this-&gt;ITEM[$key]-&gt;set_image($img);\n\t\/\/\t$img-&gt;show(); \n\t\t$this-&gt;ITEM[$key]-&gt;set_has_tooltip(true);\n\t\t$this-&gt;ITEM[$key]-&gt;set_tooltip_text($this-&gt;ITEMS[$key][&quot;display_name&quot;]);\n\t\tif ($new) {\n\t\t\t$this-&gt;ITEM[$key]-&gt;set_name(&quot;item1&quot;);\n\t\t\t$this-&gt;ITEM[$key]-&gt;drag_dest_set(&quot;text\/uri-list&quot;, 0, 0);\n\t\t\t$this-&gt;ITEM[$key]-&gt;connect(&quot;button-release-event&quot;,function($button, $event) {global $R; $this-&gt;click_process($button, $event, $R);return false;});\n\t\t\t$this-&gt;ITEM[$key]-&gt;set_data(&quot;xid&quot;, $this-&gt;ITEMS[$key][&#39;xid&#39;]);\n\t\t\t$this-&gt;ITEM[$key]-&gt;set_data(&quot;key&quot;, $key);\n\t\t\t$r = rand(1,100000);\n\t\t\t$this-&gt;ITEM[$key]-&gt;set_data(&quot;uid&quot;, &quot;$r&quot;);\n\t\t\t$old_signal = $this-&gt;ITEM[$key]-&gt;get_data(&quot;signal&quot;);\n\t\t\tif ($old_signal==&quot;&quot;) {\n\t\t\t\t$signal = $this-&gt;ITEM[$key]-&gt;connect(&quot;drag-motion&quot;,function($button, $event) { \/\/ \u0415\u0441\u043b\u0438 \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u043d\u0430\u0432\u0435\u043b\u0438 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0440\u0430\u0433-\u043d-\u0434\u0440\u043e\u043f\u043f\u043d\u043e\u0435\n\t\t\t\t\t$xid = $button-&gt;get_data(&quot;xid&quot;);\n\t\t\t\t\tif ($xid!=$this-&gt;drag_xid) {\n\t\t\t\t\t\t$this-&gt;supreme-&gt;toggleWindowFromDock($xid); \/\/ \u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043e\u043a\u043d\u043e \u043f\u043e\u0434 \u044d\u0442\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439\n\t\t\t\t\t\t$this-&gt;drag_xid = $xid;\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t});\n\t\t\t\t$this-&gt;ITEM[$key]-&gt;set_data(&quot;signal&quot;, &quot;$signal&quot;);\n\t\t\t}\n\t\t}\t\n\t\tif ($new) {$this-&gt;DOCKBOX-&gt;add($this-&gt;ITEM[$key]);} else {$this-&gt;ITEM[$key]-&gt;show_all();}\n\t}\n\n\tprivate function draw_elements_on_dock($redraw = false) {\n\t\tif ($redraw) {\n\t\t\tforeach ($this-&gt;ITEMS as $key =&gt; $value) {\n\t\t\t\t$this-&gt;remove_icon($key);\n\t\t\t\/\/\tunset($this-&gt;ITEM[$key]);\n\t\t\t\/\/\tunset($this-&gt;ITEMS[$key]);\n\t\t\t}\n\t\/\/\t\tunset($this-&gt;ITEM);\n\t\/\/\t\tunset($this-&gt;ITEMS);\n\t\t}\n\t\t\n\t\t$this-&gt;icon_theme = GtkIconTheme::get_default();\n\t\tif (is_array($this-&gt;ITEMS)) {ksort($this-&gt;ITEMS);}\n\t\tforeach ($this-&gt;ITEMS as $key =&gt; $value) {\n\t\t\t$this-&gt;draw_icon($key);\n\t\t}\n\t\t$this-&gt;DOCKBOX-&gt;show_all();\n\t}\n\t\n\tprivate function watch_dock() {\n\t\t$this-&gt;old_windows_state = $this-&gt;new_windows_state;\n\t\t$this-&gt;new_windows_state = [];\n\t\t$this-&gt;new_windows_state = $this-&gt;supreme-&gt;ListActiveWindows();\n\t\tif (!is_array($this-&gt;old_windows_state)) {$this-&gt;old_windows_state = $this-&gt;new_windows_state;}\n\t\tif ($this-&gt;old_windows_state!=$this-&gt;new_windows_state) { \/\/ \u0415\u0441\u043b\u0438 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0441 \u043e\u043a\u043d\u0430\u043c\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c\n\t\t\t$this-&gt;ITEMS = [];\n\t\t\t$apps = $this-&gt;get_running_windows();\n\t\t\tfor ($i = 1; $i &lt;= count($this-&gt;new_windows_state[&quot;xid&quot;]); $i++) { \/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u043d\u043e\u0432\u044b\u0445 \u043e\u043a\u043e\u043d\n\t\t\t\t$xid = $this-&gt;new_windows_state[&quot;xid&quot;][$i];\n\t\t\t\tfor ($ii = 1; $ii &lt;= count($this-&gt;old_windows_state[&quot;xid&quot;]); $ii++) {\n\t\t\t\t\tif ($this-&gt;old_windows_state[&quot;xid&quot;][$ii] == $this-&gt;new_windows_state[&quot;xid&quot;][$i]) {unset($xid);break;}\n\t\t\t\t}\n\t\t\tif (isset($xid)) {\n\t\t\t\t$this-&gt;draw_elements_on_dock(true);\n\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfor ($i = 1; $i &lt;= count($this-&gt;old_windows_state[&quot;xid&quot;]); $i++) { \/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u043e\u043d\n\t\t\t\t$xid = $this-&gt;old_windows_state[&quot;xid&quot;][$i];\n\t\t\t\tfor ($ii = 1; $ii &lt;= count($this-&gt;new_windows_state[&quot;xid&quot;]); $ii++) {\n\t\t\t\t\tif ($this-&gt;new_windows_state[&quot;xid&quot;][$ii] == $this-&gt;old_windows_state[&quot;xid&quot;][$i]) {unset($xid);break;}\n\t\t\t\t}\n\t\t\t\tif (isset($xid)) {\n\t\t\t\t\t$x = $this-&gt;DOCKBOX-&gt;get_children();\n\t\t\t\t\tif (is_array($x)) {\n\t\t\t\t\t\tforeach ($x as &$value) {\n\t\t\t\t\t\t\t$key = $value-&gt;get_name();\n\t\t\t\t\t\t\t$value-&gt;destroy();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tforeach ($this-&gt;ITEM as $key =&gt; $value) {\n\t\t\t\t\t\t$this-&gt;ITEM[$key]-&gt;destroy();\n\t\t\t\t\t\tunset($this-&gt;ITEM[$key]);\n\t\t\t\t\t}\n\t\t\t\t\t$this-&gt;draw_elements_on_dock(true);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfor ($i = 1; $i &lt;= count($this-&gt;new_windows_state[&quot;xid&quot;]); $i++) { \/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u043c \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u043e\u043a\u043e\u043d\n\t\t\t\tunset($xid);\n\t\t\t\tif ($this-&gt;new_windows_state[&quot;window_name&quot;][$i]!=$this-&gt;old_windows_state[&quot;window_name&quot;][$i]) {$xid = $this-&gt;new_windows_state[&quot;xid&quot;][$i];}\n\t\t\t\tif ($this-&gt;new_windows_state[&quot;pixbuf&quot;][$i]!=$this-&gt;old_windows_state[&quot;pixbuf&quot;][$i]) {$xid = $this-&gt;new_windows_state[&quot;xid&quot;][$i];}\n\t\t\t\tif ($this-&gt;new_windows_state[&quot;urgent&quot;][$i]!=$this-&gt;old_windows_state[&quot;urgent&quot;][$i]) {$xid = $this-&gt;new_windows_state[&quot;xid&quot;][$i];}\n\t\t\t\tif ($this-&gt;new_windows_state[&quot;active&quot;][$i]!=$this-&gt;old_windows_state[&quot;active&quot;][$i]) {$xid = $this-&gt;new_windows_state[&quot;xid&quot;][$i];}\n\t\t\t\tif (isset($xid)) {\n\t\t\t\t\t$this-&gt;draw_icon($this-&gt;get_id_by_xid($xid));\n\t\t\t\t} \/\/ of $xid\n\t\t\t}\n\t\t}\n\t\t\/\/ \u0427\u0438\u0442\u0430\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433-\u0444\u0430\u0439\u043b\u0430\n\t\tclearstatcache();\n\t\tif ($this-&gt;CONF_MTIME!=filemtime(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/supreme.conf&quot;)) {\n\t\t\t$this-&gt;CONF_MTIME = filemtime(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/supreme.conf&quot;);\n\t\t\t$this-&gt;conf_dock = read_config_to_array(&quot;\/home\/&quot; . $_SERVER[&quot;USER&quot;] . &quot;\/.config\/supreme.conf&quot;);\n\t\t\t$tick = 150;\n\t\t\tif ($this-&gt;conf_dock[&quot;performance_level&quot;]==1) {$tick = 500;}\n\t\t\tif ($this-&gt;conf_dock[&quot;performance_level&quot;]==0) {$tick = 1000;}\n\t\t\tGtk::timeout_add($tick, function () {return $this-&gt;watch_dock();});\n\t\t\treturn false;\n\t\t}\n\t\t\n\t\tif ($this-&gt;DOCK_MTIME!=filemtime(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock\/&quot;)) {\n\t\t\t$this-&gt;DOCK_MTIME = filemtime(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock\/&quot;);\n\t\t\t$apps = $this-&gt;get_running_windows();\n\t\t\t$x = $this-&gt;DOCKBOX-&gt;get_children();\n\t\t\t\t\tif (is_array($x)) {\n\t\t\t\t\t\tforeach ($x as &$value) {\n\t\t\t\t\t\t\t$key = $value-&gt;get_name();\n\t\t\t\t\t\t\t$value-&gt;destroy();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tforeach ($this-&gt;ITEM as $key =&gt; $value) {\n\t\t\t\t\t\t$this-&gt;ITEM[$key]-&gt;destroy();\n\t\t\t\t\t\tunset($this-&gt;ITEM[$key]);\n\t\t\t\t\t}\n\t\t\t\t\t$this-&gt;draw_elements_on_dock(true);\n\t\t\treturn true;\n\t\t}\n\t\t\n\t\t\n\t\treturn true;\n\t}\n\t\n\tpublic function dock($box) {\n\t\t$this-&gt;supreme = new Supreme();\n\t\t$this-&gt;conf_dock = read_config_to_array(&quot;\/home\/&quot; . $_SERVER[&quot;USER&quot;] . &quot;\/.config\/supreme.conf&quot;);\n\t\t$this-&gt;DOCKBOX = new GtkBox(GtkOrientation::HORIZONTAL,0);\n\t\t$this-&gt;DOCKBOX-&gt;drag_dest_set(&quot;text\/uri-list&quot;, 0, 0);\n\t\t$this-&gt;DOCKBOX-&gt;connect(&quot;drag-motion&quot;,function($button, $event) {\n\t\t\/\/\tprint_r($event);\n\t\t});\n\t\t$this-&gt;DOCKBOX-&gt;connect_after(&quot;drag-drop&quot;, function ($widget, $context, $event) {\n\t\t\techo &quot;DRAG received \\n&quot;;\n\t\t\tprint_r($context);\n\t\t\/\/\texit();\n\t\t});\n\t\t$this-&gt;css_provider = new GtkCssProvider();\n\t\t$this-&gt;css_provider-&gt;load_from_data($this-&gt;css_dock);\n\t\t$this-&gt;style_context = new GtkStyleContext();\n\t\t$this-&gt;style_context-&gt;add_provider_for_screen($this-&gt;css_provider, 600);\n\t\t$box-&gt;add($this-&gt;DOCKBOX);\n\t\t$tick = 150;\n\t\t$this-&gt;DOCK_MTIME = filemtime(&quot;\/home\/&quot;.$_SERVER[&quot;USER&quot;].&quot;\/.config\/dock\/&quot;);\n\t\t$this-&gt;get_installed_apps_by_group();\n\t\t$apps = $this-&gt;get_running_windows();\n\t\/\/\t$docks = $this-&gt;get_docked_items();\n\t\/\/\t$result = $this-&gt;perform_array($apps,$docks);\n\t\t$this-&gt;draw_elements_on_dock();\n\t\t$tick = 150;\n\t\tif ($this-&gt;conf_dock[&quot;performance_level&quot;]==1) {$tick = 500;}\n\t\tif ($this-&gt;conf_dock[&quot;performance_level&quot;]==0) {$tick = 1000;}\n\t\tGtk::timeout_add($tick, function () {return $this-&gt;watch_dock();});\n\n\t}\n}\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-437","post","type-post","status-publish","format-standard","hentry","category-7"],"_links":{"self":[{"href":"https:\/\/phpsupreme.de\/index.php?rest_route=\/wp\/v2\/posts\/437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpsupreme.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpsupreme.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpsupreme.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpsupreme.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=437"}],"version-history":[{"count":1,"href":"https:\/\/phpsupreme.de\/index.php?rest_route=\/wp\/v2\/posts\/437\/revisions"}],"predecessor-version":[{"id":438,"href":"https:\/\/phpsupreme.de\/index.php?rest_route=\/wp\/v2\/posts\/437\/revisions\/438"}],"wp:attachment":[{"href":"https:\/\/phpsupreme.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpsupreme.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpsupreme.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}