mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
osd: refactor to not write server->osd_state outside osd.c
This commit is contained in:
parent
8f8e734405
commit
6fe688b3e4
4 changed files with 47 additions and 33 deletions
31
src/action.c
31
src/action.c
|
|
@ -789,33 +789,6 @@ run_if_action(struct view *view, struct server *server, struct action *action)
|
|||
return !strcmp(branch, "then");
|
||||
}
|
||||
|
||||
static bool
|
||||
shift_is_pressed(struct server *server)
|
||||
{
|
||||
uint32_t modifiers = wlr_keyboard_get_modifiers(
|
||||
&server->seat.keyboard_group->keyboard);
|
||||
return modifiers & WLR_MODIFIER_SHIFT;
|
||||
}
|
||||
|
||||
static void
|
||||
start_window_cycling(struct server *server, enum lab_cycle_dir direction)
|
||||
{
|
||||
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Remember direction so it can be followed by subsequent key presses */
|
||||
server->osd_state.initial_direction = direction;
|
||||
server->osd_state.initial_keybind_contained_shift =
|
||||
shift_is_pressed(server);
|
||||
server->osd_state.cycle_view = desktop_cycle_view(server,
|
||||
server->osd_state.cycle_view, direction);
|
||||
|
||||
seat_focus_override_begin(&server->seat,
|
||||
LAB_INPUT_STATE_WINDOW_SWITCHER, LAB_CURSOR_DEFAULT);
|
||||
osd_update(server);
|
||||
}
|
||||
|
||||
static struct output *
|
||||
get_target_output(struct output *output, struct server *server,
|
||||
struct action *action)
|
||||
|
|
@ -982,10 +955,10 @@ actions_run(struct view *activator, struct server *server,
|
|||
}
|
||||
break;
|
||||
case ACTION_TYPE_NEXT_WINDOW:
|
||||
start_window_cycling(server, LAB_CYCLE_DIR_FORWARD);
|
||||
osd_begin(server, LAB_CYCLE_DIR_FORWARD);
|
||||
break;
|
||||
case ACTION_TYPE_PREVIOUS_WINDOW:
|
||||
start_window_cycling(server, LAB_CYCLE_DIR_BACKWARD);
|
||||
osd_begin(server, LAB_CYCLE_DIR_BACKWARD);
|
||||
break;
|
||||
case ACTION_TYPE_RECONFIGURE:
|
||||
kill(getpid(), SIGHUP);
|
||||
|
|
|
|||
|
|
@ -497,10 +497,7 @@ handle_cycle_view_key(struct server *server, struct keyinfo *keyinfo)
|
|||
|
||||
/* Only one direction modifier is allowed, either arrow keys OR shift */
|
||||
miss_shift_toggle:
|
||||
|
||||
server->osd_state.cycle_view = desktop_cycle_view(server,
|
||||
server->osd_state.cycle_view, direction);
|
||||
osd_update(server);
|
||||
osd_cycle(server, direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
37
src/osd.c
37
src/osd.c
|
|
@ -128,6 +128,43 @@ restore_preview_node(struct server *server)
|
|||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
shift_is_pressed(struct server *server)
|
||||
{
|
||||
uint32_t modifiers = wlr_keyboard_get_modifiers(
|
||||
&server->seat.keyboard_group->keyboard);
|
||||
return modifiers & WLR_MODIFIER_SHIFT;
|
||||
}
|
||||
|
||||
void
|
||||
osd_begin(struct server *server, enum lab_cycle_dir direction)
|
||||
{
|
||||
if (server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Remember direction so it can be followed by subsequent key presses */
|
||||
server->osd_state.initial_direction = direction;
|
||||
server->osd_state.initial_keybind_contained_shift =
|
||||
shift_is_pressed(server);
|
||||
server->osd_state.cycle_view = desktop_cycle_view(server,
|
||||
server->osd_state.cycle_view, direction);
|
||||
|
||||
seat_focus_override_begin(&server->seat,
|
||||
LAB_INPUT_STATE_WINDOW_SWITCHER, LAB_CURSOR_DEFAULT);
|
||||
osd_update(server);
|
||||
}
|
||||
|
||||
void
|
||||
osd_cycle(struct server *server, enum lab_cycle_dir direction)
|
||||
{
|
||||
assert(server->input_mode == LAB_INPUT_STATE_WINDOW_SWITCHER);
|
||||
|
||||
server->osd_state.cycle_view = desktop_cycle_view(server,
|
||||
server->osd_state.cycle_view, direction);
|
||||
osd_update(server);
|
||||
}
|
||||
|
||||
void
|
||||
osd_finish(struct server *server)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue