This avoids calling view->impl functions from cursor.c and desktop.c.
v2: Add an explicit recursion guard in cursor_update_focus().
* cannot assume this means that the window actually has keyboard
* or pointer focus, in this compositor are they called together.
*/
-void desktop_move_to_front(struct view *view);
-void desktop_move_to_back(struct view *view);
void desktop_focus_and_activate_view(struct seat *seat, struct view *view);
void desktop_arrange_all_views(struct server *server);
void desktop_focus_output(struct output *output);
bool store_natural_geometry);
void view_snap_to_region(struct view *view, struct region *region,
bool store_natural_geometry);
+
+void view_move_to_front(struct view *view);
+void view_move_to_back(struct view *view);
+
const char *view_get_string_prop(struct view *view, const char *prop);
void view_update_title(struct view *view);
void view_update_app_id(struct view *view);
break;
case ACTION_TYPE_RAISE:
if (view) {
- desktop_move_to_front(view);
+ view_move_to_front(view);
}
break;
case ACTION_TYPE_LOWER:
if (view) {
- desktop_move_to_back(view);
+ view_move_to_back(view);
}
break;
case ACTION_TYPE_RESIZE:
if (ctx.view && rc.focus_follow_mouse) {
desktop_focus_and_activate_view(seat, ctx.view);
if (rc.raise_on_focus) {
- desktop_move_to_front(ctx.view);
+ view_move_to_front(ctx.view);
}
}
return t->tv_sec * 1000 + t->tv_nsec / 1000000;
}
-void
-cursor_update_focus(struct server *server)
+static void
+_cursor_update_focus(struct server *server)
{
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
/* Prevent changing keyboard focus during A-Tab */
desktop_focus_and_activate_view(&server->seat, ctx.view);
if (rc.raise_on_focus) {
- /*
- * Call view method directly as desktop_move_to_front()
- * contains a call to cursor_update_focus() and thus
- * loops inifinitely
- */
- ctx.view->impl->move_to_front(ctx.view);
+ view_move_to_front(ctx.view);
}
}
/*cursor_has_moved*/ false);
}
+void
+cursor_update_focus(struct server *server)
+{
+ /* Prevent recursion via view_move_to_front() */
+ static bool updating_focus = false;
+ if (!updating_focus) {
+ updating_focus = true;
+ _cursor_update_focus(server);
+ updating_focus = false;
+ }
+}
+
static void
handle_constraint_commit(struct wl_listener *listener, void *data)
{
#include "workspaces.h"
#include "xwayland.h"
-void
-desktop_move_to_front(struct view *view)
-{
- if (!view) {
- return;
- }
- if (view->impl->move_to_front) {
- view->impl->move_to_front(view);
- cursor_update_focus(view->server);
- }
-}
-
-void
-desktop_move_to_back(struct view *view)
-{
- if (!view) {
- return;
- }
- if (view->impl->move_to_back) {
- view->impl->move_to_back(view);
- cursor_update_focus(view->server);
- }
-}
-
void
desktop_arrange_all_views(struct server *server)
{
{
struct view *view = topmost_mapped_view(server);
desktop_focus_and_activate_view(&server->seat, view);
- desktop_move_to_front(view);
+ if (view) {
+ view_move_to_front(view);
+ }
}
void
workspaces_switch_to(view->workspace);
}
desktop_focus_and_activate_view(&view->server->seat, view);
- desktop_move_to_front(view);
+ view_move_to_front(view);
}
static void
end_cycling(struct server *server)
{
desktop_focus_and_activate_view(&server->seat, server->osd_state.cycle_view);
- desktop_move_to_front(server->osd_state.cycle_view);
+ if (server->osd_state.cycle_view) {
+ view_move_to_front(server->osd_state.cycle_view);
+ }
/* osd_finish() additionally resets cycle_view to NULL */
osd_finish(server);
view_impl_map(struct view *view)
{
desktop_focus_and_activate_view(&view->server->seat, view);
- desktop_move_to_front(view);
+ view_move_to_front(view);
view_update_title(view);
view_update_app_id(view);
}
view_apply_region_geometry(view);
}
+void
+view_move_to_front(struct view *view)
+{
+ assert(view);
+ if (view->impl->move_to_front) {
+ view->impl->move_to_front(view);
+ cursor_update_focus(view->server);
+ }
+}
+
+void
+view_move_to_back(struct view *view)
+{
+ assert(view);
+ if (view->impl->move_to_back) {
+ view->impl->move_to_back(view);
+ cursor_update_focus(view->server);
+ }
+}
+
const char *
view_get_string_prop(struct view *view, const char *prop)
{
workspaces_switch_to(view->workspace);
}
desktop_focus_and_activate_view(&view->server->seat, view);
- desktop_move_to_front(view);
+ view_move_to_front(view);
}
/*
wl_container_of(listener, xwayland_view, request_activate);
struct view *view = &xwayland_view->base;
desktop_focus_and_activate_view(&view->server->seat, view);
- desktop_move_to_front(view);
+ view_move_to_front(view);
}
static void