mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-19 03:54:18 +02:00
Update view focus logic
This commit is contained in:
parent
73e0a421d2
commit
494fd6444b
6 changed files with 42 additions and 60 deletions
56
keybinding.c
56
keybinding.c
|
|
@ -220,17 +220,13 @@ swap_tile(struct cg_tile *tile,
|
|||
return;
|
||||
}
|
||||
struct cg_view *tmp_view = tile->view;
|
||||
tile->view = swap_tile->view;
|
||||
swap_tile->view = tmp_view;
|
||||
if(tile->view != NULL) {
|
||||
view_maximize(tile->view, tile);
|
||||
}
|
||||
struct cg_view *tmp_swap_view = swap_tile->view;
|
||||
workspace_tile_update_view(tile,NULL);
|
||||
workspace_tile_update_view(swap_tile,tmp_view);
|
||||
workspace_tile_update_view(tile,tmp_swap_view);
|
||||
workspace_focus_tile(
|
||||
server->curr_output->workspaces[server->curr_output->curr_workspace],
|
||||
swap_tile);
|
||||
if(swap_tile->view != NULL) {
|
||||
view_maximize(swap_tile->view, swap_tile);
|
||||
}
|
||||
seat_set_focus(server->seat, swap_tile->view);
|
||||
ipc_send_event(tile->workspace->output->server,
|
||||
"{\"event_name\":\"swap_tile\",\"tile_id\":\"%d\",\"swap_"
|
||||
|
|
@ -558,7 +554,7 @@ keybinding_split_output(struct cg_output *output, bool vertical) {
|
|||
new_tile->tile.height = y + height - new_y;
|
||||
new_tile->prev = curr_workspace->focused_tile;
|
||||
new_tile->next = curr_workspace->focused_tile->next;
|
||||
new_tile->view = next_view;
|
||||
workspace_tile_update_view(new_tile,next_view);
|
||||
new_tile->workspace = curr_workspace;
|
||||
curr_workspace->focused_tile->next->prev = new_tile;
|
||||
curr_workspace->focused_tile->next = new_tile;
|
||||
|
|
@ -657,27 +653,20 @@ keybinding_cycle_views(struct cg_server *server, bool reverse, bool ipc) {
|
|||
server->curr_output->workspaces[server->curr_output->curr_workspace];
|
||||
struct cg_view *current_view = curr_workspace->focused_tile->view;
|
||||
|
||||
if(current_view == NULL) {
|
||||
current_view =
|
||||
wl_container_of(&curr_workspace->views, current_view, link);
|
||||
}
|
||||
struct cg_view *it_view, *next_view = NULL;
|
||||
if(reverse) {
|
||||
next_view = view_get_prev_view(current_view);
|
||||
} else {
|
||||
struct wl_list *it;
|
||||
it = current_view->link.next;
|
||||
while(it != ¤t_view->link) {
|
||||
if(it == &curr_workspace->views) {
|
||||
it = it->next;
|
||||
continue;
|
||||
}
|
||||
it_view = wl_container_of(it, it_view, link);
|
||||
wl_list_for_each(it_view,&curr_workspace->views,link) {
|
||||
if(!view_is_visible(it_view)) {
|
||||
next_view = it_view;
|
||||
next_view=it_view;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
wl_list_for_each_reverse(it_view,&curr_workspace->views,link) {
|
||||
if(!view_is_visible(it_view)) {
|
||||
next_view=it_view;
|
||||
break;
|
||||
}
|
||||
it = it->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -685,9 +674,6 @@ keybinding_cycle_views(struct cg_server *server, bool reverse, bool ipc) {
|
|||
return;
|
||||
}
|
||||
|
||||
/* Prevent seat_set_focus from reordering the views */
|
||||
curr_workspace->focused_tile->view = wl_container_of(
|
||||
next_view->link.prev, curr_workspace->focused_tile->view, link);
|
||||
seat_set_focus(server->seat, next_view);
|
||||
if(ipc) {
|
||||
ipc_send_event(curr_workspace->output->server,
|
||||
|
|
@ -1090,11 +1076,9 @@ keybinding_move_view_to_cycle_output(struct cg_server *server, bool reverse) {
|
|||
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);
|
||||
workspace_tile_update_view(ws->focused_tile,view);
|
||||
view->workspace = ws;
|
||||
view->tile = view->workspace->focused_tile;
|
||||
view_maximize(view, view->tile);
|
||||
seat_set_focus(server->seat, view);
|
||||
}
|
||||
int id = -1;
|
||||
|
|
@ -1238,9 +1222,9 @@ keybinding_move_view_to_output(struct cg_server *server, int output_num) {
|
|||
server->curr_output->workspaces[server->curr_output->curr_workspace]
|
||||
->focused_tile->view;
|
||||
if(view != NULL) {
|
||||
workspace_tile_update_view(server->curr_output->workspaces[server->curr_output->curr_workspace]
|
||||
->focused_tile,NULL);
|
||||
wl_list_remove(&view->link);
|
||||
server->curr_output->workspaces[server->curr_output->curr_workspace]
|
||||
->focused_tile->view = NULL;
|
||||
keybinding_cycle_views(server, false, false);
|
||||
if(server->curr_output->workspaces[server->curr_output->curr_workspace]
|
||||
->focused_tile->view == NULL) {
|
||||
|
|
@ -1255,8 +1239,7 @@ keybinding_move_view_to_output(struct cg_server *server, int output_num) {
|
|||
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);
|
||||
workspace_tile_update_view(ws->focused_tile,view);
|
||||
seat_set_focus(server->seat, view);
|
||||
}
|
||||
char *view_title = "";
|
||||
|
|
@ -1297,8 +1280,7 @@ keybinding_move_view_to_workspace(struct cg_server *server, uint32_t ws) {
|
|||
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);
|
||||
workspace_tile_update_view(ws->focused_tile,view);
|
||||
seat_set_focus(server->seat, view);
|
||||
}
|
||||
ipc_send_event(server,
|
||||
|
|
|
|||
2
output.c
2
output.c
|
|
@ -69,7 +69,7 @@ output_clear(struct cg_output *output) {
|
|||
first || output->workspaces[i]->focused_tile != tile;
|
||||
tile = tile->next) {
|
||||
first = false;
|
||||
tile->view = NULL;
|
||||
workspace_tile_update_view(tile,NULL);
|
||||
}
|
||||
struct cg_workspace *ws =
|
||||
server->curr_output
|
||||
|
|
|
|||
21
seat.c
21
seat.c
|
|
@ -986,8 +986,7 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) {
|
|||
|
||||
/* Focusing the background */
|
||||
if(view == NULL) {
|
||||
server->curr_output->workspaces[server->curr_output->curr_workspace]
|
||||
->focused_tile->view = NULL;
|
||||
workspace_tile_update_view(server->curr_output->workspaces[server->curr_output->curr_workspace]->focused_tile,NULL);
|
||||
seat->focused_view = NULL;
|
||||
if(prev_view != NULL) {
|
||||
view_activate(prev_view, false);
|
||||
|
|
@ -1000,21 +999,11 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) {
|
|||
if(view->type != CG_XWAYLAND_VIEW || xwayland_view_should_manage(view))
|
||||
#endif
|
||||
{
|
||||
/* Always resize the view, even if prev_view == view */
|
||||
struct cg_workspace *curr_workspace =
|
||||
server->curr_output
|
||||
struct cg_workspace *curr_workspace = server->curr_output
|
||||
->workspaces[server->curr_output->curr_workspace];
|
||||
view_maximize(view, curr_workspace->focused_tile);
|
||||
if(!view_is_visible(view)) {
|
||||
wl_list_remove(&view->link);
|
||||
if(curr_workspace->focused_tile->view != NULL) {
|
||||
wl_list_insert(&curr_workspace->focused_tile->view->link,
|
||||
&view->link);
|
||||
} else {
|
||||
wl_list_insert(curr_workspace->views.prev, &view->link);
|
||||
}
|
||||
curr_workspace->focused_tile->view = view;
|
||||
}
|
||||
workspace_tile_update_view(curr_workspace->focused_tile,view);
|
||||
wl_list_remove(&curr_workspace->views);
|
||||
wl_list_insert(&view->link,&curr_workspace->views);
|
||||
}
|
||||
|
||||
#if CG_HAS_XWAYLAND
|
||||
|
|
|
|||
7
view.c
7
view.c
|
|
@ -142,10 +142,7 @@ view_unmap(struct cg_view *view) {
|
|||
}
|
||||
struct cg_tile *view_tile = view_get_tile(view);
|
||||
if(view_tile != NULL) {
|
||||
view_tile->view = prev;
|
||||
if(prev != NULL) {
|
||||
view_maximize(prev, view_tile);
|
||||
}
|
||||
workspace_tile_update_view(view_tile,prev);
|
||||
}
|
||||
}
|
||||
#if CG_HAS_XWAYLAND
|
||||
|
|
@ -196,8 +193,6 @@ view_map(struct cg_view *view, struct wlr_surface *surface,
|
|||
} else
|
||||
#endif
|
||||
{
|
||||
view->tile = view->workspace->focused_tile;
|
||||
view_maximize(view, view->tile);
|
||||
wl_list_insert(&ws->views, &view->link);
|
||||
}
|
||||
seat_set_focus(output->server->seat, view);
|
||||
|
|
|
|||
16
workspace.c
16
workspace.c
|
|
@ -20,6 +20,20 @@
|
|||
#include "seat.h"
|
||||
#include "server.h"
|
||||
#include "workspace.h"
|
||||
#include "view.h"
|
||||
|
||||
void
|
||||
workspace_tile_update_view(struct cg_tile *tile, struct cg_view *view) {
|
||||
if(tile->view!=NULL) {
|
||||
wlr_scene_node_set_enabled(tile->view->scene_node,false);
|
||||
tile->view->tile=NULL;
|
||||
}
|
||||
tile->view=view;
|
||||
if(view!=NULL) {
|
||||
view_maximize(view,tile);
|
||||
wlr_scene_node_set_enabled(view->scene_node,true);
|
||||
}
|
||||
}
|
||||
|
||||
#if CG_HAS_FANALYZE
|
||||
#pragma GCC diagnostic push
|
||||
|
|
@ -42,7 +56,7 @@ full_screen_workspace_tiles(struct wlr_output_layout *layout,
|
|||
struct wlr_box *output_box = wlr_output_layout_get_box(layout, output);
|
||||
workspace->focused_tile->tile.width = output_box->width;
|
||||
workspace->focused_tile->tile.height = output_box->height;
|
||||
workspace->focused_tile->view = NULL;
|
||||
workspace_tile_update_view(workspace->focused_tile,NULL);
|
||||
workspace->focused_tile->id = *tiles_curr_id;
|
||||
++(*tiles_curr_id);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -41,5 +41,7 @@ void
|
|||
workspace_focus_tile(struct cg_workspace *ws, struct cg_tile *tile);
|
||||
void
|
||||
workspace_focus(struct cg_output *outp, int ws);
|
||||
void
|
||||
workspace_tile_update_view(struct cg_tile *tile, struct cg_view *view);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue