Skip to content

Commit 3198ed7

Browse files
committed
fix transition between screens of different sizes on macos.
1 parent 66478b5 commit 3198ed7

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/mouse.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,27 @@ void switch_to_another_pc(
152152
}
153153

154154
void switch_virtual_desktop_macos(device_t *state, int direction) {
155-
/* Fix for MACOS: Send relative mouse movement here, one or two pixels in the
156-
direction of movement, BEFORE absolute report sets X to 0 */
155+
/*
156+
* Fix for MACOS: Before sending new absolute report setting X to 0:
157+
* 1. Move the cursor to the edge of the screen directly in the middle to handle screens
158+
* of different heights
159+
* 2. Send relative mouse movement one or two pixels in the direction of movement to get
160+
* the cursor onto the next screen
161+
*/
162+
mouse_report_t edge_position = {
163+
.x = (direction == LEFT) ? MIN_SCREEN_COORD : MAX_SCREEN_COORD,
164+
.y = MAX_SCREEN_COORD / 2,
165+
.mode = ABSOLUTE,
166+
.buttons = state->mouse_buttons,
167+
};
168+
157169
uint16_t move = (direction == LEFT) ? -MACOS_SWITCH_MOVE_X : MACOS_SWITCH_MOVE_X;
158-
mouse_report_t move_relative_one = {.x = move, .mode = RELATIVE};
170+
mouse_report_t move_relative_one = {
171+
.x = move,
172+
.mode = RELATIVE,
173+
};
174+
175+
output_mouse_report(&edge_position, state);
159176

160177
/* Once doesn't seem reliable enough, do it a few times */
161178
for (int i = 0; i < MACOS_SWITCH_MOVE_COUNT; i++)

0 commit comments

Comments
 (0)