From e68d58b454f32a95423048a288a543f4d6c29d01 Mon Sep 17 00:00:00 2001 From: Michael Cardell Widerkrantz Date: Mon, 5 Mar 2012 11:39:37 +0100 Subject: Only get the pointer position if we're going to use it when mapping a new window. If we don't have the pointer position, use the window's coordinates to find the physical screen. Should have been used anyway. --- mcwm.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/mcwm.c b/mcwm.c index f15a4ff..814083f 100644 --- a/mcwm.c +++ b/mcwm.c @@ -978,8 +978,6 @@ void fitonscreen(struct client *client) */ void newwin(xcb_window_t win) { - int16_t pointx; - int16_t pointy; struct client *client; if (NULL != findclient(win)) @@ -993,14 +991,6 @@ void newwin(xcb_window_t win) return; } - /* Get pointer position so we can move the window to the cursor. */ - if (!getpointer(screen->root, &pointx, &pointy)) - { - PDEBUG("Failed to get pointer coords!\n"); - pointx = 0; - pointy = 0; - } - /* * Set up stuff, like borders, add the window to the client list, * et cetera. @@ -1017,12 +1007,23 @@ void newwin(xcb_window_t win) /* * If the client doesn't say the user specified the coordinates - * for the window we store it where our pointer is instead. + * for the window we map it where our pointer is instead. */ if (!client->usercoord) { + int16_t pointx; + int16_t pointy; PDEBUG("Coordinates not set by user. Using pointer: %d,%d.\n", pointx, pointy); + + /* Get pointer position so we can move the window to the cursor. */ + if (!getpointer(screen->root, &pointx, &pointy)) + { + PDEBUG("Failed to get pointer coords!\n"); + pointx = 0; + pointy = 0; + } + client->x = pointx; client->y = pointy; @@ -1036,7 +1037,7 @@ void newwin(xcb_window_t win) /* Find the physical output this window will be on if RANDR is active. */ if (-1 != randrbase) { - client->monitor = findmonbycoord(pointx, pointy); + client->monitor = findmonbycoord(client->x, client->y); if (NULL == client->monitor) { /* -- cgit v1.2.3