Merge pull request #179 from eltariel/macos-screen-switch
Tweak macos screen switch helper
This commit is contained in:
commit
cbb98e4a88
23
src/mouse.c
23
src/mouse.c
|
@ -17,6 +17,9 @@
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
#define MACOS_SWITCH_MOVE_X 10
|
||||||
|
#define MACOS_SWITCH_MOVE_COUNT 5
|
||||||
|
|
||||||
/* Move mouse coordinate 'position' by 'offset', but don't fall off the screen */
|
/* Move mouse coordinate 'position' by 'offset', but don't fall off the screen */
|
||||||
int32_t move_and_keep_on_screen(int position, int offset) {
|
int32_t move_and_keep_on_screen(int position, int offset) {
|
||||||
/* Lowest we can go is 0 */
|
/* Lowest we can go is 0 */
|
||||||
|
@ -122,7 +125,7 @@ int16_t scale_y_coordinate(int screen_from, int screen_to, device_t *state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void switch_screen(
|
void switch_screen(
|
||||||
device_t *state, output_t *output, int new_x, int output_from, int output_to, int direction) {
|
device_t *state, output_t *output, int output_to, int direction) {
|
||||||
uint8_t *mouse_park_pos = &state->config.output[state->active_output].mouse_park_pos;
|
uint8_t *mouse_park_pos = &state->config.output[state->active_output].mouse_park_pos;
|
||||||
|
|
||||||
int16_t mouse_y = (*mouse_park_pos == 0) ? MIN_SCREEN_COORD : /* Top */
|
int16_t mouse_y = (*mouse_park_pos == 0) ? MIN_SCREEN_COORD : /* Top */
|
||||||
|
@ -137,17 +140,21 @@ void switch_screen(
|
||||||
state->pointer_y = scale_y_coordinate(output->number, 1 - output->number, state);
|
state->pointer_y = scale_y_coordinate(output->number, 1 - output->number, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void switch_desktop(device_t *state, output_t *output, int new_index, int direction) {
|
void switch_desktop_macos(device_t *state, int direction) {
|
||||||
/* Fix for MACOS: Send relative mouse movement here, one or two pixels in the
|
/* Fix for MACOS: Send relative mouse movement here, one or two pixels in the
|
||||||
direction of movement, BEFORE absolute report sets X to 0 */
|
direction of movement, BEFORE absolute report sets X to 0 */
|
||||||
mouse_report_t move_relative_one
|
uint16_t move = (direction == LEFT) ? -MACOS_SWITCH_MOVE_X : MACOS_SWITCH_MOVE_X;
|
||||||
= {.x = (direction == LEFT) ? -5 : 5, .mode = RELATIVE};
|
mouse_report_t move_relative_one = {.x = move, .mode = RELATIVE};
|
||||||
|
|
||||||
|
/* Once doesn't seem reliable enough, do it a few times */
|
||||||
|
for (int i = 0; i < MACOS_SWITCH_MOVE_COUNT; i++)
|
||||||
|
output_mouse_report(&move_relative_one, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void switch_desktop(device_t *state, output_t *output, int new_index, int direction) {
|
||||||
switch (output->os) {
|
switch (output->os) {
|
||||||
case MACOS:
|
case MACOS:
|
||||||
/* Once doesn't seem reliable enough, do it a few times */
|
switch_desktop_macos(state, direction);
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
output_mouse_report(&move_relative_one, state);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WINDOWS:
|
case WINDOWS:
|
||||||
|
@ -199,7 +206,7 @@ void check_screen_switch(const mouse_values_t *values, device_t *state) {
|
||||||
if (state->mouse_buttons)
|
if (state->mouse_buttons)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch_screen(state, output, new_x, state->active_output, 1 - state->active_output, direction);
|
switch_screen(state, output, 1 - state->active_output, direction);
|
||||||
}
|
}
|
||||||
/* If here, this output has multiple desktops and we are not on the main one */
|
/* If here, this output has multiple desktops and we are not on the main one */
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue