mirror of
https://github.com/labwc/labwc.git
synced 2026-02-25 01:40:28 -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
|
|
@ -367,8 +367,6 @@ void foreign_toplevel_update_outputs(struct view *view);
|
||||||
* cannot assume this means that the window actually has keyboard
|
* cannot assume this means that the window actually has keyboard
|
||||||
* or pointer focus, in this compositor are they called together.
|
* 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_focus_and_activate_view(struct seat *seat, struct view *view);
|
||||||
void desktop_arrange_all_views(struct server *server);
|
void desktop_arrange_all_views(struct server *server);
|
||||||
void desktop_focus_output(struct output *output);
|
void desktop_focus_output(struct output *output);
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,10 @@ void view_snap_to_edge(struct view *view, const char *direction,
|
||||||
bool store_natural_geometry);
|
bool store_natural_geometry);
|
||||||
void view_snap_to_region(struct view *view, struct region *region,
|
void view_snap_to_region(struct view *view, struct region *region,
|
||||||
bool store_natural_geometry);
|
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);
|
const char *view_get_string_prop(struct view *view, const char *prop);
|
||||||
void view_update_title(struct view *view);
|
void view_update_title(struct view *view);
|
||||||
void view_update_app_id(struct view *view);
|
void view_update_app_id(struct view *view);
|
||||||
|
|
|
||||||
|
|
@ -439,12 +439,12 @@ actions_run(struct view *activator, struct server *server,
|
||||||
break;
|
break;
|
||||||
case ACTION_TYPE_RAISE:
|
case ACTION_TYPE_RAISE:
|
||||||
if (view) {
|
if (view) {
|
||||||
desktop_move_to_front(view);
|
view_move_to_front(view);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACTION_TYPE_LOWER:
|
case ACTION_TYPE_LOWER:
|
||||||
if (view) {
|
if (view) {
|
||||||
desktop_move_to_back(view);
|
view_move_to_back(view);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACTION_TYPE_RESIZE:
|
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) {
|
if (ctx.view && rc.focus_follow_mouse) {
|
||||||
desktop_focus_and_activate_view(seat, ctx.view);
|
desktop_focus_and_activate_view(seat, ctx.view);
|
||||||
if (rc.raise_on_focus) {
|
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;
|
return t->tv_sec * 1000 + t->tv_nsec / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
cursor_update_focus(struct server *server)
|
_cursor_update_focus(struct server *server)
|
||||||
{
|
{
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
@ -523,12 +523,7 @@ cursor_update_focus(struct server *server)
|
||||||
/* Prevent changing keyboard focus during A-Tab */
|
/* Prevent changing keyboard focus during A-Tab */
|
||||||
desktop_focus_and_activate_view(&server->seat, ctx.view);
|
desktop_focus_and_activate_view(&server->seat, ctx.view);
|
||||||
if (rc.raise_on_focus) {
|
if (rc.raise_on_focus) {
|
||||||
/*
|
view_move_to_front(ctx.view);
|
||||||
* 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -536,6 +531,18 @@ cursor_update_focus(struct server *server)
|
||||||
/*cursor_has_moved*/ false);
|
/*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
|
static void
|
||||||
handle_constraint_commit(struct wl_listener *listener, void *data)
|
handle_constraint_commit(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,30 +12,6 @@
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
#include "xwayland.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
|
void
|
||||||
desktop_arrange_all_views(struct server *server)
|
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);
|
struct view *view = topmost_mapped_view(server);
|
||||||
desktop_focus_and_activate_view(&server->seat, view);
|
desktop_focus_and_activate_view(&server->seat, view);
|
||||||
desktop_move_to_front(view);
|
if (view) {
|
||||||
|
view_move_to_front(view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ handle_request_activate(struct wl_listener *listener, void *data)
|
||||||
workspaces_switch_to(view->workspace);
|
workspaces_switch_to(view->workspace);
|
||||||
}
|
}
|
||||||
desktop_focus_and_activate_view(&view->server->seat, view);
|
desktop_focus_and_activate_view(&view->server->seat, view);
|
||||||
desktop_move_to_front(view);
|
view_move_to_front(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ static void
|
||||||
end_cycling(struct server *server)
|
end_cycling(struct server *server)
|
||||||
{
|
{
|
||||||
desktop_focus_and_activate_view(&server->seat, server->osd_state.cycle_view);
|
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() additionally resets cycle_view to NULL */
|
||||||
osd_finish(server);
|
osd_finish(server);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ void
|
||||||
view_impl_map(struct view *view)
|
view_impl_map(struct view *view)
|
||||||
{
|
{
|
||||||
desktop_focus_and_activate_view(&view->server->seat, 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_title(view);
|
||||||
view_update_app_id(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);
|
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 *
|
const char *
|
||||||
view_get_string_prop(struct view *view, const char *prop)
|
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);
|
workspaces_switch_to(view->workspace);
|
||||||
}
|
}
|
||||||
desktop_focus_and_activate_view(&view->server->seat, view);
|
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);
|
wl_container_of(listener, xwayland_view, request_activate);
|
||||||
struct view *view = &xwayland_view->base;
|
struct view *view = &xwayland_view->base;
|
||||||
desktop_focus_and_activate_view(&view->server->seat, view);
|
desktop_focus_and_activate_view(&view->server->seat, view);
|
||||||
desktop_move_to_front(view);
|
view_move_to_front(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue