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
- 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.
---------------------------------------------------------
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 ()
{
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);
}

View file

@ -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

View file

@ -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;

View file

@ -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:

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);
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;

View file

@ -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