mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
define focused_view function and use it for keyboard actions
This commit is contained in:
parent
a15a56bfe1
commit
815cd4aa46
3 changed files with 26 additions and 6 deletions
12
src/action.c
12
src/action.c
|
|
@ -24,7 +24,7 @@ action(struct server *server, const char *action, const char *command)
|
|||
if (!action)
|
||||
return;
|
||||
if (!strcasecmp(action, "Close")) {
|
||||
struct view *view = topmost_mapped_view(server);
|
||||
struct view *view = focused_view(server);
|
||||
if (view) {
|
||||
view->impl->close(view);
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ action(struct server *server, const char *action, const char *command)
|
|||
} else if (!strcasecmp(action, "Exit")) {
|
||||
wl_display_terminate(server->wl_display);
|
||||
} else if (!strcasecmp(action, "MoveToEdge")) {
|
||||
view_move_to_edge(topmost_mapped_view(server), command);
|
||||
view_move_to_edge(focused_view(server), command);
|
||||
} else if (!strcasecmp(action, "NextWindow")) {
|
||||
server->cycle_view =
|
||||
desktop_cycle_view(server, server->cycle_view);
|
||||
|
|
@ -50,22 +50,22 @@ action(struct server *server, const char *action, const char *command)
|
|||
} else if (!strcasecmp(action, "ShowMenu")) {
|
||||
show_menu(server, command);
|
||||
} else if (!strcasecmp(action, "ToggleMaximize")) {
|
||||
struct view *view = topmost_mapped_view(server);
|
||||
struct view *view = focused_view(server);
|
||||
if (view) {
|
||||
view_toggle_maximize(view);
|
||||
}
|
||||
} else if (!strcasecmp(action, "ToggleFullscreen")) {
|
||||
struct view *view = topmost_mapped_view(server);
|
||||
struct view *view = focused_view(server);
|
||||
if (view) {
|
||||
view_toggle_fullscreen(view);
|
||||
}
|
||||
} else if (!strcasecmp(action, "ToggleDecorations")) {
|
||||
struct view *view = topmost_mapped_view(server);
|
||||
struct view *view = focused_view(server);
|
||||
if (view) {
|
||||
view_toggle_decorations(view);
|
||||
}
|
||||
} else if (!strcasecmp(action, "Iconify")) {
|
||||
struct view *view = topmost_mapped_view(server);
|
||||
struct view *view = focused_view(server);
|
||||
if (view) {
|
||||
view_minimize(view, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,6 +212,25 @@ topmost_mapped_view(struct server *server)
|
|||
return view;
|
||||
}
|
||||
|
||||
struct view *
|
||||
focused_view(struct server *server)
|
||||
{
|
||||
struct seat *seat = &server->seat;
|
||||
struct wlr_surface *focused_surface;
|
||||
focused_surface = seat->seat->keyboard_state.focused_surface;
|
||||
if (!focused_surface) {
|
||||
return NULL;
|
||||
}
|
||||
struct view *view;
|
||||
wl_list_for_each (view, &server->views, link) {
|
||||
if (view->surface == focused_surface) {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
desktop_focus_topmost_mapped_view(struct server *server)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue