]> Dogcows Code - chaz/tint2/blobdiff - src/panel.c
add default icon on task (/usr/share/tint2/default_icon.png needed)
[chaz/tint2] / src / panel.c
index 5275d38c5c557344c05dbf58f9581bbbf39b2554..a753dfec1646f033342734788d2b6f1885be4739 100644 (file)
@@ -29,6 +29,7 @@
 #include "window.h"
 #include "task.h"
 #include "panel.h"
+#include "tooltip.h"
 
 
 int signal_pending;
@@ -43,6 +44,7 @@ int mouse_tilt_right;
 
 int panel_mode;
 int wm_menu;
+int panel_dock=0;  // default not in the dock
 int panel_position;
 int panel_horizontal;
 int panel_refresh;
@@ -56,6 +58,7 @@ int  max_tick_urgent;
 Panel *panel1 = 0;
 int  nb_panel;
 
+Imlib_Image default_icon;
 
 
 void init_panel()
@@ -63,6 +66,17 @@ void init_panel()
        int i;
        Panel *p;
 
+       // load default icon
+       char *path;
+       const gchar * const *data_dirs;
+       data_dirs = g_get_system_data_dirs ();
+       for (i = 0; data_dirs[i] != NULL; i++)  {
+               path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL);
+               if (g_file_test (path, G_FILE_TEST_EXISTS))
+                       default_icon = imlib_load_image(path);
+               g_free(path);
+       }
+
        for (i=0 ; i < nb_panel ; i++) {
                p = &panel1[i];
 
@@ -147,7 +161,10 @@ void init_panel()
                // printf("panel : posx %d, posy %d, width %d, height %d\n", p->posx, p->posy, p->area.width, p->area.height);
 
                // Catch some events
-               XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 };
+               long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask;
+               if (g_tooltip.enabled)
+                       event_mask |= PointerMotionMask|LeaveWindowMask;
+               XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, event_mask, NoEventMask, False, 0, 0 };
                if (p->main_win) XDestroyWindow(server.dsp, p->main_win);
                p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att);
 
@@ -170,6 +187,11 @@ void cleanup_panel()
        cleanup_systray();
        cleanup_taskbar();
 
+       if (default_icon) {
+               imlib_context_set_image(default_icon);
+               imlib_free_image();
+       }
+
        // font allocated once
        if (panel1[0].g_task.font_desc) {
                pango_font_description_free(panel1[0].g_task.font_desc);
@@ -197,6 +219,15 @@ void cleanup_panel()
 
        if (panel1) free(panel1);
        panel1 = 0;
+
+       if (g_tooltip.window) {
+               XDestroyWindow(server.dsp, g_tooltip.window);
+               g_tooltip.window = 0;
+       }
+       if (g_tooltip.font_desc) {
+               pango_font_description_free(g_tooltip.font_desc);
+               g_tooltip.font_desc = 0;
+       }
 }
 
 
@@ -369,9 +400,17 @@ void set_panel_properties(Panel *p)
 
        // Unfocusable
        XWMHints wmhints;
-       wmhints.flags = InputHint;
-       wmhints.input = False;
-       XChangeProperty (server.dsp, p->main_win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4);
+       if (panel_dock) {
+               // TODO: Xdnd feature cannot be used in withdrawn state at the moment (at least GTK apps fail, qt seems to work)
+               wmhints.icon_window = wmhints.window_group = p->main_win;
+               wmhints.flags = StateHint | IconWindowHint;
+               wmhints.initial_state = WithdrawnState;
+       }
+       else {
+               wmhints.flags = InputHint;
+               wmhints.input = False;
+       }
+  XSetWMHints(server.dsp, p->main_win, &wmhints);
 
        // Undecorated
        long prop[5] = { 2, 0, 0, 0, 0 };
This page took 0.026907 seconds and 4 git commands to generate.