summaryrefslogtreecommitdiff
path: root/mcwm.c
diff options
context:
space:
mode:
authorMichael Cardell Widerkrantz <mc@hack.org>2011-08-12 11:42:21 +0200
committerMichael Cardell Widerkrantz <mc@hack.org>2011-08-12 11:42:21 +0200
commitcc447b8c1ab31fc84b90589172993ea56a45be77 (patch)
treefef993a49763631ca573e1ac5f4149a4f5c04333 /mcwm.c
parentf058f5bcde855f1a8315fc562b568381e169f912 (diff)
downloadmcwm-cc447b8c1ab31fc84b90589172993ea56a45be77.zip
It was still possible to map a window on coordinates outside physical
screens. Now hopefully fixed, if not perfectly: If a window isn't bound to any physical screen it will be bound in newwin() to the first screen mcwm knows about. In fitonscreen() I forgot to check for the case where window coordinates are larger than the screen's.
Diffstat (limited to 'mcwm.c')
-rw-r--r--mcwm.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/mcwm.c b/mcwm.c
index 675c002..6b98564 100644
--- a/mcwm.c
+++ b/mcwm.c
@@ -838,9 +838,14 @@ void fitonscreen(struct client *client)
client->maxed = false;
setborders(client, BORDERWIDTH);
}
-
+
if (NULL == client->monitor)
{
+ /*
+ * This window isn't attached to any physical monitor. This
+ * probably means there is no RANDR, so we use the root window
+ * size.
+ */
mon_x = 0;
mon_y = 0;
mon_width = screen->width_in_pixels;
@@ -854,7 +859,22 @@ void fitonscreen(struct client *client)
mon_height = client->monitor->height;
}
+ PDEBUG("Is window outside monitor?\n");
+ PDEBUG("x: %d between %d and %d?\n", client->x, mon_x, mon_x + mon_width);
+ PDEBUG("y: %d between %d and %d?\n", client->y, mon_y, mon_y + mon_height);
+
/* Is it outside the physical monitor? */
+ if (client->x > mon_x + mon_width)
+ {
+ client->x = mon_x + mon_width - client->width;
+ willmove = true;
+ }
+ if (client->y > mon_y + mon_height)
+ {
+ client->y = mon_y + mon_height - client->height;
+ willmove = true;
+ }
+
if (client->x < mon_x)
{
client->x = mon_x;
@@ -865,7 +885,7 @@ void fitonscreen(struct client *client)
client->y = mon_y;
willmove = true;
}
-
+
/* Is it smaller than it wants to be? */
if (0 != client->min_height && client->height < client->min_height)
{
@@ -987,6 +1007,17 @@ void newwin(xcb_window_t win)
if (-1 != randrbase)
{
client->monitor = findmonbycoord(pointx, pointy);
+ if (NULL == client->monitor)
+ {
+ /*
+ * Window coordinates are outside all physical monitors.
+ * Choose the first screen.
+ */
+ if (NULL != monlist->data)
+ {
+ client->monitor = monlist->data;
+ }
+ }
}
fitonscreen(client);