]> Dogcows Code - chaz/tint2/commitdiff
issue 135 and xrandr management (more to come)
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 27 Sep 2009 16:57:19 +0000 (16:57 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sun, 27 Sep 2009 16:57:19 +0000 (16:57 +0000)
src/config.c
src/panel.c
src/panel.h
src/server.c
src/server.h
src/tint.c
src/util/area.c

index b6476d94c3b552a1339444292ba3b94f9d9dfcfa..2bfb34a28aee8c21cf5ee05f26472e12b98f2b92 100644 (file)
@@ -79,7 +79,8 @@ void init_config()
        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 @@ void init_config()
        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 @@ int parse_line (const char *line)
 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;
index adc6520199cf7f306017d97b497fa52dc77aee4f..2e4708581429c4f5401ea438e212462c88c60b86 100644 (file)
@@ -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 @@ void init_panel()
                        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;
@@ -177,6 +125,64 @@ void init_panel()
 }
 
 
+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;
index 5746a5574806706df596f378f9f90e9af7a67eba..b3c8fded14817dad4217637fdd73c1f67b8da6c3 100644 (file)
@@ -38,7 +38,7 @@ extern int mouse_tilt_right;
 //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);
 
index 85ecd479b199b6cf7dd17a7328b9406a7d1ce1c4..9b09010506e2bc53323303ecb0df5eaae8d20a44 100644 (file)
@@ -219,15 +219,13 @@ int compareMonitor(const void *monitor1, const void *monitor2)
 }
 
 
-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 @@ next:
                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
index fdd8826608dba351737103e26b46cc932e7ef428..aba113255c11c24b818124b036f4d65e7500c814 100644 (file)
@@ -115,7 +115,8 @@ void server_init_atoms ();
 void get_root_pixmap();
 
 // detect monitors and desktops
-void get_monitors_and_desktops();
+void get_monitors();
+void get_desktops();
 
 
 #endif
index 35980bffbcb07ce4273d8024b41bcd7494d2d38e..8705d949961d25f383fab5bf2de4d8ecaea0abb4 100644 (file)
@@ -270,6 +270,7 @@ void event_button_press (XEvent *e)
 
        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 @@ void event_button_release (XEvent *e)
        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,43 +615,60 @@ void event_expose (XEvent *e)
 
 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;
+       }
 }
 
 
index 8c40aa667a339ab8f7556566e9608b53f24fe5cb..827e118a40e7fe41f9cd846e7816bb18487ba560 100644 (file)
@@ -72,13 +72,16 @@ void size (Area *a)
 
        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);
-               }
        }
 }
 
This page took 0.042011 seconds and 4 git commands to generate.