Constrain the moveresize popup to the monitor which has the client

This commit is contained in:
Mikael Magnusson 2013-04-23 22:29:58 +02:00
parent 8be9cc92b6
commit 1b73a29646
3 changed files with 23 additions and 10 deletions

View file

@ -83,6 +83,8 @@ static void client_dest(ObClient *client, gpointer data)
{ {
if (moveresize_client == client) if (moveresize_client == client)
moveresize_end(TRUE); moveresize_end(TRUE);
if (popup && client == popup->client)
popup->client = NULL;
} }
void moveresize_startup(gboolean reconfig) 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_position(popup, gravity, x, y);
} }
popup->client = c;
popup_show(popup, text); popup_show(popup, text);
g_free(text); g_free(text);
} }
@ -312,6 +315,7 @@ void moveresize_end(gboolean cancel)
ungrab_pointer(); ungrab_pointer();
popup_hide(popup); popup_hide(popup);
popup->client = NULL;
if (!moving) { if (!moving) {
#ifdef SYNC #ifdef SYNC

View file

@ -250,16 +250,22 @@ void popup_delay_show(ObPopup *self, gulong msec, gchar *text)
break; break;
} }
/* Find the monitor which contains the biggest part of the popup. /* If the popup belongs to a client (eg, the moveresize popup), get
* If the popup is completely off screen, limit it to the intersection * the monitor for that client, otherwise do other stuff */
* of all monitors and then try again. If it's still off screen, put it if (self->client) {
* on monitor 0. */ m = client_monitor(self->client);
RECT_SET(mon, x, y, w, h); } else {
m = screen_find_monitor(&mon); /* 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); area = screen_physical_area_monitor(m);
x=MAX(MIN(x, area->x+area->width-w),area->x); x = MAX(MIN(x, area->x+area->width-w), area->x);
y=MAX(MIN(y, area->y+area->height-h),area->y); y = MAX(MIN(y, area->y+area->height-h), area->y);
if (m == screen_num_monitors) { if (m == screen_num_monitors) {
RECT_SET(mon, x, y, w, h); RECT_SET(mon, x, y, w, h);
@ -268,8 +274,8 @@ void popup_delay_show(ObPopup *self, gulong msec, gchar *text)
m = 0; m = 0;
area = screen_physical_area_monitor(m); area = screen_physical_area_monitor(m);
x=MAX(MIN(x, area->x+area->width-w),area->x); x = MAX(MIN(x, area->x+area->width-w), area->x);
y=MAX(MIN(y, area->y+area->height-h),area->y); y = MAX(MIN(y, area->y+area->height-h), area->y);
} }
/* set the windows/appearances up */ /* set the windows/appearances up */

View file

@ -19,6 +19,7 @@
#ifndef __popup_h #ifndef __popup_h
#define __popup_h #define __popup_h
#include "client.h"
#include "window.h" #include "window.h"
#include "obrender/render.h" #include "obrender/render.h"
#include <glib.h> #include <glib.h>
@ -57,6 +58,8 @@ struct _ObPopup
void (*draw_icon)(gint x, gint y, gint w, gint h, gpointer data); void (*draw_icon)(gint x, gint y, gint w, gint h, gpointer data);
gpointer draw_icon_data; gpointer draw_icon_data;
ObClient *client;
}; };
struct _ObIconPopup struct _ObIconPopup