]> Dogcows Code - chaz/tint2/blobdiff - src/panel.c
*add* more real_transparency things added... whole panel works now, but systray still...
[chaz/tint2] / src / panel.c
index 50aa5c38bf175e0779afff8e9fca4d844572d54a..ee3e27df6bb6042eca449152538c98cf102ce962 100644 (file)
@@ -52,7 +52,6 @@ int panel_refresh;
 
 Task *task_active;
 Task *task_drag;
-GSList *urgent_list;
 int  max_tick_urgent;
 
 // panel's initial config
@@ -152,14 +151,22 @@ void init_panel()
                        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 };
-                       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);
+                       XSetWindowAttributes att = { .event_mask=event_mask, .colormap=server.colormap, .background_pixel=0, .border_pixel=0 };
+                       unsigned long mask = CWEventMask|CWColormap|CWBackPixel|CWBorderPixel;
+                       p->main_win = XCreateWindow(server.dsp, server.root_win, p->posx, p->posy, p->area.width, p->area.height, 0, server.depth, InputOutput, server.visual, mask, &att);
                }
                else {
                        // old panel
                        XMoveResizeWindow(server.dsp, p->main_win, p->posx, p->posy, p->area.width, p->area.height);
                }
 
+               if (!server.gc) {
+                       XGCValues  gcv;
+                       if (real_transparency)
+                               server.gc = XCreateGC(server.dsp, p->main_win, 0, &gcv);
+                       else
+                               server.gc = XCreateGC (server.dsp, server.root_win, (unsigned long)0, &gcv);
+               }
                //printf("panel %d : %d, %d, %d, %d\n", i, p->posx, p->posy, p->area.width, p->area.height);
                set_panel_properties(p);
                set_panel_background(p);
@@ -239,11 +246,6 @@ void cleanup_panel()
 
        task_active = 0;
        task_drag = 0;
-       while (urgent_list) {
-               Task_urgent* t = urgent_list->data;
-               urgent_list = g_slist_remove(urgent_list, urgent_list->data);
-               free(t);
-       }
 
        cleanup_taskbar();
 
@@ -427,16 +429,21 @@ void set_panel_properties(Panel *p)
        XChangeProperty(server.dsp, p->main_win, server.atom.XdndAware, XA_ATOM, 32, PropModeReplace, (unsigned char*)&version, 1);
 
        // Reserved space
+       unsigned int d1, screen_width, screen_height;
+       Window d2;
+       int d3;
+       XGetGeometry(server.dsp, server.root_win, &d2, &d3, &d3, &screen_width, &screen_height, &d1, &d1);
+       Monitor monitor = server.monitor[p->monitor];
        long   struts [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        if (panel_horizontal) {
                if (panel_position & TOP) {
-                       struts[2] = p->area.height + p->marginy;
+                       struts[2] = p->area.height + p->marginy + monitor.y;
                        struts[8] = p->posx;
                        // p->area.width - 1 allowed full screen on monitor 2
                        struts[9] = p->posx + p->area.width - 1;
                }
                else {
-                       struts[3] = p->area.height + p->marginy;
+                       struts[3] = p->area.height + p->marginy + screen_height - monitor.y - monitor.height;
                        struts[10] = p->posx;
                        // p->area.width - 1 allowed full screen on monitor 2
                        struts[11] = p->posx + p->area.width - 1;
@@ -444,13 +451,13 @@ void set_panel_properties(Panel *p)
        }
        else {
                if (panel_position & LEFT) {
-                       struts[0] = p->area.width + p->marginx;
+                       struts[0] = p->area.width + p->marginx + monitor.x;
                        struts[4] = p->posy;
                        // p->area.width - 1 allowed full screen on monitor 2
                        struts[5] = p->posy + p->area.height - 1;
                }
                else {
-                       struts[1] = p->area.width + p->marginx;
+                       struts[1] = p->area.width + p->marginx + screen_width - monitor.x - monitor.width;
                        struts[6] = p->posy;
                        // p->area.width - 1 allowed full screen on monitor 2
                        struts[7] = p->posy + p->area.height - 1;
@@ -467,16 +474,35 @@ void set_panel_properties(Panel *p)
        size_hints.min_width = size_hints.max_width = p->area.width;
        size_hints.min_height = size_hints.max_height = p->area.height;
        XSetWMNormalHints(server.dsp, p->main_win, &size_hints);
+
+       // Set WM_CLASS
+       XClassHint* classhint = XAllocClassHint();
+       classhint->res_name = "tint2";
+       classhint->res_class = "Tint2";
+       XSetClassHint(server.dsp, p->main_win, classhint);
+       XFree(classhint);
 }
 
 
 void set_panel_background(Panel *p)
 {
-       get_root_pixmap();
-
        if (p->area.pix.pmap) XFreePixmap (server.dsp, p->area.pix.pmap);
        p->area.pix.pmap = XCreatePixmap (server.dsp, server.root_win, p->area.width, p->area.height, server.depth);
 
+       if (real_transparency) {
+               cairo_surface_t *tmp = cairo_xlib_surface_create (server.dsp, p->area.pix.pmap, server.visual, p->area.width, p->area.height);
+               cairo_t *cr = cairo_create(tmp);
+               cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+               cairo_rectangle(cr, 0, 0, p->area.width, p->area.height);
+               cairo_set_source_rgba(cr, 1, 1, 1, 0);
+               cairo_paint (cr);
+               cairo_destroy (cr);
+               cairo_surface_destroy (tmp);
+               return;
+       }
+
+       get_root_pixmap();
+
        // copy background (server.root_pmap) in panel.area.pix.pmap
        Window dummy;
        int  x, y;
This page took 0.022796 seconds and 4 git commands to generate.