Skip to content

Commit

Permalink
Fix title bar buttons on Windows
Browse files Browse the repository at this point in the history
This fixes the broken mouse event handling by not consuming events
supposed to go to the title bar, making it possible to move/resize/close
the window.
  • Loading branch information
adamhalim committed Sep 10, 2024
1 parent 2f8fe06 commit f82a074
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions vncviewer/Viewport.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,9 @@ int Viewport::handleSystemPointerEvent(void *event, void *data)
mouseButtonMask = 0;
self->handlePointerEvent(lastPointerPos, 0);
}
#ifdef WIN32
mouseHasLeft = true;
#endif
return 0;
}

Expand All @@ -1180,8 +1183,16 @@ int Viewport::handleSystemPointerEvent(void *event, void *data)

mouse_x = GET_X_LPARAM(msg->lParam) - x();
mouse_y = GET_Y_LPARAM(msg->lParam) - y();
if ((mouse_x < 0 || mouse_x > w() || mouse_y < 0 || mouse_y > h())
&& !(mouseButtonMask & 0x187))

bool outOfBounds = (mouse_x < 0 || mouse_x > w() ||
mouse_y < 0 || mouse_y > h());

// Leave events going to title bar
if (outOfBounds && mouseHasLeft)
return 0;

// Consume mouse events when dragging button outside window
if (outOfBounds && !(mouseButtonMask & 0x187))
return 1;

if (self->altGrArmed)
Expand Down

0 comments on commit f82a074

Please sign in to comment.