From 1b73a296464546f7dc58f2a753d13042a94337b0 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Tue, 23 Apr 2013 22:29:58 +0200 Subject: [PATCH] Constrain the moveresize popup to the monitor which has the client --- openbox/moveresize.c | 4 ++++ openbox/popup.c | 26 ++++++++++++++++---------- openbox/popup.h | 3 +++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 2d0dc3ac..333a1bea 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -83,6 +83,8 @@ static void client_dest(ObClient *client, gpointer data) { if (moveresize_client == client) moveresize_end(TRUE); + if (popup && client == popup->client) + popup->client = NULL; } void moveresize_startup(gboolean reconfig) @@ -167,6 +169,7 @@ static void popup_coords(ObClient *c, const gchar *format, gint a, gint b) popup_position(popup, gravity, x, y); } + popup->client = c; popup_show(popup, text); g_free(text); } @@ -312,6 +315,7 @@ void moveresize_end(gboolean cancel) ungrab_pointer(); popup_hide(popup); + popup->client = NULL; if (!moving) { #ifdef SYNC diff --git a/openbox/popup.c b/openbox/popup.c index 2a83d7b8..5ecf2fa5 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -250,16 +250,22 @@ void popup_delay_show(ObPopup *self, gulong msec, gchar *text) break; } - /* Find the monitor which contains the biggest part of the popup. - * If the popup is completely off screen, limit it to the intersection - * of all monitors and then try again. If it's still off screen, put it - * on monitor 0. */ - RECT_SET(mon, x, y, w, h); - m = screen_find_monitor(&mon); + /* If the popup belongs to a client (eg, the moveresize popup), get + * the monitor for that client, otherwise do other stuff */ + if (self->client) { + m = client_monitor(self->client); + } else { + /* Find the monitor which contains the biggest part of the popup. + * If the popup is completely off screen, limit it to the intersection + * of all monitors and then try again. If it's still off screen, put it + * on monitor 0. */ + RECT_SET(mon, x, y, w, h); + m = screen_find_monitor(&mon); + } area = screen_physical_area_monitor(m); - x=MAX(MIN(x, area->x+area->width-w),area->x); - y=MAX(MIN(y, area->y+area->height-h),area->y); + x = MAX(MIN(x, area->x+area->width-w), area->x); + y = MAX(MIN(y, area->y+area->height-h), area->y); if (m == screen_num_monitors) { RECT_SET(mon, x, y, w, h); @@ -268,8 +274,8 @@ void popup_delay_show(ObPopup *self, gulong msec, gchar *text) m = 0; area = screen_physical_area_monitor(m); - x=MAX(MIN(x, area->x+area->width-w),area->x); - y=MAX(MIN(y, area->y+area->height-h),area->y); + x = MAX(MIN(x, area->x+area->width-w), area->x); + y = MAX(MIN(y, area->y+area->height-h), area->y); } /* set the windows/appearances up */ diff --git a/openbox/popup.h b/openbox/popup.h index 6de9d184..6d6ba6ab 100644 --- a/openbox/popup.h +++ b/openbox/popup.h @@ -19,6 +19,7 @@ #ifndef __popup_h #define __popup_h +#include "client.h" #include "window.h" #include "obrender/render.h" #include @@ -57,6 +58,8 @@ struct _ObPopup void (*draw_icon)(gint x, gint y, gint w, gint h, gpointer data); gpointer draw_icon_data; + + ObClient *client; }; struct _ObIconPopup