From: Thierry Lorthiois Date: Wed, 12 Nov 2008 15:11:39 +0000 (+0000) Subject: WM menu in left and right padding X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=88a08d8838c1b6dce06c73160005249bf3f1ed60;p=chaz%2Ftint2 WM menu in left and right padding --- diff --git a/ChangeLog b/ChangeLog index 2a19b34..aff06a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ - +2008-11-12 +- panel's left and right padding feel like WM background + (right click open window managers's menu, ...) 2008-11-02 - fixed bugs with new design diff --git a/README b/README index 018c197..1835446 100644 --- a/README +++ b/README @@ -16,4 +16,15 @@ check http://code.google.com/p/tint2/ for latest release, documentation and sample config file. +--------------------------------------------------------- +FAQ: + +- How to get menu in tint2 panel ? +use panel_padding = x y with option x>1 +then put the mouse in left (or right) padding and right clic, +tint2 will open the menu of your Window manager. + + + + diff --git a/src/panel.c b/src/panel.c index f3bd2be..b9cbcf2 100644 --- a/src/panel.c +++ b/src/panel.c @@ -31,25 +31,21 @@ void visual_refresh () { - if (!server.root_pmap) { - Pixmap wall = get_root_pixmap(); - - server.root_pmap = server_create_pixmap (panel.area.width, panel.area.height); - - XCopyArea (server.dsp, wall, server.root_pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0); - - redraw (&panel.area); - } + if (!panel.area.pmap) + set_panel_background(); if (server.pmap) XFreePixmap (server.dsp, server.pmap); server.pmap = server_create_pixmap (panel.area.width, panel.area.height); + XCopyArea (server.dsp, panel.area.pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0); - XCopyArea (server.dsp, server.root_pmap, server.pmap, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0); - - draw (&panel.area); + // draw child object + GSList *l = panel.area.list; + for (; l ; l = l->next) + draw (l->data); - XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0); - XFlush(server.dsp); + // main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right. + XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, panel.area.paddingx, 0, panel.area.width-(2*panel.area.paddingx), panel.area.height, 0, 0); + XFlush (server.dsp); panel.refresh = 0; } @@ -125,9 +121,10 @@ void window_draw_panel () /* Catch some events */ XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 }; - /* XCreateWindow(display, parent, x, y, w, h, border, depth, class, visual, mask, attrib) */ + // XCreateWindow(display, parent, x, y, w, h, border, depth, class, visual, mask, attrib) + // main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right. if (window.main_win) XDestroyWindow(server.dsp, window.main_win); - win = XCreateWindow (server.dsp, server.root_win, server.posx, server.posy, panel.area.width, panel.area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att); + win = XCreateWindow (server.dsp, server.root_win, server.posx+panel.area.paddingx, server.posy, panel.area.width-(2*panel.area.paddingx), panel.area.height, 0, server.depth, InputOutput, CopyFromParent, CWEventMask, &att); set_panel_properties (win); window.main_win = win; @@ -136,7 +133,9 @@ void window_draw_panel () if (server.gc) XFree(server.gc); XGCValues gcValues; server.gc = XCreateGC(server.dsp, win, (unsigned long) 0, &gcValues); - + if (server.gc_root) XFree(server.gc_root); + server.gc_root = XCreateGC(server.dsp, server.root_win, (unsigned long) 0, &gcValues); + XMapWindow (server.dsp, win); XFlush (server.dsp); } @@ -164,7 +163,35 @@ void visible_object() panel.area.list = g_slist_append(panel.area.list, taskbar); } } + redraw(&panel.area); panel.refresh = 1; } +void set_panel_background() +{ + Pixmap wall = get_root_pixmap(); + + panel.area.pmap = server_create_pixmap (panel.area.width, panel.area.height); + + // add layer of root pixmap + XCopyArea (server.dsp, wall, panel.area.pmap, server.gc, server.posx, server.posy, panel.area.width, panel.area.height, 0, 0); + + // draw background panel + cairo_surface_t *cs; + cairo_t *c; + cs = cairo_xlib_surface_create (server.dsp, panel.area.pmap, server.visual, panel.area.width, panel.area.height); + c = cairo_create (cs); + + draw_background (&panel.area, c); + + cairo_destroy (c); + cairo_surface_destroy (cs); + + // copy background panel on desktop window + XCopyArea (server.dsp, panel.area.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy); + + redraw (&panel.area); +} + + diff --git a/src/panel.h b/src/panel.h index 54a74e9..4a3e245 100644 --- a/src/panel.h +++ b/src/panel.h @@ -78,6 +78,6 @@ void visual_refresh (); void set_panel_properties (Window win); void window_draw_panel (); void visible_object(); - +void set_panel_background(); #endif diff --git a/src/server.h b/src/server.h index c4225db..e6e230e 100644 --- a/src/server.h +++ b/src/server.h @@ -79,8 +79,8 @@ typedef struct Visual *visual; int posx, posy; Pixmap pmap; - Pixmap root_pmap; GC gc; + GC gc_root; Global_atom atom; } Server_global; diff --git a/src/tint.c b/src/tint.c index b0959ec..46c0c22 100644 --- a/src/tint.c +++ b/src/tint.c @@ -97,7 +97,7 @@ void init () /* Catch events */ XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); - setlocale(LC_ALL, ""); + setlocale (LC_ALL, ""); } @@ -237,7 +237,6 @@ void event_property_notify (Window win, Atom at) else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) { config_taskbar(); visible_object(); - redraw(&panel.area); } /* Change desktop */ else if (at == server.atom._NET_CURRENT_DESKTOP) { @@ -265,10 +264,8 @@ void event_property_notify (Window win, Atom at) } /* Wallpaper changed */ else if (at == server.atom._XROOTPMAP_ID) { - XFreePixmap (server.dsp, server.root_pmap); - server.root_pmap = 0; - redraw(&panel.area); - panel.clock.area.redraw = 1; + XFreePixmap (server.dsp, panel.area.pmap); + panel.area.pmap = 0; panel.refresh = 1; } } @@ -354,8 +351,8 @@ int main (int argc, char *argv[]) init (); load_config: - if (server.root_pmap) XFreePixmap (server.dsp, server.root_pmap); - server.root_pmap = 0; + if (panel.area.pmap) XFreePixmap (server.dsp, panel.area.pmap); + panel.area.pmap = 0; // read tint2rc config i = 0; if (c != -1) @@ -401,7 +398,8 @@ load_config: break; case Expose: - XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, 0, 0, panel.area.width, panel.area.height, 0, 0); + XCopyArea (server.dsp, panel.area.pmap, server.root_win, server.gc_root, 0, 0, panel.area.width, panel.area.height, server.posx, server.posy); + XCopyArea (server.dsp, server.pmap, window.main_win, server.gc, panel.area.paddingx, 0, panel.area.width-(2*panel.area.paddingx), panel.area.height, 0, 0); break; case PropertyNotify: diff --git a/src/tint2 b/src/tint2 index ee44748..fcc2f2d 100755 Binary files a/src/tint2 and b/src/tint2 differ diff --git a/src/util/area.c b/src/util/area.c index c1347a1..6585c3e 100644 --- a/src/util/area.c +++ b/src/util/area.c @@ -70,11 +70,9 @@ int draw (Area *a) XCopyArea (server.dsp, a->pmap, server.pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy); GSList *l = a->list; - if (l) { - // draw child object - for (; l ; l = l->next) - draw(l->data); - } + // draw child object + for (; l ; l = l->next) + draw(l->data); //printf("end draw area\n"); return ret; diff --git a/tintrc02 b/tintrc02 index c8bdcf7..4a2c72d 100644 --- a/tintrc02 +++ b/tintrc02 @@ -23,7 +23,7 @@ panel_monitor = 1 panel_position = bottom right panel_size = 0 27 panel_margin = 0 0 -panel_padding = 3 2 +panel_padding = 4 2 font_shadow = 0 panel_background_id = 1