WM menu in left and right padding git-svn-id: http://tint2.googlecode.com/svn/trunk@19 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
lorthiois@bbsoft.fr lorthiois@bbsoft.fr@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
9 files changed,
71 insertions(+),
35 deletions(-)
M
README
→
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. + + + +
M
src/panel.c
→
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 @@
/* 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 @@ // replaced : server.gc = DefaultGC (server.dsp, 0);
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 @@
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); +} + +
M
src/panel.h
→
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
M
src/server.h
→
src/server.h
@@ -79,8 +79,8 @@ int got_root_win;
Visual *visual; int posx, posy; Pixmap pmap; - Pixmap root_pmap; GC gc; + GC gc_root; Global_atom atom; } Server_global;
M
src/tint.c
→
src/tint.c
@@ -97,7 +97,7 @@
/* Catch events */ XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); - setlocale(LC_ALL, ""); + setlocale (LC_ALL, ""); }@@ -237,7 +237,6 @@ /* Change number of desktops */
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 @@ panel.refresh = 1;
} /* 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 @@ c = getopt (argc, argv, "c:");
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 @@ event_button_release (e.xbutton.button, e.xbutton.x, e.xbutton.y);
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:
M
src/util/area.c
→
src/util/area.c
@@ -70,11 +70,9 @@
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;