aboutsummaryrefslogtreecommitdiff
path: root/src/place.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/place.c')
-rw-r--r--src/place.c101
1 files changed, 48 insertions, 53 deletions
diff --git a/src/place.c b/src/place.c
index f70ce73..cad5d96 100644
--- a/src/place.c
+++ b/src/place.c
@@ -8,6 +8,7 @@
#include "client.h"
#include "screen.h"
#include "border.h"
+#include "move.h"
#include "tray.h"
#include "main.h"
@@ -26,9 +27,12 @@ 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. */
-static int *cascadeOffsets = NULL;
static void GetScreenBounds(const ScreenType *sp, BoundingBox *box);
static void UpdateTrayBounds(BoundingBox *box, unsigned int layer);
@@ -43,17 +47,6 @@ void InitializePlacement() {
/****************************************************************************
****************************************************************************/
void StartupPlacement() {
-
- int count;
- int x;
-
- count = desktopCount * GetScreenCount();
- cascadeOffsets = Allocate(count * sizeof(int));
-
- for(x = 0; x < count; x++) {
- cascadeOffsets[x] = borderWidth + titleHeight;
- }
-
}
/****************************************************************************
@@ -62,8 +55,6 @@ void ShutdownPlacement() {
Strut *sp;
- Release(cascadeOffsets);
-
while(struts) {
sp = struts->next;
Release(struts);
@@ -374,10 +365,11 @@ void UpdateStrutBounds(BoundingBox *box) {
void PlaceClient(ClientNode *np, int alreadyMapped) {
BoundingBox box;
- int north, south, east, west;
const ScreenType *sp;
- int cascadeIndex;
- int overflow;
+ int height, overflow, width, winx, winy, x, y;
+ int north, south, east, west;
+ unsigned int mask;
+ Window rootReturn, childReturn;
Assert(np);
@@ -403,47 +395,50 @@ void PlaceClient(ClientNode *np, int alreadyMapped) {
UpdateTrayBounds(&box, np->state.layer);
UpdateStrutBounds(&box);
- cascadeIndex = sp->index * desktopCount + currentDesktop;
-
- /* Set the cascaded location. */
- np->x = box.x + west + cascadeOffsets[cascadeIndex];
- np->y = box.y + north + cascadeOffsets[cascadeIndex];
- cascadeOffsets[cascadeIndex] += borderWidth + titleHeight;
-
- /* Check for cascade overflow. */
- overflow = 0;
- if(np->x + np->width - box.x > box.width) {
- overflow = 1;
- } else if(np->y + np->height - box.y > box.height) {
- overflow = 1;
+ /* Check cursor location. */
+ JXQueryPointer(display, rootWindow, &rootReturn, &childReturn,
+ &x, &y, &winx, &winy, &mask);
+
+ if(prevx > -1
+ && prevy > -1
+ && (abs(x - prevx) <= borderWidth
+ || abs(y - prevy) <= borderWidth)) {
+ offset += borderWidth + titleHeight;
+ } else {
+ offset = 0;
+ prevx = x;
+ prevy = y;
}
- if(overflow) {
-
- cascadeOffsets[cascadeIndex] = borderWidth + titleHeight;
- np->x = box.x + west + cascadeOffsets[cascadeIndex];
- np->y = box.y + north + cascadeOffsets[cascadeIndex];
-
- /* Check for client overflow. */
- overflow = 0;
- if(np->x + np->width - box.x > box.width) {
- overflow = 1;
- } else if(np->y + np->height - box.y > box.height) {
- overflow = 1;
- }
-
- /* Update cascade position or position client. */
- if(overflow) {
- np->x = box.x + west;
- np->y = box.y + north;
- } else {
- cascadeOffsets[cascadeIndex] += borderWidth + titleHeight;
- }
-
+ /* Show window at cursor. */
+ width = np->width;
+ height = np->height;
+ if(np->state.border & BORDER_OUTLINE) {
+ x += borderWidth;
+ y += borderWidth;
+ width += borderWidth * 2;
+ height += borderWidth * 2;
}
-
+ if(np->state.border & BORDER_TITLE) {
+ y += titleHeight;
+ height += titleHeight;
+ }
+ x -= width / 2;
+ y -= height / 2;
+ np->x = x + offset;
+ np->y = y + offset;
+
+ /* 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);
}
+
if(np->state.status & STAT_FULLSCREEN) {
JXMoveWindow(display, np->parent, sp->x, sp->y);
} else {