Skip to content

Commit

Permalink
Better guard move/sizes and make sure they are properly terminated.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Jun 18, 2024
1 parent dff9157 commit 79c10bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/movesize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ bool YFrameWindow::canSize(bool horiz, bool vert) {

void YFrameWindow::netMoveSize(int x, int y, int direction)
{
if (movingWindow || sizingWindow) {
if (hasMoveSize()) {
if (direction == _NET_WM_MOVERESIZE_CANCEL)
endMoveSize();
return;
Expand Down Expand Up @@ -866,6 +866,9 @@ void YFrameWindow::netMoveSize(int x, int y, int direction)
void YFrameWindow::startMoveSize(bool doMove, bool byMouse,
int sideX, int sideY,
int mouseXroot, int mouseYroot) {
if (isMinimized() || isHidden() || isFullscreen() || hasMoveSize())
return;

Cursor grabPointer = None;

grabX = sideX;
Expand Down Expand Up @@ -1060,7 +1063,7 @@ void YFrameWindow::handleButton(const XButtonEvent &button) {
wmRaise();
}
} else if (button.type == ButtonRelease) {
if (movingWindow || sizingWindow) {
if (hasMoveSize()) {
endMoveSize();
return ;
}
Expand Down
7 changes: 7 additions & 0 deletions src/wmframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,8 @@ void YFrameWindow::wmCloseClient(YFrameClient* client, bool* confirm) {
void YFrameWindow::wmClose() {
if (!canClose())
return ;
if (hasMoveSize())
endMoveSize();

manager->grabServer();
bool confirm = false;
Expand Down Expand Up @@ -1962,6 +1964,8 @@ void YFrameWindow::wmConfirmKill(const char* message) {
void YFrameWindow::wmKill() {
if (!canClose())
return ;
if (hasMoveSize())
endMoveSize();
#ifdef DEBUG
if (debug)
msg("No WM_DELETE_WINDOW protocol");
Expand Down Expand Up @@ -3525,6 +3529,9 @@ void YFrameWindow::setState(int mask, int state) {
fWinState, fWinState ^ flip, gain, lose));
fWinState ^= flip;

if (gain & (WinStateUnmapped | WinStateFullscreen | WinStateMaximizedBoth))
if (hasMoveSize())
endMoveSize();
if (flip & WinStateMinimized) {
MSG(("WinStateMinimized: %d", isMinimized()));
if (gain & WinStateMinimized)
Expand Down
1 change: 1 addition & 0 deletions src/wmframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class YFrameWindow:
void startMoveSize(bool doMove, bool byMouse,
int sideX, int sideY,
int mouseXroot, int mouseYroot);
bool hasMoveSize() const { return movingWindow || sizingWindow; }
void endMoveSize();
void moveWindow(int newX, int newY);
void manualPlace();
Expand Down

0 comments on commit 79c10bb

Please sign in to comment.