summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-14 21:14:03 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-14 21:14:03 +0200
commit51a83b486323d7876b31b9cbf65762364fd1fdb8 (patch)
tree5ad5a2813a74640a329de15dcf4147946dd897f6 /src/ui/window.c
parent5fa4bf565abd8a34f6175d6665148cd1ea04a0a1 (diff)
Windows: Improved custom frame behavior; default to disabled
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 998f5681..c5eb7e03 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -841,12 +841,12 @@ static SDL_HitTestResult hitTest_Window_(SDL_Window *win, const SDL_Point *pos,
841 if (isTop) { 841 if (isTop) {
842 return pos->x < captionHeight ? SDL_HITTEST_RESIZE_TOPLEFT 842 return pos->x < captionHeight ? SDL_HITTEST_RESIZE_TOPLEFT
843 : pos->x > w - captionHeight ? SDL_HITTEST_RESIZE_TOPRIGHT 843 : pos->x > w - captionHeight ? SDL_HITTEST_RESIZE_TOPRIGHT
844 : SDL_HITTEST_RESIZE_TOP; 844 : (d->place.lastHit = SDL_HITTEST_RESIZE_TOP);
845 } 845 }
846 if (isBottom) { 846 if (isBottom) {
847 return pos->x < captionHeight ? SDL_HITTEST_RESIZE_BOTTOMLEFT 847 return pos->x < captionHeight ? SDL_HITTEST_RESIZE_BOTTOMLEFT
848 : pos->x > w - captionHeight ? SDL_HITTEST_RESIZE_BOTTOMRIGHT 848 : pos->x > w - captionHeight ? SDL_HITTEST_RESIZE_BOTTOMRIGHT
849 : SDL_HITTEST_RESIZE_BOTTOM; 849 : (d->place.lastHit = SDL_HITTEST_RESIZE_BOTTOM);
850 } 850 }
851 } 851 }
852 if (pos->x < rightEdge && pos->y < captionHeight) { 852 if (pos->x < rightEdge && pos->y < captionHeight) {
@@ -1058,7 +1058,7 @@ static iBool unsnap_Window_(iWindow *d, const iInt2 *newPos) {
1058 if (snap_Window(d) == yMaximized_WindowSnap && newPos) { 1058 if (snap_Window(d) == yMaximized_WindowSnap && newPos) {
1059 d->place.normalRect.pos = *newPos; 1059 d->place.normalRect.pos = *newPos;
1060 } 1060 }
1061 printf("unsnap\n"); fflush(stdout); 1061 //printf("unsnap\n"); fflush(stdout);
1062 setSnap_Window(d, none_WindowSnap); 1062 setSnap_Window(d, none_WindowSnap);
1063 return iTrue; 1063 return iTrue;
1064 } 1064 }
@@ -1120,7 +1120,10 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
1120 return iTrue; 1120 return iTrue;
1121 } 1121 }
1122 if (iAbs(mouse.y - usable.y) < 2) { 1122 if (iAbs(mouse.y - usable.y) < 2) {
1123 setSnap_Window(d, redo_WindowSnap | maximized_WindowSnap); 1123 setSnap_Window(d,
1124 redo_WindowSnap | (d->place.lastHit == SDL_HITTEST_RESIZE_TOP
1125 ? yMaximized_WindowSnap
1126 : maximized_WindowSnap));
1124 return iTrue; 1127 return iTrue;
1125 } 1128 }
1126 } 1129 }
@@ -1448,7 +1451,8 @@ void setSnap_Window(iWindow *d, int snapMode) {
1448 d->place.snap = snapMode & ~redo_WindowSnap; 1451 d->place.snap = snapMode & ~redo_WindowSnap;
1449 switch (snapMode & mask_WindowSnap) { 1452 switch (snapMode & mask_WindowSnap) {
1450 case none_WindowSnap: 1453 case none_WindowSnap:
1451 newRect = d->place.normalRect; 1454 newRect = intersect_Rect(d->place.normalRect,
1455 init_Rect(usable.x, usable.y, usable.w, usable.h));
1452 break; 1456 break;
1453 case left_WindowSnap: 1457 case left_WindowSnap:
1454 newRect = init_Rect(usable.x, usable.y, usable.w / 2, usable.h); 1458 newRect = init_Rect(usable.x, usable.y, usable.w / 2, usable.h);