logo

inaban

Unnamed repository; edit this file 'description' to name the repository.
commit: b665cef11f506e3d60cf446290d1a5aaba84f3cd
parent: 31d915640b3e4bd5770a54ff378663dc735a7da4
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  1 Jul 2019 09:16:17 +0200

Remove braces containing a oneliner

Diffstat:

Minaban.c116++++++++++++++++++++-----------------------------------------------------------
1 file changed, 29 insertions(+), 87 deletions(-)

diff --git a/inaban.c b/inaban.c @@ -16,18 +16,11 @@ static void focus_view(struct inaban_view *view, struct wlr_surface *surface) { /* Note: this function only deals with keyboard focus. */ - if(view == NULL) - { - return; - } + if(view == NULL) return; struct inaban_server *server = view->server; struct wlr_seat *seat = server->seat; struct wlr_surface *prev_surface = seat->keyboard_state.focused_surface; - if(prev_surface == surface) - { - /* Don't re-focus an already focused surface. */ - return; - } + if(prev_surface == surface) return; /* Don't re-focus an already focused surface. */ if(prev_surface) { /* @@ -90,10 +83,7 @@ handle_keybinding(struct inaban_server *server, xkb_keysym_t sym) case INABAN_MODBIND_TERMINATE: wl_display_terminate(server->wl_display); break; case INABAN_MODBIND_SWITCH: /* Cycle to the next view */ - if(wl_list_length(&server->views) < 2) - { - break; - } + if(wl_list_length(&server->views) < 2) break; struct inaban_view *current_view = wl_container_of(server->views.next, current_view, link); struct inaban_view *next_view = wl_container_of(current_view->link.next, next_view, link); focus_view(next_view, next_view->xdg_surface->surface); @@ -128,9 +118,7 @@ keyboard_handle_key(struct wl_listener *listener, void *data) /* If alt is held down and this button was _pressed_, we attempt to * process it as a compositor keybinding. */ for(int i = 0; i < nsyms; i++) - { handled = handle_keybinding(server, syms[i]); - } } if(!handled) @@ -198,10 +186,8 @@ server_new_input(struct wl_listener *listener, void *data) * communiciated to the client. In TinyWL we always have a cursor, even if * there are no pointer devices, so we always include that capability. */ uint32_t caps = WL_SEAT_CAPABILITY_POINTER; - if(!wl_list_empty(&server->keyboards)) - { - caps |= WL_SEAT_CAPABILITY_KEYBOARD; - } + if(!wl_list_empty(&server->keyboards)) caps |= WL_SEAT_CAPABILITY_KEYBOARD; + wlr_seat_set_capabilities(server->seat, caps); } @@ -214,14 +200,12 @@ seat_request_cursor(struct wl_listener *listener, void *data) struct wlr_seat_client *focused_client = server->seat->pointer_state.focused_client; /* This can be sent by any client, so we check to make sure this one is * actually has pointer focus first. */ + /* Once we've vetted the client, we can tell the cursor to use the + * provided surface as the cursor image. It will set the hardware cursor + * on the output that it's currently on and continue to do so as the + * cursor moves between outputs. */ if(focused_client == event->seat_client) - { - /* Once we've vetted the client, we can tell the cursor to use the - * provided surface as the cursor image. It will set the hardware cursor - * on the output that it's currently on and continue to do so as the - * cursor moves between outputs. */ wlr_cursor_set_surface(server->cursor, event->surface, event->hotspot_x, event->hotspot_y); - } } static bool @@ -272,10 +256,7 @@ desktop_view_at(struct inaban_server *server, struct inaban_view *view; wl_list_for_each(view, &server->views, link) { - if(view_at(view, lx, ly, surface, sx, sy)) - { - return view; - } + if(view_at(view, lx, ly, surface, sx, sy)) return view; } return NULL; } @@ -312,28 +293,19 @@ process_cursor_resize(struct inaban_server *server, uint32_t time) { y = server->grab_y + dy; height -= dy; - if(height < 1) - { - y += height; - } + if(height < 1) y += height; } else if(server->resize_edges & WLR_EDGE_BOTTOM) - { height += dy; - } if(server->resize_edges & WLR_EDGE_LEFT) { x = server->grab_x + dx; width -= dx; - if(width < 1) - { - x += width; - } + if(width < 1) x += width; } else if(server->resize_edges & WLR_EDGE_RIGHT) - { width += dx; - } + view->x = x; view->y = y; wlr_xdg_toplevel_set_size(view->xdg_surface, width, height); @@ -360,13 +332,10 @@ process_cursor_motion(struct inaban_server *server, uint32_t time) struct wlr_surface *surface = NULL; struct inaban_view *view = desktop_view_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); - if(!view) - { - /* If there's no view under the cursor, set the cursor image to a - * default. This is what makes the cursor image appear when you move it - * around the screen, not over any views. */ - wlr_xcursor_manager_set_cursor_image(server->cursor_mgr, "left_ptr", server->cursor); - } + /* If there's no view under the cursor, set the cursor image to a + * default. This is what makes the cursor image appear when you move it + * around the screen, not over any views. */ + if(!view) wlr_xcursor_manager_set_cursor_image(server->cursor_mgr, "left_ptr", server->cursor); if(surface) { bool focus_changed = seat->pointer_state.focused_surface != surface; @@ -379,12 +348,9 @@ process_cursor_motion(struct inaban_server *server, uint32_t time) * a window. */ wlr_seat_pointer_notify_enter(seat, surface, sx, sy); - if(!focus_changed) - { - /* The enter event contains coordinates, so we only need to notify - * on motion if the focus did not change. */ - wlr_seat_pointer_notify_motion(seat, time, sx, sy); - } + /* The enter event contains coordinates, so we only need to notify + * on motion if the focus did not change. */ + if(!focus_changed) wlr_seat_pointer_notify_motion(seat, time, sx, sy); } else { @@ -440,15 +406,10 @@ server_cursor_button(struct wl_listener *listener, void *data) struct inaban_view *view = desktop_view_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); if(event->state == WLR_BUTTON_RELEASED) - { - /* If you released any buttons, we exit interactive move/resize mode. */ - server->cursor_mode = INABAN_CURSOR_PASSTHROUGH; - } + server->cursor_mode = + INABAN_CURSOR_PASSTHROUGH; /* If you released any buttons, we exit interactive move/resize mode. */ else - { - /* Focus that client if the button was _pressed_ */ - focus_view(view, surface); - } + focus_view(view, surface); /* Focus that client if the button was _pressed_ */ } static void @@ -503,10 +464,7 @@ render_surface(struct wlr_surface *surface, int sx, int sy, void *data) * could have sent a pixel buffer which we copied to the GPU, or a few other * means. You don't have to worry about this, wlroots takes care of it. */ struct wlr_texture *texture = wlr_surface_get_texture(surface); - if(texture == NULL) - { - return; - } + if(texture == NULL) return; /* The view has a position in layout coordinates. If you have two displays, * one next to the other, both 1080p, a view on the rightmost display might @@ -561,10 +519,7 @@ output_frame(struct wl_listener *listener, void *data) clock_gettime(CLOCK_MONOTONIC, &now); /* wlr_output_attach_render makes the OpenGL context current. */ - if(!wlr_output_attach_render(output->wlr_output, NULL)) - { - return; - } + if(!wlr_output_attach_render(output->wlr_output, NULL)) return; /* The "effective" resolution can change if you rotate your outputs. */ int width, height; wlr_output_effective_resolution(output->wlr_output, &width, &height); @@ -579,11 +534,7 @@ output_frame(struct wl_listener *listener, void *data) struct inaban_view *view; wl_list_for_each_reverse(view, &output->server->views, link) { - if(!view->mapped) - { - /* An unmapped view should not be rendered. */ - continue; - } + if(!view->mapped) continue; /* An unmapped view should not be rendered. */ struct render_data rdata = { .output = output->wlr_output, .view = view, @@ -684,10 +635,7 @@ begin_interactive(struct inaban_view *view, enum inaban_cursor_mode mode, uint32 struct inaban_server *server = view->server; struct wlr_surface *focused_surface = server->seat->pointer_state.focused_surface; if(view->xdg_surface->surface != focused_surface) - { - /* Deny move/resize requests from unfocused clients. */ - return; - } + return; /* Deny move/resize requests from unfocused clients. */ server->grabbed_view = view; server->cursor_mode = mode; struct wlr_box geo_box; @@ -739,10 +687,7 @@ server_new_xdg_surface(struct wl_listener *listener, void *data) * client, either a toplevel (application window) or popup. */ struct inaban_server *server = wl_container_of(listener, server, new_xdg_surface); struct wlr_xdg_surface *xdg_surface = data; - if(xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) - { - return; - } + if(xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) return; /* Allocate a inaban_view for this surface */ struct inaban_view *view = calloc(1, sizeof(struct inaban_view)); @@ -948,10 +893,7 @@ main(int argc, char *argv[]) setenv("WAYLAND_DISPLAY", socket, true); if(startup_cmd) { - if(fork() == 0) - { - execl("/bin/sh", "/bin/sh", "-c", startup_cmd, (void *)NULL); - } + if(fork() == 0) execl("/bin/sh", "/bin/sh", "-c", startup_cmd, (void *)NULL); } /* Run the Wayland event loop. This does not return until you exit the * compositor. Starting the backend rigged up all of the necessary event