Fix issues related to wlr_scene

This commit is contained in:
project-repo 2022-02-15 22:33:53 +01:00
commit da1f973532
4 changed files with 32 additions and 18 deletions

View file

@ -786,14 +786,11 @@ keybinding_move_view_to_cycle_output(struct cg_server *server, bool reverse) {
}
keybinding_cycle_outputs(server, reverse);
if(view != NULL) {
wl_list_insert(&server->curr_output
->workspaces[server->curr_output->curr_workspace]
->views,
&view->link);
server->curr_output->workspaces[server->curr_output->curr_workspace]
->focused_tile->view = view;
view->workspace = server->curr_output
->workspaces[server->curr_output->curr_workspace];
struct cg_workspace *ws=server->curr_output->workspaces[server->curr_output->curr_workspace];
wl_list_insert(&ws->views, &view->link);
ws->focused_tile->view = view;
wlr_scene_node_reparent(view->scene_node, &ws->scene->node);
view->workspace = ws;
view->tile = view->workspace->focused_tile;
view_maximize(view, view->tile);
seat_set_focus(server->seat, view);
@ -942,6 +939,7 @@ keybinding_move_view_to_output(struct cg_server *server, int output_num) {
->workspaces[server->curr_output->curr_workspace];
view->workspace = ws;
wl_list_insert(&ws->views, &view->link);
wlr_scene_node_reparent(view->scene_node, &ws->scene->node);
ws->focused_tile->view = view;
view_maximize(view, ws->focused_tile);
seat_set_focus(server->seat, view);
@ -982,6 +980,7 @@ keybinding_move_view_to_workspace(struct cg_server *server, uint32_t ws) {
->workspaces[server->curr_output->curr_workspace];
view->workspace = ws;
wl_list_insert(&ws->views, &view->link);
wlr_scene_node_reparent(view->scene_node, &ws->scene->node);
ws->focused_tile->view = view;
view_maximize(view, ws->focused_tile);
seat_set_focus(server->seat, view);

View file

@ -864,12 +864,12 @@ parse_command(struct cg_server *server, struct keybinding *keybinding,
char *mode = strtok_r(NULL, " ", &saveptr);
if(mode == NULL) {
*errstr =
log_error("Expected mode after \"switch_mode\". Got nothing.");
log_error("Expected mode after \"mode\". Got nothing.");
return -1;
}
int mode_idx = get_mode_index_from_name(server->modes, mode);
if(mode_idx == -1) {
*errstr = log_error("Unknown mode \"%s\" for switch_mode", mode);
*errstr = log_error("Unknown mode \"%s\" for \"mode\"", mode);
return -1;
}
keybinding->data.u = (unsigned int)mode_idx;

22
view.c
View file

@ -108,7 +108,7 @@ void
view_unmap(struct cg_view *view) {
uint32_t id = view->id;
uint32_t tile_id = view->tile->id;
uint32_t tile_id = 0;
uint32_t ws = view->workspace->num;
char *output_name = view->workspace->output->wlr_output->name;
char *title = view->impl->get_title(view);
@ -117,13 +117,18 @@ view_unmap(struct cg_view *view) {
return;
}
if(view->tile == NULL) {
tile_id=-1;
} else {
tile_id=view->tile->id;
}
wlr_scene_node_destroy(view->scene_node);
#if CG_HAS_XWAYLAND
if((view->type != CG_XWAYLAND_VIEW || xwayland_view_should_manage(view)))
#endif
{
struct cg_tile *view_tile = view_get_tile(view);
struct cg_view *prev = view_get_prev_view(view);
if(view == view->server->seat->focused_view) {
seat_set_focus(view->server->seat, prev);
@ -133,7 +138,7 @@ view_unmap(struct cg_view *view) {
seat_set_focus(view->server->seat,
view->server->seat->focused_view);
}
view_tile = view_get_tile(view);
struct cg_tile *view_tile = view_get_tile(view);
if(view_tile != NULL) {
view_tile->view = prev;
if(prev != NULL) {
@ -180,6 +185,9 @@ view_map(struct cg_view *view, struct wlr_surface *surface,
their own (x,y) coordinates in handle_wayland_surface_map. */
if(view->type == CG_XWAYLAND_VIEW && !xwayland_view_should_manage(view)) {
wl_list_insert(&ws->unmanaged_views, &view->link);
struct wlr_box *box = wlr_output_layout_get_box(
view->server->output_layout, view->workspace->output->wlr_output);
wlr_scene_node_set_position(view->scene_node, view->ox+box->x, view->oy+box->y);
} else
#endif
{
@ -188,10 +196,16 @@ view_map(struct cg_view *view, struct wlr_surface *surface,
wl_list_insert(&ws->views, &view->link);
}
seat_set_focus(output->server->seat, view);
int tile_id=0;
if(view->tile==NULL) {
tile_id=-1;
} else {
tile_id=view->tile->id;
}
ipc_send_event(
output->server,
"view_map(view_id:%d,tile_id:%d,workspace:%d,output:%s,view_title:%s)",
view->id, view->tile->id, view->workspace->num + 1,
view->id, tile_id, view->workspace->num + 1,
view->workspace->output->wlr_output->name, view->impl->get_title(view));
}

View file

@ -10,7 +10,6 @@
#include <X11/Xutil.h>
#include <stdbool.h>
#include <wayland-server-core.h>
#include <wlr/util/box.h>
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/util/log.h>
@ -121,10 +120,12 @@ handle_xwayland_surface_map(struct wl_listener *listener, void *_data) {
struct cg_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, map);
struct cg_view *view = &xwayland_view->view;
if(!xwayland_view_should_manage(view)) {
view->ox = xwayland_view->xwayland_surface->x;
view->oy = xwayland_view->xwayland_surface->y;
struct wlr_output_layout *output_layout = view->server->output_layout;
struct wlr_box *output_box = wlr_output_layout_get_box(
output_layout, view->server->curr_output->wlr_output);
view->ox = xwayland_view->xwayland_surface->x-output_box->x;
view->oy = xwayland_view->xwayland_surface->y-output_box->y;
}
view_map(view, xwayland_view->xwayland_surface->surface,