Apply clang-format

This commit is contained in:
project-repo 2022-09-30 21:09:51 +02:00
commit 3247d8cfd1
7 changed files with 62 additions and 40 deletions

View file

@ -476,10 +476,12 @@ resize_tile(struct cg_server *server, int hpixs, int vpixs) {
void
keybinding_workspace_fullscreen(struct cg_server *server) {
output_make_workspace_fullscreen(server->curr_output,server->curr_output->curr_workspace);
output_make_workspace_fullscreen(server->curr_output,
server->curr_output->curr_workspace);
struct cg_output *output = server->curr_output;
ipc_send_event(server,
"{\"event_name\":\"fullscreen\",\"tile_id\":\"%d\",\"workspace\":\"%d\",\"output\":\"%s\"}",
"{\"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,11 +224,13 @@ message_set_output(struct cg_output *output, const char *string,
break;
}
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(output->server->scene,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;
}
message->message=wlr_scene_buffer_create(&scene_output->scene->node,&buf->base);
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,7 +153,8 @@ handle_output_frame(struct wl_listener *listener, void *data) {
if(!output->wlr_output->enabled) {
return;
}
struct wlr_scene_output *scene_output=wlr_scene_get_scene_output(output->server->scene,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;
}
@ -292,19 +293,22 @@ output_configure(struct cg_server *server, struct cg_output *output) {
}
if(config->pos.x != -1) {
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.");
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);
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 */
/* 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);
output_make_workspace_fullscreen(output, i);
}
}
wl_list_remove(&output->link);
@ -313,17 +317,20 @@ output_configure(struct cg_server *server, struct cg_output *output) {
wlr_output_commit(wlr_output);
}
}
if(output->bg!=NULL) {
if(output->bg != NULL) {
wlr_scene_node_destroy(&output->bg->node);
output->bg=NULL;
output->bg = NULL;
}
struct wlr_scene_output *scene_output = wlr_scene_get_scene_output(output->server->scene,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);
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);
}
@ -367,14 +374,13 @@ 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;
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);
if(current_view == NULL||ws != output->curr_workspace) {
if(current_view == NULL || ws != output->curr_workspace) {
struct cg_view *it = NULL;
wl_list_for_each(it, &output->workspaces[ws]->views,
link) {
wl_list_for_each(it, &output->workspaces[ws]->views, link) {
if(view_is_visible(it)) {
current_view = it;
break;
@ -400,8 +406,6 @@ output_make_workspace_fullscreen(struct cg_output *output,int ws) {
}
}
#if CG_HAS_FANALYZE
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wanalyzer-malloc-leak"

View file

@ -56,5 +56,5 @@ 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);
output_make_workspace_fullscreen(struct cg_output *output, int ws);
#endif

30
seat.c
View file

@ -636,29 +636,39 @@ process_cursor_motion(struct cg_seat *seat, uint32_t time) {
wlr_idle_notify_activity(seat->server->idle, seat->seat);
/* Check if cursor switched tile */
struct wlr_output *c_outp = wlr_output_layout_output_at(seat->server->output_layout,seat->cursor->x,seat->cursor->y);
struct wlr_output *c_outp = wlr_output_layout_output_at(
seat->server->output_layout, seat->cursor->x, seat->cursor->y);
struct cg_output *cg_outp = NULL;
wl_list_for_each(cg_outp,&seat->server->outputs,link) {
wl_list_for_each(cg_outp, &seat->server->outputs, link) {
if(cg_outp->wlr_output == c_outp) {
break;
}
}
struct cg_tile *c_tile;
bool first=true;
bool first = true;
for(c_tile = cg_outp->workspaces[cg_outp->curr_workspace]->focused_tile;
first || c_tile != cg_outp->workspaces[cg_outp->curr_workspace]->focused_tile; c_tile = c_tile->next) {
first ||
c_tile != cg_outp->workspaces[cg_outp->curr_workspace]->focused_tile;
c_tile = c_tile->next) {
first = false;
double ox=seat->cursor->x,oy=seat->cursor->y;
wlr_output_layout_output_coords(seat->server->output_layout,c_outp,&ox,&oy);
if(c_tile->tile.x<=ox&&c_tile->tile.y<=oy&&c_tile->tile.x+c_tile->tile.width>=ox&&c_tile->tile.y+c_tile->tile.height>=oy) {
double ox = seat->cursor->x, oy = seat->cursor->y;
wlr_output_layout_output_coords(seat->server->output_layout, c_outp,
&ox, &oy);
if(c_tile->tile.x <= ox && c_tile->tile.y <= oy &&
c_tile->tile.x + c_tile->tile.width >= ox &&
c_tile->tile.y + c_tile->tile.height >= oy) {
break;
}
}
if(seat->cursor_tile != NULL && seat->cursor_tile != c_tile) {
ipc_send_event(seat->server, "{\"event_name\":\"cursor_switch_tile\",\"old_output\":\"%s\",\"old_tile\":\"%d\",\"new_output\":\"%s\",\"new_tile\":\"%d\"}",
seat->cursor_tile->workspace->output->wlr_output->name, seat->cursor_tile->id,c_outp->name,c_tile->id);
ipc_send_event(
seat->server,
"{\"event_name\":\"cursor_switch_tile\",\"old_output\":\"%s\","
"\"old_tile\":\"%d\",\"new_output\":\"%s\",\"new_tile\":\"%d\"}",
seat->cursor_tile->workspace->output->wlr_output->name,
seat->cursor_tile->id, c_outp->name, c_tile->id);
}
seat->cursor_tile=c_tile;
seat->cursor_tile = c_tile;
}
static void

View file

@ -16,8 +16,8 @@
#include <wlr/util/log.h>
#include "message.h"
#include "seat.h"
#include "output.h"
#include "seat.h"
#include "server.h"
#include "workspace.h"
@ -57,7 +57,8 @@ 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);
struct wlr_scene_output *scene_output =
wlr_scene_get_scene_output(output->server->scene, output->wlr_output);
if(scene_output == NULL) {
return NULL;
}
@ -91,8 +92,10 @@ void
workspace_free_tiles(struct cg_workspace *workspace) {
workspace->focused_tile->prev->next = NULL;
while(workspace->focused_tile != NULL) {
if(workspace->output->server->running&&workspace->output->server->seat->cursor_tile==workspace->focused_tile) {
workspace->output->server->seat->cursor_tile=NULL;
if(workspace->output->server->running &&
workspace->output->server->seat->cursor_tile ==
workspace->focused_tile) {
workspace->output->server->seat->cursor_tile = NULL;
}
struct cg_tile *next = workspace->focused_tile->next;
free(workspace->focused_tile);

View file

@ -64,7 +64,8 @@ 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);
wlr_xwayland_surface_restack(xwayland_view->xwayland_surface, NULL,
XCB_STACK_MODE_ABOVE);
}
}