mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
view: Add view_move_to_front/back().
This avoids calling view->impl functions from cursor.c and desktop.c. v2: Add an explicit recursion guard in cursor_update_focus().
This commit is contained in:
parent
12f3314595
commit
d7dd366bad
11 changed files with 52 additions and 43 deletions
|
|
@ -439,12 +439,12 @@ actions_run(struct view *activator, struct server *server,
|
|||
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:
|
||||
|
|
|
|||
25
src/cursor.c
25
src/cursor.c
|
|
@ -481,7 +481,7 @@ process_cursor_motion(struct server *server, uint32_t time)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -510,8 +510,8 @@ msec(const struct timespec *t)
|
|||
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);
|
||||
|
|
@ -523,12 +523,7 @@ cursor_update_focus(struct server *server)
|
|||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -536,6 +531,18 @@ cursor_update_focus(struct server *server)
|
|||
/*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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,30 +12,6 @@
|
|||
#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)
|
||||
{
|
||||
|
|
@ -267,7 +243,9 @@ desktop_focus_topmost_mapped_view(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
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ handle_request_activate(struct wl_listener *listener, void *data)
|
|||
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
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ 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);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ void
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
20
src/view.c
20
src/view.c
|
|
@ -982,6 +982,26 @@ view_snap_to_region(struct view *view, struct region *region,
|
|||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ xdg_activation_handle_request(struct wl_listener *listener, void *data)
|
|||
workspaces_switch_to(view->workspace);
|
||||
}
|
||||
desktop_focus_and_activate_view(&view->server->seat, view);
|
||||
desktop_move_to_front(view);
|
||||
view_move_to_front(view);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ handle_request_activate(struct wl_listener *listener, void *data)
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue