WM menu in left and right padding

git-svn-id: http://tint2.googlecode.com/svn/trunk@19 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr 2008-11-12 15:11:39 +00:00
parent b1c239db22
commit 9707ec36d2
9 changed files with 71 additions and 35 deletions

View file

@ -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 2008-11-02
- fixed bugs with new design - fixed bugs with new design

11
README
View file

@ -16,4 +16,15 @@ check http://code.google.com/p/tint2/
for latest release, documentation and sample config file. 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.

View file

@ -31,25 +31,21 @@
void visual_refresh () void visual_refresh ()
{ {
if (!server.root_pmap) { if (!panel.area.pmap)
Pixmap wall = get_root_pixmap(); set_panel_background();
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 (server.pmap) XFreePixmap (server.dsp, server.pmap); if (server.pmap) XFreePixmap (server.dsp, server.pmap);
server.pmap = server_create_pixmap (panel.area.width, panel.area.height); 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 child object
GSList *l = panel.area.list;
draw (&panel.area); 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); // main_win doesn't include panel.area.paddingx, so we have WM capabilities on left and right.
XFlush(server.dsp); 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; panel.refresh = 0;
} }
@ -125,9 +121,10 @@ void window_draw_panel ()
/* Catch some events */ /* Catch some events */
XSetWindowAttributes att = { ParentRelative, 0L, 0, 0L, 0, 0, Always, 0L, 0L, False, ExposureMask|ButtonPressMask|ButtonReleaseMask, NoEventMask, False, 0, 0 }; 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); 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); set_panel_properties (win);
window.main_win = win; window.main_win = win;
@ -136,7 +133,9 @@ void window_draw_panel ()
if (server.gc) XFree(server.gc); if (server.gc) XFree(server.gc);
XGCValues gcValues; XGCValues gcValues;
server.gc = XCreateGC(server.dsp, win, (unsigned long) 0, &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); XMapWindow (server.dsp, win);
XFlush (server.dsp); XFlush (server.dsp);
} }
@ -164,7 +163,35 @@ void visible_object()
panel.area.list = g_slist_append(panel.area.list, taskbar); panel.area.list = g_slist_append(panel.area.list, taskbar);
} }
} }
redraw(&panel.area);
panel.refresh = 1; 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);
}

View file

@ -78,6 +78,6 @@ void visual_refresh ();
void set_panel_properties (Window win); void set_panel_properties (Window win);
void window_draw_panel (); void window_draw_panel ();
void visible_object(); void visible_object();
void set_panel_background();
#endif #endif

View file

@ -79,8 +79,8 @@ typedef struct
Visual *visual; Visual *visual;
int posx, posy; int posx, posy;
Pixmap pmap; Pixmap pmap;
Pixmap root_pmap;
GC gc; GC gc;
GC gc_root;
Global_atom atom; Global_atom atom;
} Server_global; } Server_global;

View file

@ -97,7 +97,7 @@ void init ()
/* Catch events */ /* Catch events */
XSelectInput (server.dsp, server.root_win, PropertyChangeMask|StructureNotifyMask); 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) { else if (at == server.atom._NET_NUMBER_OF_DESKTOPS) {
config_taskbar(); config_taskbar();
visible_object(); visible_object();
redraw(&panel.area);
} }
/* Change desktop */ /* Change desktop */
else if (at == server.atom._NET_CURRENT_DESKTOP) { else if (at == server.atom._NET_CURRENT_DESKTOP) {
@ -265,10 +264,8 @@ void event_property_notify (Window win, Atom at)
} }
/* Wallpaper changed */ /* Wallpaper changed */
else if (at == server.atom._XROOTPMAP_ID) { else if (at == server.atom._XROOTPMAP_ID) {
XFreePixmap (server.dsp, server.root_pmap); XFreePixmap (server.dsp, panel.area.pmap);
server.root_pmap = 0; panel.area.pmap = 0;
redraw(&panel.area);
panel.clock.area.redraw = 1;
panel.refresh = 1; panel.refresh = 1;
} }
} }
@ -354,8 +351,8 @@ int main (int argc, char *argv[])
init (); init ();
load_config: load_config:
if (server.root_pmap) XFreePixmap (server.dsp, server.root_pmap); if (panel.area.pmap) XFreePixmap (server.dsp, panel.area.pmap);
server.root_pmap = 0; panel.area.pmap = 0;
// read tint2rc config // read tint2rc config
i = 0; i = 0;
if (c != -1) if (c != -1)
@ -401,7 +398,8 @@ load_config:
break; break;
case Expose: 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; break;
case PropertyNotify: case PropertyNotify:

BIN
src/tint2

Binary file not shown.

View file

@ -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); XCopyArea (server.dsp, a->pmap, server.pmap, server.gc, 0, 0, a->width, a->height, a->posx, a->posy);
GSList *l = a->list; GSList *l = a->list;
if (l) { // draw child object
// draw child object for (; l ; l = l->next)
for (; l ; l = l->next) draw(l->data);
draw(l->data);
}
//printf("end draw area\n"); //printf("end draw area\n");
return ret; return ret;

View file

@ -23,7 +23,7 @@ panel_monitor = 1
panel_position = bottom right panel_position = bottom right
panel_size = 0 27 panel_size = 0 27
panel_margin = 0 0 panel_margin = 0 0
panel_padding = 3 2 panel_padding = 4 2
font_shadow = 0 font_shadow = 0
panel_background_id = 1 panel_background_id = 1