fix: layer shell + view bugs
- fix bug that causes layer shell seat focus incorrect on layer windows - focus on a regular view now raises all views of the related applications on top of the output
This commit is contained in:
parent
4c289d28da
commit
8d84d04d9c
13
layer.c
13
layer.c
@ -89,11 +89,10 @@ static void layer_surface_commit(struct wl_listener *listener, void *data)
|
||||
* enter a new/moved/resized layer surface.
|
||||
*/
|
||||
// cursor_update_focus(layer->server);
|
||||
diyac_cursor_focus(layer->server);
|
||||
//diyac_cursor_focus(layer->server);
|
||||
}
|
||||
}
|
||||
static void
|
||||
layer_surface_unmap(struct wl_listener *listener, void *data)
|
||||
static void layer_surface_unmap(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct diyac_layer_surface *layer = wl_container_of(listener, layer, unmap);
|
||||
struct wlr_layer_surface_v1 *layer_surface =
|
||||
@ -104,7 +103,7 @@ layer_surface_unmap(struct wl_listener *listener, void *data)
|
||||
}
|
||||
struct diyac_seat *seat = &layer->server->seat;
|
||||
if (seat->focused_layer == layer_surface) {
|
||||
diyac_seat_focus_layer(seat, NULL);
|
||||
diyac_seat_focus_layer(seat, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,11 +130,7 @@ static void layer_surface_node_destroy(struct wl_listener *listener, void *data)
|
||||
struct diyac_layer_surface *layer =
|
||||
wl_container_of(listener, layer, node_destroy);
|
||||
|
||||
/*
|
||||
* TODO: Determine if this layer is being used by an exclusive client.
|
||||
* If it is, try and find another layer owned by this client to pass
|
||||
* focus to.
|
||||
*/
|
||||
diyac_seat_focus_layer(&layer->server->seat, NULL);
|
||||
|
||||
wl_list_remove(&layer->map.link);
|
||||
wl_list_remove(&layer->unmap.link);
|
||||
|
49
seat.c
49
seat.c
@ -6,6 +6,7 @@
|
||||
#include <assert.h>
|
||||
#include "seat.h"
|
||||
#include "view.h"
|
||||
#include "output.h"
|
||||
|
||||
static void configure_keyboard(struct diyac_seat* seat, struct diyac_input* input, bool force)
|
||||
{
|
||||
@ -406,14 +407,33 @@ void diyac_seat_focus_layer(struct diyac_seat *seat, struct wlr_layer_surface_v1
|
||||
if (!layer)
|
||||
{
|
||||
seat->focused_layer = NULL;
|
||||
diyac_seat_focus_topmost(seat, diyac_output_from_cursor(seat->server));
|
||||
return;
|
||||
/*
|
||||
diyac_focus_topmost_view(seat->server, false);
|
||||
return;
|
||||
*/
|
||||
}
|
||||
if(seat->focused_layer == layer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(seat->focused_layer)
|
||||
wlr_log(WLR_INFO,"Layer focus changed %s -> %s", seat->focused_layer->namespace, layer->namespace);
|
||||
|
||||
// unfocus currently focus view
|
||||
if (seat->server->active_view)
|
||||
{
|
||||
diya_view_unfocus(seat->server->active_view);
|
||||
}
|
||||
seat_focus(seat, layer->surface, /*is_lock_surface*/ false);
|
||||
seat->focused_layer = layer;
|
||||
/*
|
||||
if (layer->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP)
|
||||
{
|
||||
seat->focused_layer = layer;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void diyac_seat_configure(struct diyac_server* server)
|
||||
@ -435,4 +455,33 @@ void diyac_seat_configure(struct diyac_server* server)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void diyac_seat_focus_topmost(struct diyac_seat* seat, struct diyac_output* output)
|
||||
{
|
||||
for(int i = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY; i >= ZWLR_LAYER_SHELL_V1_LAYER_TOP; i--)
|
||||
{
|
||||
struct wlr_scene_tree *scene = output->layer_tree[i];
|
||||
struct wl_list *node_list = & scene->children;
|
||||
struct wlr_scene_node *node;
|
||||
wl_list_for_each_reverse(node,node_list, link)
|
||||
{
|
||||
struct diyac_node_descriptor *node_descriptor = node->data;
|
||||
if (!node->enabled || !node_descriptor || node_descriptor->type != DIYAC_NODE_LAYER_SURFACE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
struct diyac_layer_surface* surface = (struct diyac_layer_surface *)node_descriptor->data;
|
||||
struct wlr_layer_surface_v1* layer_surface = surface->scene_layer_surface->layer_surface;
|
||||
if(!surface->mapped || layer_surface->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
wlr_log(WLR_INFO," Update focus on layer: %s", layer_surface->namespace);
|
||||
diyac_seat_focus_layer(seat, layer_surface);
|
||||
return;
|
||||
}
|
||||
}
|
||||
seat->focused_layer = NULL;
|
||||
diyac_focus_topmost_view(seat->server, true);
|
||||
}
|
3
seat.h
3
seat.h
@ -6,6 +6,7 @@ void diyac_init_seat(struct diyac_server* server);
|
||||
void diyac_seat_focus_surface(struct diyac_seat *seat, struct wlr_surface *surface);
|
||||
void diyac_seat_focus_lock_surface(struct diyac_seat *seat, struct wlr_surface *surface);
|
||||
void diyac_seat_focus_layer(struct diyac_seat *seat, struct wlr_layer_surface_v1 *layer);
|
||||
void diyac_seat_focus_topmost(struct diyac_seat* seat, struct diyac_output* output);
|
||||
|
||||
void diyac_seat_configure(struct diyac_server* server);
|
||||
#endif
|
||||
#endif
|
||||
|
55
view.c
55
view.c
@ -63,6 +63,30 @@ static void raise_to_front(struct diyac_view *view)
|
||||
/* Activate the new surface */
|
||||
}
|
||||
|
||||
static void raise_all_views(struct diyac_view* view)
|
||||
{
|
||||
struct diyac_view* root = diyac_get_root_view(view);
|
||||
if (root)
|
||||
{
|
||||
raise_to_front(root);
|
||||
struct diyac_view **subview = NULL;
|
||||
struct wl_array subviews;
|
||||
wl_array_init(&subviews);
|
||||
diyac_get_children_views(root, &subviews);
|
||||
wl_array_for_each(subview, &subviews)
|
||||
{
|
||||
raise_to_front(*subview);
|
||||
}
|
||||
wl_array_release(&subviews);
|
||||
}
|
||||
else
|
||||
{
|
||||
raise_to_front(view);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void diyac_focus_view(struct diyac_view *toplevel, bool raise)
|
||||
{
|
||||
/* Note: this function only deals with keyboard focus. */
|
||||
@ -86,18 +110,13 @@ void diyac_focus_view(struct diyac_view *toplevel, bool raise)
|
||||
{
|
||||
diyac_view_set_activated(toplevel->server->active_view, false);
|
||||
}
|
||||
raise_to_front(toplevel);
|
||||
if (raise)
|
||||
{
|
||||
struct diyac_view **subview = NULL;
|
||||
struct wl_array subviews;
|
||||
wl_array_init(&subviews);
|
||||
diyac_get_children_views(toplevel, &subviews);
|
||||
wl_array_for_each(subview, &subviews)
|
||||
{
|
||||
raise_to_front(*subview);
|
||||
}
|
||||
wl_array_release(&subviews);
|
||||
raise_all_views(toplevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
raise_to_front(toplevel);
|
||||
}
|
||||
diyac_view_set_activated(toplevel, true);
|
||||
// diyac_seat_focus_surface(&server->seat, toplevel->xdg_toplevel->base->surface);
|
||||
@ -256,7 +275,12 @@ bool diyac_view_update_geometry(struct diyac_view *view, bool grabbed)
|
||||
view->pending_size = view->original;
|
||||
}
|
||||
}
|
||||
|
||||
view->state = view->requested;
|
||||
if((view->state.maximized || view->state.fullscreen) && !wlr_box_equal(&usable, &view->original))
|
||||
{
|
||||
diyac_view_configure(view, usable);
|
||||
return true;
|
||||
}
|
||||
// if (wlr_output_layout_intersects(view->server->output_layout,
|
||||
// view->output->wlr_output, &view->current))
|
||||
//{
|
||||
@ -301,7 +325,6 @@ bool diyac_view_update_geometry(struct diyac_view *view, bool grabbed)
|
||||
geometry.y = usable.y + usable.height - server->grab_y;
|
||||
}
|
||||
}
|
||||
view->state = view->requested;
|
||||
if (!wlr_box_equal(&geometry, &view->original) || !view->requested.maximized)
|
||||
{
|
||||
wlr_log(WLR_DEBUG, "diyac_view_update_geometry: updating geometry: %d %d %d %d", geometry.x, geometry.y, geometry.width, geometry.height);
|
||||
@ -323,7 +346,7 @@ void diyac_get_children_views(struct diyac_view *view, struct wl_array *children
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!child->mapped /*&& !view->minimized*/)
|
||||
if (!child->mapped || view->state.minimized)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -488,3 +511,9 @@ void diyac_view_sync_geo(struct diyac_view *view)
|
||||
wlr_scene_node_set_position(&view->scene_tree->node, next_x, next_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void diya_view_unfocus(struct diyac_view* view)
|
||||
{
|
||||
diyac_view_set_activated(view, false);
|
||||
}
|
1
view.h
1
view.h
@ -21,4 +21,5 @@ void diyac_view_set_mimimize(struct diyac_view * view, bool activated);
|
||||
void diyac_view_update_title(struct diyac_view * view);
|
||||
void diyac_view_update_app_id(struct diyac_view * view);
|
||||
void diyac_view_sync_geo(struct diyac_view *view);
|
||||
void diya_view_unfocus(struct diyac_view* view);
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user