aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/place.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/place.c b/src/place.c
index cad5d96..188945b 100644
--- a/src/place.c
+++ b/src/place.c
@@ -10,6 +10,7 @@
#include "border.h"
#include "move.h"
#include "tray.h"
+#include "timing.h"
#include "main.h"
typedef struct BoundingBox {
@@ -27,10 +28,6 @@ typedef struct Strut {
static Strut *struts = NULL;
static Strut *strutsTail = NULL;
-static int prevx = -1;
-static int prevy = -1;
-static int offset = 0;
-
/* desktopCount x screenCount */
/* Note that we assume x and y are 0 based for all screens here. */
@@ -364,10 +361,15 @@ void UpdateStrutBounds(BoundingBox *box) {
****************************************************************************/
void PlaceClient(ClientNode *np, int alreadyMapped) {
+ static int prevx = -1;
+ static int prevy = -1;
+ static TimeType last = ZERO_TIME;
+
BoundingBox box;
const ScreenType *sp;
- int height, overflow, width, winx, winy, x, y;
+ int height, offset, overflow, width, winx, winy, x, y;
int north, south, east, west;
+ TimeType now;
unsigned int mask;
Window rootReturn, childReturn;
@@ -399,16 +401,19 @@ void PlaceClient(ClientNode *np, int alreadyMapped) {
JXQueryPointer(display, rootWindow, &rootReturn, &childReturn,
&x, &y, &winx, &winy, &mask);
- if(prevx > -1
- && prevy > -1
+ /* Set offset if needed. */
+ if(prevx > -1 && prevy > -1
&& (abs(x - prevx) <= borderWidth
- || abs(y - prevy) <= borderWidth)) {
- offset += borderWidth + titleHeight;
- } else {
+ || abs(y - prevy) <= borderWidth))
+ offset = borderWidth + titleHeight;
+ else
offset = 0;
- prevx = x;
- prevy = y;
- }
+
+ /* Unset offset if too late. */
+ GetCurrentTime(&now);
+ if (GetTimeDifference(&now, &last) > 500)
+ offset = 0;
+ last = now;
/* Show window at cursor. */
width = np->width;
@@ -425,17 +430,21 @@ void PlaceClient(ClientNode *np, int alreadyMapped) {
}
x -= width / 2;
y -= height / 2;
- np->x = x + offset;
- np->y = y + offset;
+ np->x = x;
+ np->y = y;
/* Correct for overflow. */
- /*
- if(np->x + np->width - box.x > box.width)
- np->x = box.width - (np->width - box.x);
- if(np->y + np->height - box.y > box.height)
- np->y = box.height - (np->height - box.y);
- */
ReturnToBorder(np, north, west);
+
+ np->x += offset;
+ np->y += offset;
+ MoveMouseToClient(np);
+
+ /* Save cursor location. */
+ JXQueryPointer(display, rootWindow, &rootReturn, &childReturn,
+ &x, &y, &winx, &winy, &mask);
+ prevx = x;
+ prevy = y;
}