mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
desktop: refactor desktop_focus_view()
This commit is contained in:
parent
aa0b2b8e9e
commit
f752610e0b
6 changed files with 23 additions and 35 deletions
|
|
@ -221,7 +221,7 @@ void view_unminimize(struct view *view);
|
||||||
void view_for_each_surface(struct view *view,
|
void view_for_each_surface(struct view *view,
|
||||||
wlr_surface_iterator_func_t iterator, void *user_data);
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
||||||
|
|
||||||
void desktop_focus_view(struct view *view);
|
void desktop_focus_view(struct seat *seat, struct view *view);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* desktop_next_view - return next view
|
* desktop_next_view - return next view
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ cursor_button(struct wl_listener *listener, void *data)
|
||||||
server->cursor_mode = LAB_CURSOR_PASSTHROUGH;
|
server->cursor_mode = LAB_CURSOR_PASSTHROUGH;
|
||||||
} else {
|
} else {
|
||||||
/* Focus that client if the button was _pressed_ */
|
/* Focus that client if the button was _pressed_ */
|
||||||
desktop_focus_view(view);
|
desktop_focus_view(&server->seat, view);
|
||||||
switch (view_area) {
|
switch (view_area) {
|
||||||
case LAB_DECO_BUTTON_CLOSE:
|
case LAB_DECO_BUTTON_CLOSE:
|
||||||
view->impl->close(view);
|
view->impl->close(view);
|
||||||
|
|
|
||||||
|
|
@ -64,13 +64,20 @@ set_activated(struct wlr_surface *surface, bool activated)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
focus_view(struct view *view)
|
desktop_focus_view(struct seat *seat, struct view *view)
|
||||||
{
|
{
|
||||||
struct server *server = view->server;
|
if (!view) {
|
||||||
struct wlr_seat *wlr_seat = server->seat.seat;
|
seat_focus_surface(seat->seat, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (view->minimized) {
|
||||||
|
/* this will unmap and then focus */
|
||||||
|
view_unminimize(view);
|
||||||
|
return;
|
||||||
|
} else if (view->mapped) {
|
||||||
struct wlr_surface *prev_surface;
|
struct wlr_surface *prev_surface;
|
||||||
prev_surface = wlr_seat->keyboard_state.focused_surface;
|
prev_surface = seat->seat->keyboard_state.focused_surface;
|
||||||
if (prev_surface == view->surface) {
|
if (prev_surface == view->surface) {
|
||||||
/* Don't re-focus an already focused surface. */
|
/* Don't re-focus an already focused surface. */
|
||||||
return;
|
return;
|
||||||
|
|
@ -78,30 +85,11 @@ focus_view(struct view *view)
|
||||||
if (prev_surface) {
|
if (prev_surface) {
|
||||||
set_activated(prev_surface, false);
|
set_activated(prev_surface, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
move_to_front(view);
|
move_to_front(view);
|
||||||
set_activated(view->surface, true);
|
set_activated(view->surface, true);
|
||||||
|
seat_focus_surface(seat->seat, view->surface);
|
||||||
struct wlr_keyboard *kb = &server->seat.keyboard_group->keyboard;
|
|
||||||
wlr_seat_keyboard_notify_enter(wlr_seat, view->surface, kb->keycodes,
|
|
||||||
kb->num_keycodes, &kb->modifiers);
|
|
||||||
|
|
||||||
move_xwayland_sub_views_to_front(view);
|
move_xwayland_sub_views_to_front(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
desktop_focus_view(struct view *view)
|
|
||||||
{
|
|
||||||
if (!view) {
|
|
||||||
seat_focus_surface(view->server->seat.seat, NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (view->minimized) {
|
|
||||||
/* this will unmap and focus */
|
|
||||||
view_unminimize(view);
|
|
||||||
} else if (view->mapped) {
|
|
||||||
focus_view(view);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -187,7 +175,7 @@ desktop_focus_next_mapped_view(struct view *current)
|
||||||
{
|
{
|
||||||
assert(current);
|
assert(current);
|
||||||
struct view *view = desktop_next_mapped_view(current);
|
struct view *view = desktop_next_mapped_view(current);
|
||||||
desktop_focus_view(view);
|
desktop_focus_view(¤t->server->seat, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ keyboard_key_notify(struct wl_listener *listener, void *data)
|
||||||
if ((syms[0] == XKB_KEY_Alt_L) &&
|
if ((syms[0] == XKB_KEY_Alt_L) &&
|
||||||
event->state == WLR_KEY_RELEASED) {
|
event->state == WLR_KEY_RELEASED) {
|
||||||
/* end cycle */
|
/* end cycle */
|
||||||
desktop_focus_view(server->cycle_view);
|
desktop_focus_view(&server->seat, server->cycle_view);
|
||||||
server->cycle_view = NULL;
|
server->cycle_view = NULL;
|
||||||
} else if (event->state == WLR_KEY_PRESSED) {
|
} else if (event->state == WLR_KEY_PRESSED) {
|
||||||
/* cycle to next */
|
/* cycle to next */
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ xdg_toplevel_view_map(struct view *view)
|
||||||
&view->commit);
|
&view->commit);
|
||||||
view->commit.notify = handle_commit;
|
view->commit.notify = handle_commit;
|
||||||
|
|
||||||
desktop_focus_view(view);
|
desktop_focus_view(&view->server->seat, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ map(struct view *view)
|
||||||
&view->commit);
|
&view->commit);
|
||||||
view->commit.notify = handle_commit;
|
view->commit.notify = handle_commit;
|
||||||
|
|
||||||
desktop_focus_view(view);
|
desktop_focus_view(&view->server->seat, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue