aboutsummaryrefslogtreecommitdiff
path: root/src/move.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/move.c')
-rw-r--r--src/move.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/move.c b/src/move.c
index 882ac90..7370f06 100644
--- a/src/move.c
+++ b/src/move.c
@@ -530,6 +530,81 @@ void DoSnapBorder(ClientNode *np, int north, int west) {
/****************************************************************************
****************************************************************************/
+void ReturnToBorder(ClientNode *np, int north, int west) {
+
+ const ScreenType *screen;
+ const TrayType *tray;
+ int layer;
+ RectangleType bottom = { 0 };
+ RectangleType client, other;
+ RectangleType left = { 0 };
+ RectangleType right = { 0 };
+ RectangleType top = { 0 };
+
+ GetClientRectangle(np, &client);
+ screen = GetCurrentScreen(client.left, client.top);
+
+ /* Check screen boundaries. */
+ if(client.right > (screen->width - screen->x))
+ np->x = screen->x + screen->width - west - np->width;
+ if(client.left < screen->x)
+ np->x = screen->x + west;
+ if(client.bottom > (screen->height - screen->y)) {
+ np->y = screen->y + screen->height - west;
+ if(!(np->state.status & STAT_SHADED))
+ np->y -= np->height;
+ }
+ if(client.top < screen->y)
+ np->y = north + screen->y;
+
+ GetClientRectangle(np, &client);
+ other.valid = 1;
+
+ /* Work from the bottom of the window stack to the top. */
+ for(layer = 0; layer < LAYER_COUNT; layer++) {
+
+ /* Check tray windows. */
+ for(tray = GetTrays(); tray; tray = tray->next) {
+
+ if(tray->hidden)
+ continue;
+
+ other.left = tray->x;
+ other.right = tray->x + tray->width;
+ other.top = tray->y;
+ other.bottom = tray->y + tray->height;
+
+ left.valid = CheckLeftValid(&client, &other, &left);
+ right.valid = CheckRightValid(&client, &other, &right);
+ top.valid = CheckTopValid(&client, &other, &top);
+ bottom.valid = CheckBottomValid(&client, &other, &bottom);
+
+ if(other.top == screen->y
+ && client.top < other.bottom)
+ top = other;
+ if(other.bottom == screen->height
+ && client.bottom > other.top)
+ bottom = other;
+ }
+
+ }
+
+ if(right.valid)
+ np->x = right.left - np->width - west;
+ if(left.valid)
+ np->x = left.right + west;
+ if(bottom.valid) {
+ np->y = bottom.top - west;
+ if(!(np->state.status & STAT_SHADED))
+ np->y -= np->height;
+ }
+ if(top.valid)
+ np->y = top.bottom + north;
+
+}
+
+/****************************************************************************
+ ****************************************************************************/
int ShouldSnap(const ClientNode *np) {
if(np->state.status & STAT_HIDDEN) {
return 0;