void foreign_toplevel_handle_create(struct view *view);
+/*
+ * desktop.c routines deal with a collection of views
+ *
+ * Definition of a few keywords used in desktop.c
+ * raise - Bring view to front.
+ * focus - Give keyboard focus to view.
+ * activate - Set view surface as active so that client window decorations
+ * are painted to show that the window is active,typically by
+ * using a different color. Although xdg-shell protocol says you
+ * cannot assume this means that the window actually has keyboard
+ * or pointer focus, in this compositor are they called together.
+ */
+
void desktop_set_focus_view_only(struct seat *seat, struct view *view);
-void desktop_focus_view(struct seat *seat, struct view *view);
+void desktop_raise_view(struct view *view);
+void desktop_focus_and_activate_view(struct seat *seat, struct view *view);
/**
* desktop_cycle_view - return view to 'cycle' to
if (view && rc.focus_follow_mouse) {
if (rc.raise_on_focus) {
- desktop_focus_view(&server->seat, view);
+ desktop_focus_and_activate_view(&server->seat, view);
+ desktop_raise_view(view);
} else {
desktop_set_focus_view_only(&server->seat, view);
}
}
/* Handle _press_ on view */
- desktop_focus_view(&server->seat, view);
+ desktop_focus_and_activate_view(&server->seat, view);
+ desktop_raise_view(view);
damage_all_outputs(server);
if (is_double_click(rc.doubleclick_time)
}
void
-desktop_focus_view(struct seat *seat, struct view *view)
+desktop_raise_view(struct view *view)
+{
+ if (!view) {
+ return;
+ }
+ move_to_front(view);
+#if HAVE_XWAYLAND
+ move_xwayland_sub_views_to_front(view);
+#endif
+}
+
+static void
+deactivate_all_views(struct server *server)
+{
+ struct view *view;
+ wl_list_for_each (view, &server->views, link) {
+ if (!view->mapped) {
+ continue;
+ }
+ view_set_activated(view, false);
+ }
+}
+
+void
+desktop_focus_and_activate_view(struct seat *seat, struct view *view)
{
if (!view) {
seat_focus_surface(seat, NULL);
}
if (view->minimized) {
- /* this will unmap and then focus */
+ /*
+ * Unminimizing will map the view which triggers a call to this
+ * function again.
+ */
view_minimize(view, false);
return;
- } else if (view->mapped) {
- struct wlr_surface *prev_surface;
- prev_surface = seat->seat->keyboard_state.focused_surface;
- if (prev_surface == view->surface) {
- /* Don't re-focus an already focused surface. */
- move_to_front(view);
-#if HAVE_XWAYLAND
- move_xwayland_sub_views_to_front(view);
-#endif
- return;
- }
- if (prev_surface) {
- set_activated(prev_surface, false);
- }
- move_to_front(view);
- set_activated(view->surface, true);
- seat_focus_surface(seat, view->surface);
-#if HAVE_XWAYLAND
- move_xwayland_sub_views_to_front(view);
-#endif
}
+ if (!view->mapped) {
+ return;
+ }
+
+ struct wlr_surface *prev_surface;
+ prev_surface = seat->seat->keyboard_state.focused_surface;
+
+ /* Do not re-focus an already focused surface. */
+ if (prev_surface == view->surface) {
+ return;
+ }
+
+ deactivate_all_views(view->server);
+ view_set_activated(view, true);
+ seat_focus_surface(seat, view->surface);
}
/*
desktop_focus_topmost_mapped_view(struct server *server)
{
struct view *view = topmost_mapped_view(server);
- desktop_focus_view(&server->seat, view);
+ desktop_focus_and_activate_view(&server->seat, view);
+ desktop_raise_view(view);
}
static bool
if ((event->state == WL_KEYBOARD_KEY_STATE_RELEASED)
&& !any_modifiers_pressed(device->keyboard)) {
/* end cycle */
- desktop_focus_view(&server->seat, server->cycle_view);
+ desktop_focus_and_activate_view(&server->seat,
+ server->cycle_view);
+ desktop_raise_view(server->cycle_view);
server->cycle_view = NULL;
}
}
wl_signal_add(&view->surface->events.new_subsurface,
&view->new_subsurface);
- desktop_focus_view(&view->server->seat, view);
+ desktop_focus_and_activate_view(&view->server->seat, view);
+ desktop_raise_view(view);
damage_all_outputs(view->server);
}
&view->commit);
view->commit.notify = handle_commit;
- desktop_focus_view(&view->server->seat, view);
+ desktop_focus_and_activate_view(&view->server->seat, view);
+ desktop_raise_view(view);
damage_all_outputs(view->server);
}