* For example, the xml structure <a><b><c></c></b></a> would return the
* name c.b.a
*/
-char *nodename(xmlNode *node, char *buf, int len);
+char *nodename(xmlNode * node, char *buf, int len);
#endif /* __LABWC_NODENAME_H */
#include "theme.h"
struct rcxml {
-
/* core */
bool xdg_shell_server_side_deco;
int gap;
};
#define LAB_NR_LAYERS (4)
+
struct output {
struct wl_list link; /* server::outputs */
struct server *server;
struct wl_listener destroy;
struct wl_listener frame;
};
+
#undef LAB_NR_LAYERS
enum view_type {
NULL
};
-
static enum action_type
action_type_from_str(const char *action_name)
{
- for (size_t i = 1; action_names[i] != NULL; i++) {
+ for (size_t i = 1; action_names[i]; i++) {
if (!strcasecmp(action_name, action_names[i])) {
return i;
}
wlr_log(WLR_DEBUG, "Handling action %s (%u) with arg %s",
action_names[action->type], action->type, action->arg);
- /* Refetch view because it may have been changed due to the previous action */
+ /*
+ * Refetch view because it may have been changed due to the
+ * previous action
+ */
view = activator_or_focused_view(activator, server);
switch (action->type) {
view_snap_to_edge(view, action->arg);
break;
case ACTION_TYPE_NEXT_WINDOW:
- server->cycle_view =
- desktop_cycle_view(server, server->cycle_view, LAB_CYCLE_DIR_FORWARD);
+ server->cycle_view = desktop_cycle_view(server,
+ server->cycle_view, LAB_CYCLE_DIR_FORWARD);
osd_update(server);
break;
case ACTION_TYPE_PREVIOUS_WINDOW:
- server->cycle_view =
- desktop_cycle_view(server, server->cycle_view, LAB_CYCLE_DIR_BACKWARD);
+ server->cycle_view = desktop_cycle_view(server,
+ server->cycle_view, LAB_CYCLE_DIR_BACKWARD);
osd_update(server);
break;
case ACTION_TYPE_RECONFIGURE:
case ACTION_TYPE_RESIZE:
view = desktop_view_at_cursor(server);
if (view) {
- interactive_begin(view, LAB_INPUT_STATE_RESIZE, resize_edges);
+ interactive_begin(view, LAB_INPUT_STATE_RESIZE,
+ resize_edges);
}
break;
case ACTION_TYPE_NONE:
- wlr_log(WLR_ERROR, "Not executing unknown action with arg %s", action->arg);
+ wlr_log(WLR_ERROR,
+ "Not executing unknown action with arg %s",
+ action->arg);
break;
default:
/*
* action_names and action_type being out of sync or by
* adding a new action without installing a handler here.
*/
- wlr_log(WLR_ERROR, "Not executing invalid action (%u) with arg %s"
- " This is a BUG. Please report.", action->type, action->arg);
+ wlr_log(WLR_ERROR,
+ "Not executing invalid action (%u) with arg %s"
+ " This is a BUG. Please report.",
+ action->type, action->arg);
}
}
}
#include <ctype.h>
#include "common/buf.h"
-
static void
strip_curly_braces(char *s)
{
} else {
/* just add one character at a time */
if (new.alloc <= new.len + 1) {
- new.alloc = new.alloc * 3/2 + 16;
+ new.alloc = new.alloc * 3 / 2 + 16;
new.buf = realloc(new.buf, new.alloc);
}
new.buf[new.len++] = s->buf[i];
if (!prefix) {
continue;
}
- gchar **prefixes;
+ gchar * *prefixes;
prefixes = g_strsplit(prefix, ":", -1);
- for (gchar **p = prefixes; *p; p++) {
+ for (gchar * *p = prefixes; *p; p++) {
ctx->build_path_fn(ctx, *p, d.path);
if (debug) {
fprintf(stderr, "%s\n", ctx->buf);
k->modifiers |= modifier;
} else {
xkb_keysym_t sym = xkb_keysym_to_lower(
- xkb_keysym_from_name(symname, XKB_KEYSYM_CASE_INSENSITIVE));
+ xkb_keysym_from_name(symname,
+ XKB_KEYSYM_CASE_INSENSITIVE));
if (sym == XKB_KEY_NoSymbol) {
wlr_log(WLR_ERROR, "unknown keybind (%s)", symname);
free(k);
static void
fill_libinput_category(char *nodename, char *content)
{
-
if (!strcmp(nodename, "category.device.libinput")) {
current_libinput_category = libinput_category_create();
}
LIBINPUT_CONFIG_TAP_DISABLED;
} else if (!strcasecmp(nodename, "tapButtonMap")) {
if (!strcmp(content, "lrm")) {
- current_libinput_category->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
+ current_libinput_category->tap_button_map =
+ LIBINPUT_CONFIG_TAP_MAP_LRM;
} else if (!strcmp(content, "lmr")) {
- current_libinput_category->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LMR;
+ current_libinput_category->tap_button_map =
+ LIBINPUT_CONFIG_TAP_MAP_LMR;
} else {
wlr_log(WLR_ERROR, "invalid tapButtonMap");
}
} else if (!strcasecmp(nodename, "accelProfile")) {
- current_libinput_category->accel_profile = get_accel_profile(content);
+ current_libinput_category->accel_profile =
+ get_accel_profile(content);
} else if (!strcasecmp(nodename, "middleEmulation")) {
current_libinput_category->middle_emu = get_bool(content) ?
LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED :
void
rcxml_finish(void)
{
-
zfree(rc.font_name_activewindow);
zfree(rc.font_name_menuitem);
zfree(rc.font_name_osd);
{
struct wl_client *inhibiting_client =
seat->active_client_while_inhibited;
- return (inhibiting_client != NULL) &&
- inhibiting_client != wl_resource_get_client(resource);
+ return inhibiting_client
+ && inhibiting_client != wl_resource_get_client(resource);
}
static void
wl_list_remove(&constraint->destroy.link);
if (seat->current_constraint == wlr_constraint) {
- if (seat->constraint_commit.link.next != NULL) {
+ if (seat->constraint_commit.link.next) {
wl_list_remove(&seat->constraint_commit.link);
}
wl_list_init(&seat->constraint_commit.link);
seat->current_constraint = constraint;
- if (constraint == NULL) {
+ if (!constraint) {
wl_list_init(&seat->constraint_commit.link);
return;
}
continue;
case MOUSE_ACTION_DRAG:
if (mousebind->pressed_in_context) {
- /* Swallow the release event as well as the press one */
+ /*
+ * Swallow the release event as well as
+ * the press one
+ */
activated_any = true;
- activated_any_frame |= mousebind->context == LAB_SSD_FRAME;
+ activated_any_frame |=
+ mousebind->context == LAB_SSD_FRAME;
}
continue;
default:
&& mousebind->button == button
&& modifiers == mousebind->modifiers) {
switch (mousebind->mouse_event) {
- case MOUSE_ACTION_DRAG: /* FALLTHROUGH */
+ case MOUSE_ACTION_DRAG: /* fallthrough */
case MOUSE_ACTION_CLICK:
/*
* DRAG and CLICK actions will be processed on
* counted as a DOUBLECLICK.
*/
if (!double_click) {
- /* Swallow the press event as well as the release one */
+ /*
+ * Swallow the press event as well as
+ * the release one
+ */
activated_any = true;
- activated_any_frame |= mousebind->context == LAB_SSD_FRAME;
+ activated_any_frame |=
+ mousebind->context == LAB_SSD_FRAME;
mousebind->pressed_in_context = true;
}
continue;
server->grabbed_view = NULL;
}
- /* Focus surface under cursor and force updating the cursor icon */
+ /*
+ * Focus surface under cursor and force updating the
+ * cursor icon
+ */
cursor_rebase(&server->seat, event->time_msec, true);
return;
}
if (server->input_mode == LAB_INPUT_STATE_MENU) {
if (view_area != LAB_SSD_MENU) {
- /* We close the menu on release so we don't leak a stray release */
+ /*
+ * We close the menu on release so we don't leak a stray
+ * release
+ */
close_menu = true;
} else if (menu_call_actions(node)) {
- /* Action was successfull, may fail if item just opens a submenu */
+ /*
+ * Action was successfull, may fail if item just opens a
+ * submenu
+ */
close_menu = true;
}
return;
} else if (cursor_y <= area->y + snap_range) {
if (rc.snap_top_maximize) {
view_maximize(view, true);
- /* When unmaximizing later on restore original position */
- view->unmaximized_geometry.x = view->server->grab_box.x;
- view->unmaximized_geometry.y = view->server->grab_box.y;
+ /*
+ * When unmaximizing later on restore
+ * original position
+ */
+ view->unmaximized_geometry.x =
+ view->server->grab_box.x;
+ view->unmaximized_geometry.y =
+ view->server->grab_box.y;
} else {
view_snap_to_edge(view, "up");
}
return false;
}
-
static void
keyboard_modifiers_notify(struct wl_listener *listener, void *data)
{
if (server->cycle_view) {
struct wlr_keyboard_key_event *event = data;
struct wlr_keyboard *keyboard = &seat->keyboard_group->keyboard;
- if ((event->state == WL_KEYBOARD_KEY_STATE_RELEASED)
+ if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED
&& !any_modifiers_pressed(keyboard)) {
/* end cycle */
desktop_focus_and_activate_view(&server->seat,
unsigned int vt = syms[i] - XKB_KEY_XF86Switch_VT_1 + 1;
if (vt >= 1 && vt <= 12) {
change_vt(server, vt);
- /* don't send any key events to clients when changing tty */
+ /*
+ * Don't send any key events to clients when
+ * changing tty
+ */
return true;
}
}
}
if (!ignore) {
- server->cycle_view =
- desktop_cycle_view(server, server->cycle_view,
- backwards ? LAB_CYCLE_DIR_BACKWARD : LAB_CYCLE_DIR_FORWARD);
+ enum lab_cycle_dir dir = backwards
+ ? LAB_CYCLE_DIR_BACKWARD
+ : LAB_CYCLE_DIR_FORWARD;
+ server->cycle_view = desktop_cycle_view(server,
+ server->cycle_view, dir);
osd_update(server);
}
}
struct menuitem *item;
wl_list_for_each (item, &menu->menuitems, link) {
if (item->submenu) {
- wlr_scene_node_set_enabled(&item->submenu->scene_tree->node, false);
+ wlr_scene_node_set_enabled(
+ &item->submenu->scene_tree->node, false);
close_all_submenus(item->submenu);
}
}
item->parent->selection.menu = item->submenu;
}
-
bool
menu_call_actions(struct wlr_scene_node *node)
{
get_formatted_app_id(struct view *view)
{
char *s = (char *)view_get_string_prop(view, "app_id");
- if (s == NULL) {
+ if (!s) {
return NULL;
}
/* remove the first two nodes of 'org.' strings */
if (wlr_output->non_desktop) {
wlr_log(WLR_DEBUG, "Not configuring non-desktop output");
if (server->drm_lease_manager) {
- wlr_drm_lease_v1_manager_offer_output(server->drm_lease_manager,
- wlr_output);
+ wlr_drm_lease_v1_manager_offer_output(
+ server->drm_lease_manager, wlr_output);
}
return;
}
struct server *server =
wl_container_of(listener, server, output_layout_change);
- bool done_changing = server->pending_output_config == NULL;
+ bool done_changing = !server->pending_output_config;
if (done_changing) {
struct wlr_output_configuration_v1 *config =
create_output_config(server);
}
/* reset the flags */
- flags.left = flags.top = flags.right = flags.bottom = 0;
+ flags.left = 0;
+ flags.top = 0;
+ flags.right = 0;
+ flags.bottom = 0;
}
}
return;
}
wl_list_for_each(output, &server->outputs, link) {
-
mgeom = output_usable_area_in_layout_coords(output);
if (!wlr_box_intersection(&intersection, &vgeom, &mgeom)
}
/* reset the flags */
- flags.left = flags.top = flags.right = flags.bottom = 0;
+ flags.left = 0;
+ flags.top = 0;
+ flags.right = 0;
+ flags.bottom = 0;
}
}
} else {
wlr_log(WLR_INFO, "tap configured");
libinput_device_config_tap_set_enabled(libinput_dev, dc->tap);
- libinput_device_config_tap_set_button_map(libinput_dev, dc->tap_button_map);
+ libinput_device_config_tap_set_button_map(libinput_dev,
+ dc->tap_button_map);
}
if (libinput_device_config_scroll_has_natural_scroll(libinput_dev) <= 0
static struct wlr_output *
output_by_name(struct server *server, const char *name)
{
- assert(name != NULL);
+ assert(name);
struct output *output;
wl_list_for_each(output, &server->outputs, link) {
if (!strcasecmp(output->wlr_output->name, name)) {
wlr_log(WLR_INFO, "map pointer to output %s\n",
dev->pointer->output_name);
struct wlr_output *output = NULL;
- if (dev->pointer->output_name != NULL) {
+ if (dev->pointer->output_name) {
output = output_by_name(seat->server, dev->pointer->output_name);
}
wlr_cursor_map_input_to_output(seat->cursor, dev, output);
wlr_log(WLR_INFO, "map touch to output %s\n",
dev->pointer->output_name);
struct wlr_output *output = NULL;
- if (dev->pointer->output_name != NULL) {
+ if (dev->pointer->output_name) {
output = output_by_name(seat->server, dev->pointer->output_name);
}
wlr_cursor_map_input_to_output(seat->cursor, dev, output);
struct wlr_seat_client *previous_ptr_client =
seat->seat->pointer_state.focused_client;
- if (previous_ptr_client &&
- (previous_ptr_client->client != active_client)) {
+ if (previous_ptr_client && previous_ptr_client->client != active_client) {
wlr_seat_pointer_clear_focus(seat->seat);
}
}
}
}
-
-
static void
handle_input_inhibit(struct wl_listener *listener, void *data)
{
}
static void
-handle_drm_lease_request(struct wl_listener *listener, void *data) {
- /* We only offer non-desktop outputs, but in the future we might want to do
- * more logic here. */
+handle_drm_lease_request(struct wl_listener *listener, void *data)
+{
+ /*
+ * We only offer non-desktop outputs, but in the future we might want to do
+ * more logic here.
+ */
struct wlr_drm_lease_request_v1 *req = data;
struct wlr_drm_lease_v1 *lease = wlr_drm_lease_request_v1_grant(req);
server->foreign_toplevel_manager =
wlr_foreign_toplevel_manager_v1_create(server->wl_display);
- server->drm_lease_manager=
- wlr_drm_lease_v1_manager_create(server->wl_display, server->backend);
+ server->drm_lease_manager = wlr_drm_lease_v1_manager_create(
+ server->wl_display, server->backend);
if (server->drm_lease_manager) {
server->drm_lease_request.notify = handle_drm_lease_request;
wl_signal_add(&server->drm_lease_manager->events.request,
void
server_finish(struct server *server)
{
-
/* TODO: clean up various scene_tree nodes */
#if HAVE_XWAYLAND
wlr_xwayland_destroy(server->xwayland);
rect = lab_wlr_scene_get_rect(part->node);
switch (part->type) {
case LAB_SSD_PART_LEFT:
- wlr_scene_rect_set_size(rect, theme->border_width, height);
+ wlr_scene_rect_set_size(rect,
+ theme->border_width, height);
continue;
case LAB_SSD_PART_RIGHT:
- wlr_scene_rect_set_size(rect, theme->border_width, height);
- wlr_scene_node_set_position(
- part->node, theme->border_width + width, 0);
+ wlr_scene_rect_set_size(rect,
+ theme->border_width, height);
+ wlr_scene_node_set_position(part->node,
+ theme->border_width + width, 0);
continue;
case LAB_SSD_PART_BOTTOM:
- wlr_scene_rect_set_size(rect, full_width, theme->border_width);
- wlr_scene_node_set_position(part->node, 0, height);
+ wlr_scene_rect_set_size(rect,
+ full_width, theme->border_width);
+ wlr_scene_node_set_position(part->node,
+ 0, height);
continue;
case LAB_SSD_PART_TOP:
wlr_scene_rect_set_size(rect,
- width - 2 * BUTTON_WIDTH, theme->border_width);
+ width - 2 * BUTTON_WIDTH,
+ theme->border_width);
continue;
default:
continue;
if (part_box.width != result_box.width
|| part_box.height != result_box.height) {
/* Partly visible */
- wlr_scene_rect_set_size(rect, result_box.width, result_box.height);
+ wlr_scene_rect_set_size(rect, result_box.width,
+ result_box.height);
wlr_scene_node_set_position(part->node,
target->x + (result_box.x - part_box.x),
target->y + (result_box.y - part_box.y));
wl_list_for_each(part, &subtree->parts, link) {
switch (part->type) {
case LAB_SSD_PART_TITLEBAR:
- wlr_scene_rect_set_size(lab_wlr_scene_get_rect(part->node),
+ wlr_scene_rect_set_size(
+ lab_wlr_scene_get_rect(part->node),
width - BUTTON_WIDTH * BUTTON_COUNT,
theme->title_height);
continue;
case LAB_SSD_BUTTON_CLOSE:
if (is_direct_child(part->node, subtree)) {
wlr_scene_node_set_position(part->node,
- width - BUTTON_WIDTH * 1, -theme->border_width);
+ width - BUTTON_WIDTH * 1,
+ -theme->border_width);
}
continue;
default:
return;
}
struct wlr_box box = output_usable_area_in_layout_coords(output);
- if (box.height == output->wlr_output->height && output->wlr_output->scale != 1) {
+ if (box.height == output->wlr_output->height
+ && output->wlr_output->scale != 1) {
box.height /= output->wlr_output->scale;
}
- if (box.width == output->wlr_output->width && output->wlr_output->scale != 1) {
+ if (box.width == output->wlr_output->width
+ && output->wlr_output->scale != 1) {
box.width /= output->wlr_output->scale;
}
view_apply_unmaximized_geometry(struct view *view)
{
struct wlr_output_layout *layout = view->server->output_layout;
- if (wlr_output_layout_intersects(layout, NULL, &view->unmaximized_geometry)) {
+ if (wlr_output_layout_intersects(layout, NULL,
+ &view->unmaximized_geometry)) {
/* restore to original geometry */
view_move_resize(view, view->unmaximized_geometry);
} else {
view_set_fullscreen(struct view *view, bool fullscreen,
struct wlr_output *wlr_output)
{
- if (fullscreen == (view->fullscreen != NULL)) {
+ if (fullscreen != !view->fullscreen) {
return;
}
if (view->impl->set_fullscreen) {
}
struct border border = view_border(view);
struct wlr_box usable = output_usable_area_in_layout_coords(output);
- if (usable.height == output->wlr_output->height && output->wlr_output->scale != 1) {
+ if (usable.height == output->wlr_output->height
+ && output->wlr_output->scale != 1) {
usable.height /= output->wlr_output->scale;
}
- if (usable.width == output->wlr_output->width && output->wlr_output->scale != 1) {
+ if (usable.width == output->wlr_output->width
+ && output->wlr_output->scale != 1) {
usable.width /= output->wlr_output->scale;
}
{
struct border border = view_border(view);
struct wlr_box usable = output_usable_area_in_layout_coords(output);
- if (usable.height == output->wlr_output->height && output->wlr_output->scale != 1) {
+ if (usable.height == output->wlr_output->height
+ && output->wlr_output->scale != 1) {
usable.height /= output->wlr_output->scale;
}
- if (usable.width == output->wlr_output->width && output->wlr_output->scale != 1) {
+ if (usable.width == output->wlr_output->width
+ && output->wlr_output->scale != 1) {
usable.width /= output->wlr_output->scale;
}
* geometry.{x,y} seems to be greater than zero. We filter on that
* on the assumption that this will remain true.
*/
- if (view->xdg_surface->current.geometry.x || view->xdg_surface->current.geometry.y) {
+ struct wlr_xdg_surface_state *current = &view->xdg_surface->current;
+ if (current->geometry.x || current->geometry.y) {
return false;
}
return true;
view->h = size.height;
/* padding changes with maximize/unmaximize */
- view->padding.top = view->padding.bottom = size.y;
- view->padding.left = view->padding.right = size.x;
+ view->padding.top = size.y;
+ view->padding.bottom = size.y;
+ view->padding.left = size.x;
+ view->padding.right = size.x;
uint32_t serial = view->pending_move_resize.configure_serial;
if (serial > 0 && serial >= view->xdg_surface->current.configure_serial) {
{
struct wlr_box padding;
wlr_xdg_surface_get_geometry(view->xdg_surface, &padding);
- view->padding.top = view->padding.bottom = padding.y;
- view->padding.left = view->padding.right = padding.x;
+ view->padding.top = padding.y;
+ view->padding.bottom = padding.y;
+ view->padding.left = padding.x;
+ view->padding.right = padding.x;
}
static void
static bool
istopmost(struct view *view)
{
- return view->xdg_surface->toplevel->parent == NULL;
+ return !view->xdg_surface->toplevel->parent;
}
static struct view *