Skip to content

Commit

Permalink
Make pointer id independent of mouse bindings
Browse files Browse the repository at this point in the history
The tool type (MOUSE or FINGER) to use depended on whether a secondary
click was possible via mouse bindings.

As a first step, always use a mouse tool type to break this dependency.
Note that this change might cause regressions in some (unknown) cases
(refs f70359f), but hopefully not.

Further commits will restore a finger tool type in some specific use
cases, but independent of secondary clicks.

Refs #5055 <#5055>
Refs #5067 <#5067>
  • Loading branch information
rom1v committed Jul 8, 2024
1 parent 912df31 commit 90a1a62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
20 changes: 3 additions & 17 deletions app/src/input_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ is_shortcut_key(struct sc_input_manager *im, SDL_Keycode keycode) {
|| (im->sdl_shortcut_mods & KMOD_RGUI && keycode == SDLK_RGUI);
}

static inline bool
mouse_bindings_has_secondary_click(const struct sc_mouse_bindings *mb) {
return mb->right_click == SC_MOUSE_BINDING_CLICK
|| mb->middle_click == SC_MOUSE_BINDING_CLICK
|| mb->click4 == SC_MOUSE_BINDING_CLICK
|| mb->click5 == SC_MOUSE_BINDING_CLICK;
}

void
sc_input_manager_init(struct sc_input_manager *im,
const struct sc_input_manager_params *params) {
Expand All @@ -76,8 +68,6 @@ sc_input_manager_init(struct sc_input_manager *im,
im->mp = params->mp;

im->mouse_bindings = params->mouse_bindings;
im->has_secondary_click =
mouse_bindings_has_secondary_click(&im->mouse_bindings);
im->legacy_paste = params->legacy_paste;
im->clipboard_autosync = params->clipboard_autosync;

Expand Down Expand Up @@ -375,9 +365,7 @@ simulate_virtual_finger(struct sc_input_manager *im,
msg.inject_touch_event.action = action;
msg.inject_touch_event.position.screen_size = im->screen->frame_size;
msg.inject_touch_event.position.point = point;
msg.inject_touch_event.pointer_id =
im->has_secondary_click ? SC_POINTER_ID_VIRTUAL_MOUSE
: SC_POINTER_ID_VIRTUAL_FINGER;
msg.inject_touch_event.pointer_id = SC_POINTER_ID_VIRTUAL_MOUSE;
msg.inject_touch_event.pressure = up ? 0.0f : 1.0f;
msg.inject_touch_event.action_button = 0;
msg.inject_touch_event.buttons = 0;
Expand Down Expand Up @@ -662,8 +650,7 @@ sc_input_manager_process_mouse_motion(struct sc_input_manager *im,

struct sc_mouse_motion_event evt = {
.position = sc_input_manager_get_position(im, event->x, event->y),
.pointer_id = im->has_secondary_click ? SC_POINTER_ID_MOUSE
: SC_POINTER_ID_GENERIC_FINGER,
.pointer_id = SC_POINTER_ID_MOUSE,
.xrel = event->xrel,
.yrel = event->yrel,
.buttons_state =
Expand Down Expand Up @@ -817,8 +804,7 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
.position = sc_input_manager_get_position(im, event->x, event->y),
.action = sc_action_from_sdl_mousebutton_type(event->type),
.button = sc_mouse_button_from_sdl(event->button),
.pointer_id = im->has_secondary_click ? SC_POINTER_ID_MOUSE
: SC_POINTER_ID_GENERIC_FINGER,
.pointer_id = SC_POINTER_ID_MOUSE,
.buttons_state = sc_mouse_buttons_state_from_sdl(sdl_buttons_state,
&im->mouse_bindings),
};
Expand Down
1 change: 0 additions & 1 deletion app/src/input_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ struct sc_input_manager {
struct sc_mouse_processor *mp;

struct sc_mouse_bindings mouse_bindings;
bool has_secondary_click;
bool legacy_paste;
bool clipboard_autosync;

Expand Down

0 comments on commit 90a1a62

Please sign in to comment.