all repos — tint2 @ 145ce16757d7af43bcbd3a51c686dbc51c825a6a

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

issue 135 and xrandr management (more to come)

git-svn-id: http://tint2.googlecode.com/svn/trunk@202 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
lorthiois@bbsoft.fr lorthiois@bbsoft.fr@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

145ce16757d7af43bcbd3a51c686dbc51c825a6a

parent

e015d5b19c126e06427d749d52d588438a02c77a

7 files changed, 137 insertions(+), 102 deletions(-)

jump to
M src/config.csrc/config.c

@@ -79,7 +79,8 @@ {

cleanup_panel(); // get monitor and desktop config - get_monitors_and_desktops(); + get_monitors(); + get_desktops(); // append full transparency background list_back = g_slist_append(0, calloc(1, sizeof(Area)));

@@ -90,7 +91,7 @@ panel_config->g_task.alpha_active = 100;

systray.sort = 1; // window manager's menu default value == false - wm_menu = 0; + wm_menu = wm_menu_open = 0; max_tick_urgent = 7; }

@@ -742,7 +743,7 @@

void config_finish () { if (panel_config->monitor > (server.nb_monitor-1)) { - // server.nb_monitor minimum value is 1 (see get_monitors_and_desktops()) + // server.nb_monitor minimum value is 1 (see get_monitors()) // and panel_config->monitor is higher fprintf(stderr, "warning : monitor not found. tint2 default to monitor 1.\n"); panel_config->monitor = 0;
M src/panel.csrc/panel.c

@@ -43,7 +43,7 @@ int mouse_tilt_left;

int mouse_tilt_right; int panel_mode; -int wm_menu; +int wm_menu, wm_menu_open; int panel_dock=0; // default not in the dock int panel_position; int panel_horizontal;

@@ -106,59 +106,7 @@ p->initial_width = 100;

p->pourcentx = 1; } - // detect panel size - if (panel_horizontal) { - if (p->pourcentx) - p->area.width = (float)server.monitor[p->monitor].width * p->initial_width / 100; - else - p->area.width = p->initial_width; - if (p->pourcenty) - p->area.height = (float)server.monitor[p->monitor].height * p->initial_height / 100; - else - p->area.height = p->initial_height; - if (p->area.pix.border.rounded > p->area.height/2) - p->area.pix.border.rounded = p->area.height/2; - } - else { - if (p->pourcentx) - p->area.height = (float)server.monitor[p->monitor].height * p->initial_width / 100; - else - p->area.height = p->initial_width; - if (p->pourcenty) - p->area.width = (float)server.monitor[p->monitor].width * p->initial_height / 100; - else - p->area.width = p->initial_height; - if (p->area.pix.border.rounded > p->area.width/2) - p->area.pix.border.rounded = p->area.width/2; - } - - /* panel position determined here */ - if (panel_position & LEFT) { - p->posx = server.monitor[p->monitor].x + p->marginx; - } - else { - if (panel_position & RIGHT) { - p->posx = server.monitor[p->monitor].x + server.monitor[p->monitor].width - p->area.width - p->marginx; - } - else { - if (panel_horizontal) - p->posx = server.monitor[p->monitor].x + ((server.monitor[p->monitor].width - p->area.width) / 2); - else - p->posx = server.monitor[p->monitor].x + p->marginx; - } - } - if (panel_position & TOP) { - p->posy = server.monitor[p->monitor].y + p->marginy; - } - else { - if (panel_position & BOTTOM) { - p->posy = server.monitor[p->monitor].y + server.monitor[p->monitor].height - p->area.height - p->marginy; - } - else { - p->posy = server.monitor[p->monitor].y + ((server.monitor[p->monitor].height - p->area.height) / 2); - } - } - // printf("panel : posx %d, posy %d, width %d, height %d\n", p->posx, p->posy, p->area.width, p->area.height); + init_panel_size_and_position(p); // Catch some events long event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask;

@@ -174,6 +122,64 @@

XMapWindow (server.dsp, p->main_win); } panel_refresh = 1; +} + + +void init_panel_size_and_position(Panel *panel) +{ + // detect panel size + if (panel_horizontal) { + if (panel->pourcentx) + panel->area.width = (float)server.monitor[panel->monitor].width * panel->initial_width / 100; + else + panel->area.width = panel->initial_width; + if (panel->pourcenty) + panel->area.height = (float)server.monitor[panel->monitor].height * panel->initial_height / 100; + else + panel->area.height = panel->initial_height; + if (panel->area.pix.border.rounded > panel->area.height/2) + panel->area.pix.border.rounded = panel->area.height/2; + } + else { + if (panel->pourcentx) + panel->area.height = (float)server.monitor[panel->monitor].height * panel->initial_width / 100; + else + panel->area.height = panel->initial_width; + if (panel->pourcenty) + panel->area.width = (float)server.monitor[panel->monitor].width * panel->initial_height / 100; + else + panel->area.width = panel->initial_height; + if (panel->area.pix.border.rounded > panel->area.width/2) + panel->area.pix.border.rounded = panel->area.width/2; + } + + // panel position determined here + if (panel_position & LEFT) { + panel->posx = server.monitor[panel->monitor].x + panel->marginx; + } + else { + if (panel_position & RIGHT) { + panel->posx = server.monitor[panel->monitor].x + server.monitor[panel->monitor].width - panel->area.width - panel->marginx; + } + else { + if (panel_horizontal) + panel->posx = server.monitor[panel->monitor].x + ((server.monitor[panel->monitor].width - panel->area.width) / 2); + else + panel->posx = server.monitor[panel->monitor].x + panel->marginx; + } + } + if (panel_position & TOP) { + panel->posy = server.monitor[panel->monitor].y + panel->marginy; + } + else { + if (panel_position & BOTTOM) { + panel->posy = server.monitor[panel->monitor].y + server.monitor[panel->monitor].height - panel->area.height - panel->marginy; + } + else { + panel->posy = server.monitor[panel->monitor].y + ((server.monitor[panel->monitor].height - panel->area.height) / 2); + } + } + // printf("panel : posx %d, posy %d, width %d, height %d\n", panel->posx, panel->posy, panel->area.width, panel->area.height); }
M src/panel.hsrc/panel.h

@@ -38,7 +38,7 @@

//panel mode enum { SINGLE_DESKTOP=0, MULTI_DESKTOP }; extern int panel_mode; -extern int wm_menu; +extern int wm_menu, wm_menu_open; extern int panel_dock; //panel position

@@ -106,6 +106,7 @@ extern int nb_panel;

void init_panel(); +void init_panel_size_and_position(Panel *panel); void cleanup_panel(); void resize_panel(void *obj);
M src/server.csrc/server.c

@@ -219,15 +219,13 @@ }

} -void get_monitors_and_desktops() +void get_monitors() { - int i; - if (server.monitor) free(server.monitor); server.nb_monitor = 0; server.monitor = 0; - int nb_monitor; + int i, nb_monitor; if (XineramaIsActive(server.dsp)) { XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nb_monitor);

@@ -274,6 +272,12 @@ server.monitor[0].x = server.monitor[0].y = 0;

server.monitor[0].width = DisplayWidth (server.dsp, server.screen); server.monitor[0].height = DisplayHeight (server.dsp, server.screen); } +} + + +void get_desktops() +{ + int i; // detect number of desktops // wait 15s to leave some time for window manager startup
M src/server.hsrc/server.h

@@ -115,7 +115,8 @@ // detect root background

void get_root_pixmap(); // detect monitors and desktops -void get_monitors_and_desktops(); +void get_monitors(); +void get_desktops(); #endif
M src/tint.csrc/tint.c

@@ -270,6 +270,7 @@ task_drag = click_task(panel, e->xbutton.x, e->xbutton.y);

if (wm_menu && !task_drag && !click_clock(panel, e->xbutton.x, e->xbutton.y) && (e->xbutton.button != 1) ) { // forward the click to the desktop window (thanks conky) + wm_menu_open = 1; XUngrabPointer(server.dsp, e->xbutton.time); e->xbutton.window = server.root_win; // icewm doesn't open under the mouse.

@@ -291,11 +292,12 @@ {

Panel *panel = get_panel(e->xany.window); if (!panel) return; - if (wm_menu && click_padding(panel, e->xbutton.x, e->xbutton.y)) { - // forward the click to the desktop window (thanks conky) - e->xbutton.window = server.root_win; - XSendEvent(server.dsp, e->xbutton.window, False, ButtonReleaseMask, e); - return; + if (wm_menu && wm_menu_open) { + // forward the click to the desktop window (thanks conky) + wm_menu_open = 0; + e->xbutton.window = server.root_win; + XSendEvent(server.dsp, e->xbutton.window, False, ButtonReleaseMask, e); + return; } int action = TOGGLE_ICONIFY;

@@ -613,42 +615,59 @@

void event_configure_notify (Window win) { + // change in root window (xrandr) if (win == server.root_win) { - printf("ConfigureNotify on root\n"); - //XMoveWindow(dpy, fen, pos_x, pos_y); - //XResizeWindow(dpy, fen, largeur, hauteur); + int i, old_monitor = server.nb_monitor; + + get_monitors(); + if (old_monitor != server.nb_monitor) { + } + for (i=0 ; i < nb_panel ; i++) { + Panel *panel = &panel1[i]; + + init_panel_size_and_position(panel); + XMoveResizeWindow(server.dsp, panel->main_win, panel->posx, panel->posy, panel->area.width, panel->area.height); + set_panel_background(panel); + + // force the resize of childs + GSList *l0; + panel->area.resize = 1; + for (l0 = panel->area.list; l0 ; l0 = l0->next) + ((Area*)l0->data)->resize = 1; + } + panel_refresh = 1; + //printf("ConfigureNotify on root width=%d, height=%d\n", server.monitor[0].width, server.monitor[0].height); + return; } - else { - // check 'win' move in systray - TrayWindow *traywin; - GSList *l; - for (l = systray.list_icons; l ; l = l->next) { - traywin = (TrayWindow*)l->data; - if (traywin->id == win) { - //printf("move tray %d\n", traywin->x); - XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height); - panel_refresh = 1; - return; - } + + // 'win' is a trayer icon + TrayWindow *traywin; + GSList *l; + for (l = systray.list_icons; l ; l = l->next) { + traywin = (TrayWindow*)l->data; + if (traywin->id == win) { + //printf("move tray %d\n", traywin->x); + XMoveResizeWindow(server.dsp, traywin->id, traywin->x, traywin->y, traywin->width, traywin->height); + panel_refresh = 1; + return; } + } - // check 'win' move in another monitor - if (nb_panel == 1) return; - if (server.nb_monitor == 1) return; - Task *tsk = task_get_task (win); - if (!tsk) return; + // 'win' move in another monitor + if (nb_panel == 1) return; + Task *tsk = task_get_task (win); + if (!tsk) return; - Panel *p = tsk->area.panel; - if (p->monitor != window_get_monitor (win)) { - remove_task (tsk); - add_task (win); - if (win == window_get_active ()) { - Task *tsk = task_get_task (win); - tsk->area.is_active = 1; - task_active = tsk; - } - panel_refresh = 1; + Panel *p = tsk->area.panel; + if (p->monitor != window_get_monitor (win)) { + remove_task (tsk); + add_task (win); + if (win == window_get_active ()) { + Task *tsk = task_get_task (win); + tsk->area.is_active = 1; + task_active = tsk; } + panel_refresh = 1; } }
M src/util/area.csrc/util/area.c

@@ -72,13 +72,16 @@ GSList *l;

if (a->resize) { a->resize = 0; - for (l = a->list; l ; l = l->next) - size(l->data); + // force the resize of childs + for (l = a->list; l ; l = l->next) { + Area *area = (Area*)l->data; + area->resize = 1; + size(area); + } // resize can generate a redraw - if (a->_resize) { + if (a->_resize) a->_resize(a); - } } }