Merge remote-tracking branch 'github/startup_failed' into development

This commit is contained in:
project-repo 2022-09-25 09:48:49 +02:00
commit a8148690d6
8 changed files with 99 additions and 61 deletions

View file

@ -476,42 +476,10 @@ resize_tile(struct cg_server *server, int hpixs, int vpixs) {
void
keybinding_workspace_fullscreen(struct cg_server *server) {
struct cg_view *current_view = seat_get_focus(server->seat);
output_make_workspace_fullscreen(server->curr_output,server->curr_output->curr_workspace);
struct cg_output *output = server->curr_output;
struct cg_view *it = NULL, *tmp = NULL;
wl_list_for_each_safe(
it, tmp, &output->workspaces[output->curr_workspace]->views, link) {
if(view_is_visible(it)) {
if(current_view == NULL) {
current_view = it;
}
if(&it->link !=
&output->workspaces[output->curr_workspace]->views) {
seat_set_focus(server->seat,it);
}
}
}
workspace_free_tiles(output->workspaces[output->curr_workspace]);
if(full_screen_workspace_tiles(server->output_layout, output->wlr_output,
output->workspaces[output->curr_workspace],
&server->tiles_curr_id) != 0) {
wlr_log(WLR_ERROR, "Failed to allocate space for fullscreen workspace");
return;
}
struct cg_view *it_view;
wl_list_for_each(it_view,
&output->workspaces[output->curr_workspace]->views, link) {
it_view->tile =
output->workspaces[output->curr_workspace]->focused_tile;
}
seat_set_focus(server->seat, current_view);
ipc_send_event(output->server,
"{\"event_name\":\"fullscreen\",\"tile_id\":\"%d\","
"\"workspace\":\"%d\",\"output\":\"%s\"}",
ipc_send_event(server,
"{\"event_name\":\"fullscreen\",\"tile_id\":\"%d\",\"workspace\":\"%d\",\"output\":\"%s\"}",
output->workspaces[output->curr_workspace]->focused_tile->id,
output->workspaces[output->curr_workspace]->num + 1,
output->wlr_output->name);

View file

@ -224,8 +224,11 @@ message_set_output(struct cg_output *output, const char *string,
break;
}
message->message =
wlr_scene_buffer_create(&output->scene_output->scene->node, &buf->base);
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(output->server->scene,output->wlr_output);
if(scene_output == NULL) {
return;
}
message->message=wlr_scene_buffer_create(&scene_output->scene->node,&buf->base);
wlr_scene_node_raise_to_top(&message->message->node);
wlr_scene_node_set_enabled(&message->message->node, true);
struct wlr_box *outp_box = wlr_output_layout_get_box(

View file

@ -153,11 +153,15 @@ handle_output_frame(struct wl_listener *listener, void *data) {
if(!output->wlr_output->enabled) {
return;
}
wlr_scene_output_commit(output->scene_output);
struct wlr_scene_output *scene_output=wlr_scene_get_scene_output(output->server->scene,output->wlr_output);
if(scene_output == NULL) {
return;
}
wlr_scene_output_commit(scene_output);
struct timespec now = {0};
clock_gettime(CLOCK_MONOTONIC, &now);
wlr_scene_output_send_frame_done(output->scene_output, &now);
wlr_scene_output_send_frame_done(scene_output, &now);
}
struct cg_output_config *
@ -171,7 +175,7 @@ output_find_config(struct cg_server *server, struct wlr_output *output) {
return NULL;
}
static void
static int
output_set_mode(struct wlr_output *output, int width, int height,
float refresh_rate) {
int mhz = (int)(refresh_rate * 1000);
@ -180,7 +184,7 @@ output_set_mode(struct wlr_output *output, int width, int height,
wlr_log(WLR_DEBUG, "Assigning custom mode to %s", output->name);
wlr_output_set_custom_mode(output, width, height,
refresh_rate > 0 ? mhz : 0);
return;
return 0;
}
struct wlr_output_mode *mode, *best = NULL;
@ -204,6 +208,7 @@ output_set_mode(struct wlr_output *output, int width, int height,
wlr_log(WLR_DEBUG, "Assigning configured mode to %s", output->name);
}
wlr_output_set_mode(output, best);
wlr_output_commit(output);
if(!wlr_output_test(output)) {
wlr_log(WLR_ERROR,
"Unable to assign configured mode to %s, picking arbitrary "
@ -215,11 +220,16 @@ output_set_mode(struct wlr_output *output, int width, int height,
continue;
}
wlr_output_set_mode(output, mode);
wlr_output_commit(output);
if(wlr_output_test(output)) {
break;
}
}
if(!wlr_output_test(output)) {
return 1;
}
}
return 0;
}
void
@ -277,36 +287,43 @@ output_configure(struct cg_server *server, struct cg_output *output) {
wlr_output_enable(wlr_output, false);
wlr_output_commit(wlr_output);
} else {
wl_list_remove(&output->link);
if(config->priority != -1) {
output->priority = config->priority;
}
if(config->pos.x != -1) {
output_set_mode(wlr_output, config->pos.width,
config->pos.height, config->refresh_rate);
if(output_set_mode(wlr_output, config->pos.width,
config->pos.height, config->refresh_rate)!=0) {
wlr_log(WLR_ERROR,"Setting output mode failed, disabling output.");
output_clear(output);
wl_list_insert(&server->disabled_outputs,&output->link);
wlr_output_enable(wlr_output, false);
wlr_output_commit(wlr_output);
return;
}
wlr_output_layout_add(server->output_layout, wlr_output,
config->pos.x, config->pos.y);
/* Since the size of the output may have changed, we reinitialize all workspaces with a fullscreen layout */
for(unsigned int i = 0; i < output->server->nws; ++i) {
output_make_workspace_fullscreen(output,i);
}
}
wl_list_remove(&output->link);
output_insert(server, output);
wlr_output_enable(wlr_output, true);
wlr_output_commit(wlr_output);
}
}
struct wlr_scene_output *scene_output;
wl_list_for_each(scene_output, &output->server->scene->outputs, link) {
if(scene_output->output == wlr_output) {
output->scene_output = scene_output;
break;
}
}
if(output->bg != NULL) {
if(output->bg!=NULL) {
wlr_scene_node_destroy(&output->bg->node);
output->bg=NULL;
}
output->bg = wlr_scene_rect_create(
&output->scene_output->scene->node, output->wlr_output->width,
output->wlr_output->height, server->bg_color);
struct wlr_box *box =
wlr_output_layout_get_box(server->output_layout, output->wlr_output);
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(output->server->scene,output->wlr_output);
if(scene_output == NULL) {
return;
}
output->bg=wlr_scene_rect_create(&scene_output->scene->node, output->wlr_output->width,output->wlr_output->height, server->bg_color);
struct wlr_box *box = wlr_output_layout_get_box(
server->output_layout, output->wlr_output);
wlr_scene_node_set_position(&output->bg->node, box->x, box->y);
wlr_scene_node_lower_to_bottom(&output->bg->node);
}
@ -349,6 +366,43 @@ handle_output_mode(struct wl_listener *listener, void *data) {
}
}
void
output_make_workspace_fullscreen(struct cg_output *output,int ws) {
struct cg_server *server=output->server;
struct cg_view *current_view = seat_get_focus(server->seat);
/* We are focused on the background */
if(current_view == NULL||ws != output->curr_workspace) {
struct cg_view *it = NULL;
wl_list_for_each(it, &output->workspaces[ws]->views,
link) {
if(view_is_visible(it)) {
current_view = it;
break;
}
}
}
workspace_free_tiles(output->workspaces[ws]);
if(full_screen_workspace_tiles(server->output_layout, output->wlr_output,
output->workspaces[ws],
&server->tiles_curr_id) != 0) {
wlr_log(WLR_ERROR, "Failed to allocate space for fullscreen workspace");
return;
}
struct cg_view *it_view;
wl_list_for_each(it_view, &output->workspaces[ws]->views, link) {
it_view->tile = output->workspaces[ws]->focused_tile;
}
if(ws == output->curr_workspace) {
seat_set_focus(server->seat, current_view);
}
}
#if CG_HAS_FANALYZE
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"

View file

@ -12,7 +12,6 @@ struct wlr_surface;
struct cg_output {
struct cg_server *server;
struct wlr_output *wlr_output;
struct wlr_scene_output *scene_output;
struct wlr_scene_rect *bg;
struct wl_listener mode;
@ -56,5 +55,6 @@ void
output_configure(struct cg_server *server, struct cg_output *output);
void
output_set_window_title(struct cg_output *output, const char *title);
void
output_make_workspace_fullscreen(struct cg_output *output,int ws);
#endif

6
seat.c
View file

@ -656,6 +656,12 @@ handle_cursor_motion(struct wl_listener *listener, void *data) {
event->delta_y);
process_cursor_motion(seat, event->time_msec);
wlr_idle_notify_activity(seat->server->idle, seat->seat);
struct wlr_output *c_outp = wlr_output_layout_output_at(seat->server->output_layout,seat->cursor->x,seat->cursor->y);
if(seat->cursor_output != NULL && seat->cursor_output != c_outp) {
ipc_send_event(seat->server, "{\"event_name\":\"cursor_switch_output\",\"old_output\":\"%s\",\"new_output\":\"%s\"}",
seat->cursor_output->name, c_outp->name);
}
seat->cursor_output=c_outp;
}
static void

1
seat.h
View file

@ -28,6 +28,7 @@ struct cg_seat {
uint16_t num_touch;
struct wlr_cursor *cursor;
struct wlr_output *cursor_output;
struct wlr_xcursor_manager *xcursor_manager;
struct wl_listener cursor_motion;
struct wl_listener cursor_motion_absolute;

View file

@ -56,10 +56,13 @@ full_screen_workspace(struct cg_output *output) {
if(!workspace) {
return NULL;
}
struct wlr_scene_output *scene_output=wlr_scene_get_scene_output(output->server->scene,output->wlr_output);
if(scene_output == NULL) {
return NULL;
}
workspace->server = output->server;
workspace->num = -1;
workspace->scene =
wlr_scene_tree_create(&output->scene_output->scene->node);
workspace->scene = wlr_scene_tree_create(&scene_output->scene->node);
if(full_screen_workspace_tiles(output->server->output_layout,
output->wlr_output, workspace,
&output->server->tiles_curr_id) != 0) {

View file

@ -63,6 +63,9 @@ static void
activate(struct cg_view *view, bool activate) {
struct cg_xwayland_view *xwayland_view = xwayland_view_from_view(view);
wlr_xwayland_surface_activate(xwayland_view->xwayland_surface, activate);
if(activate) {
wlr_xwayland_surface_restack(xwayland_view->xwayland_surface, NULL, XCB_STACK_MODE_ABOVE);
}
}
static void