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)));
systray.sort = 1;
// window manager's menu default value == false
- wm_menu = 0;
+ wm_menu = wm_menu_open = 0;
max_tick_urgent = 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;
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;
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;
}
+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);
+}
+
+
void cleanup_panel()
{
if (!panel1) return;
//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
void init_panel();
+void init_panel_size_and_position(Panel *panel);
void cleanup_panel();
void resize_panel(void *obj);
}
-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);
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
void get_root_pixmap();
// detect monitors and desktops
-void get_monitors_and_desktops();
+void get_monitors();
+void get_desktops();
#endif
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.
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;
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);
- }
- 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;
- }
+ 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];
- // 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;
-
- 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;
- }
+ 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;
+ }
+
+ // '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;
}
}
+
+ // '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;
+ }
}
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);
- }
}
}