mirror of
https://github.com/labwc/labwc.git
synced 2026-03-19 05:33:53 -04:00
view: add move_to_front to struct view_impl
...to increase xwayland and xdg-shell encapsulation and to avoid passing a function pointer as an argument in `xwayland_move_sub_views_to_front()` which is inconsistent with labwc design patterns. Rename view-impl.c to view-impl-common.c Move function declarations that are common to view-implementations from view.h into view-impl-common.h
This commit is contained in:
parent
440372c2da
commit
b8ec5a3e2e
10 changed files with 74 additions and 55 deletions
|
|
@ -365,7 +365,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_front(struct view *view);
|
||||||
void desktop_move_to_back(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);
|
||||||
|
|
|
||||||
14
include/view-impl-common.h
Normal file
14
include/view-impl-common.h
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
#ifndef __LABWC_VIEW_IMPL_COMMON_H
|
||||||
|
#define __LABWC_VIEW_IMPL_COMMON_H
|
||||||
|
/*
|
||||||
|
* Common code for view->impl functions
|
||||||
|
*
|
||||||
|
* Please note: only xdg-shell-toplevel-view and xwayland-view view_impl
|
||||||
|
* functions should call these functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void view_impl_move_to_front(struct view *view);
|
||||||
|
void view_impl_map(struct view *view);
|
||||||
|
|
||||||
|
#endif /* __LABWC_VIEW_IMPL_COMMON_H */
|
||||||
|
|
@ -30,6 +30,7 @@ struct view_impl {
|
||||||
void (*set_fullscreen)(struct view *view, bool fullscreen);
|
void (*set_fullscreen)(struct view *view, bool fullscreen);
|
||||||
void (*unmap)(struct view *view);
|
void (*unmap)(struct view *view);
|
||||||
void (*maximize)(struct view *view, bool maximize);
|
void (*maximize)(struct view *view, bool maximize);
|
||||||
|
void (*move_to_front)(struct view *view);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct view {
|
struct view {
|
||||||
|
|
@ -162,7 +163,6 @@ void view_update_title(struct view *view);
|
||||||
void view_update_app_id(struct view *view);
|
void view_update_app_id(struct view *view);
|
||||||
void view_reload_ssd(struct view *view);
|
void view_reload_ssd(struct view *view);
|
||||||
|
|
||||||
void view_impl_map(struct view *view);
|
|
||||||
void view_adjust_size(struct view *view, int *w, int *h);
|
void view_adjust_size(struct view *view, int *w, int *h);
|
||||||
|
|
||||||
void view_evacuate_region(struct view *view);
|
void view_evacuate_region(struct view *view);
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,6 @@ void xwayland_unmanaged_create(struct server *server,
|
||||||
struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
|
struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
|
||||||
|
|
||||||
bool xwayland_apply_size_hints(struct view *view, int *w, int *h);
|
bool xwayland_apply_size_hints(struct view *view, int *w, int *h);
|
||||||
void xwayland_move_sub_views_to_front(struct view *parent,
|
|
||||||
void (*move_to_front)(struct view *view));
|
|
||||||
|
|
||||||
void xwayland_server_init(struct server *server,
|
void xwayland_server_init(struct server *server,
|
||||||
struct wlr_compositor *compositor);
|
struct wlr_compositor *compositor);
|
||||||
|
|
|
||||||
|
|
@ -12,25 +12,16 @@
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
#include "xwayland.h"
|
#include "xwayland.h"
|
||||||
|
|
||||||
static void
|
|
||||||
move_to_front(struct view *view)
|
|
||||||
{
|
|
||||||
wl_list_remove(&view->link);
|
|
||||||
wl_list_insert(&view->server->views, &view->link);
|
|
||||||
wlr_scene_node_raise_to_top(&view->scene_tree->node);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
desktop_move_to_front(struct view *view)
|
desktop_move_to_front(struct view *view)
|
||||||
{
|
{
|
||||||
if (!view) {
|
if (!view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
move_to_front(view);
|
if (view->impl->move_to_front) {
|
||||||
#if HAVE_XWAYLAND
|
view->impl->move_to_front(view);
|
||||||
xwayland_move_sub_views_to_front(view, move_to_front);
|
cursor_update_focus(view->server);
|
||||||
#endif
|
}
|
||||||
cursor_update_focus(view->server);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "key-state.h"
|
#include "key-state.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "regions.h"
|
#include "regions.h"
|
||||||
|
#include "view.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
|
||||||
static bool should_cancel_cycling_on_next_key_release;
|
static bool should_cancel_cycling_on_next_key_release;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ labwc_sources = files(
|
||||||
'touch.c',
|
'touch.c',
|
||||||
'theme.c',
|
'theme.c',
|
||||||
'view.c',
|
'view.c',
|
||||||
'view-impl.c',
|
'view-impl-common.c',
|
||||||
'workspaces.c',
|
'workspaces.c',
|
||||||
'xdg.c',
|
'xdg.c',
|
||||||
'xdg-deco.c',
|
'xdg-deco.c',
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,24 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/* view-impl.c: common code for shell view->impl functions */
|
/* view-impl-common.c: common code for shell view->impl functions */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
#include "view-impl-common.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
view_impl_move_to_front(struct view *view)
|
||||||
|
{
|
||||||
|
wl_list_remove(&view->link);
|
||||||
|
wl_list_insert(&view->server->views, &view->link);
|
||||||
|
wlr_scene_node_raise_to_top(&view->scene_tree->node);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
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);
|
desktop_move_to_front(view);
|
||||||
|
|
||||||
view_update_title(view);
|
view_update_title(view);
|
||||||
view_update_app_id(view);
|
view_update_app_id(view);
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
#include "view-impl-common.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
|
||||||
struct wlr_xdg_surface *
|
struct wlr_xdg_surface *
|
||||||
|
|
@ -389,6 +390,7 @@ static const struct view_impl xdg_toplevel_view_impl = {
|
||||||
.set_fullscreen = xdg_toplevel_view_set_fullscreen,
|
.set_fullscreen = xdg_toplevel_view_set_fullscreen,
|
||||||
.unmap = xdg_toplevel_view_unmap,
|
.unmap = xdg_toplevel_view_unmap,
|
||||||
.maximize = xdg_toplevel_view_maximize,
|
.maximize = xdg_toplevel_view_maximize,
|
||||||
|
.move_to_front = view_impl_move_to_front,
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
#include "view-impl-common.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
#include "xwayland.h"
|
#include "xwayland.h"
|
||||||
|
|
||||||
|
|
@ -57,40 +58,6 @@ top_parent_of(struct view *view)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xwayland_move_sub_views_to_front(struct view *parent,
|
|
||||||
void (*move_to_front)(struct view *view))
|
|
||||||
{
|
|
||||||
assert(parent);
|
|
||||||
assert(move_to_front);
|
|
||||||
|
|
||||||
if (parent->type != LAB_XWAYLAND_VIEW) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_xwayland_surface *parent_xwayland_surface =
|
|
||||||
xwayland_surface_from_view(parent);
|
|
||||||
struct view *view, *next;
|
|
||||||
wl_list_for_each_reverse_safe(view, next, &parent->server->views, link)
|
|
||||||
{
|
|
||||||
/* need to stop here, otherwise loops keeps going forever */
|
|
||||||
if (view == parent) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (view->type != LAB_XWAYLAND_VIEW) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!view->mapped && !view->minimized) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (top_parent_of(view) != parent_xwayland_surface) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
move_to_front(view);
|
|
||||||
/* TODO: we should probably focus on these too here */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct xwayland_view *
|
static struct xwayland_view *
|
||||||
xwayland_view_from_view(struct view *view)
|
xwayland_view_from_view(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -545,6 +512,44 @@ maximize(struct view *view, bool maximized)
|
||||||
maximized);
|
maximized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
move_sub_views_to_front(struct view *parent)
|
||||||
|
{
|
||||||
|
assert(parent);
|
||||||
|
|
||||||
|
if (parent->type != LAB_XWAYLAND_VIEW) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wlr_xwayland_surface *parent_xwayland_surface =
|
||||||
|
xwayland_surface_from_view(parent);
|
||||||
|
struct view *view, *next;
|
||||||
|
wl_list_for_each_reverse_safe(view, next, &parent->server->views, link)
|
||||||
|
{
|
||||||
|
/* need to stop here, otherwise loops keeps going forever */
|
||||||
|
if (view == parent) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (view->type != LAB_XWAYLAND_VIEW) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!view->mapped && !view->minimized) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (top_parent_of(view) != parent_xwayland_surface) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
view_impl_move_to_front(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
move_to_front(struct view *view)
|
||||||
|
{
|
||||||
|
view_impl_move_to_front(view);
|
||||||
|
move_sub_views_to_front(view);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_activated(struct view *view, bool activated)
|
set_activated(struct view *view, bool activated)
|
||||||
{
|
{
|
||||||
|
|
@ -584,7 +589,8 @@ static const struct view_impl xwl_view_impl = {
|
||||||
.set_activated = set_activated,
|
.set_activated = set_activated,
|
||||||
.set_fullscreen = set_fullscreen,
|
.set_fullscreen = set_fullscreen,
|
||||||
.unmap = unmap,
|
.unmap = unmap,
|
||||||
.maximize = maximize
|
.maximize = maximize,
|
||||||
|
.move_to_front = move_to_front,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue