Merge branch 'master' into mouseemu

This commit is contained in:
Simon Long 2024-10-20 11:56:14 +01:00 committed by GitHub
commit 06129fe1ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
178 changed files with 10958 additions and 2691 deletions

View file

@ -7,6 +7,7 @@
struct view;
struct server;
struct cursor_context;
struct action {
struct wl_list link; /*
@ -34,8 +35,16 @@ void action_arg_from_xml_node(struct action *action, const char *nodename, const
bool actions_contain_toggle_keybinds(struct wl_list *action_list);
/**
* actions_run() - Run actions.
* @activator: Target view to apply actions (e.g. Maximize, Focus etc.).
* NULL is allowed, in which case the focused/hovered view is used.
* @ctx: Set for action invocations via mousebindings. Used to get the
* direction of resize or the position of the window menu button for ShowMenu
* action.
*/
void actions_run(struct view *activator, struct server *server,
struct wl_list *actions, uint32_t resize_edges);
struct wl_list *actions, struct cursor_context *ctx);
void action_free(struct action *action);
void action_list_free(struct wl_list *action_list);

View file

@ -32,21 +32,55 @@
struct lab_data_buffer {
struct wlr_buffer base;
cairo_t *cairo;
void *data;
cairo_surface_t *surface; /* optional */
cairo_t *cairo; /* optional */
void *data; /* owned by surface if surface != NULL */
uint32_t format;
size_t stride;
bool free_on_destroy;
uint32_t unscaled_width;
uint32_t unscaled_height;
/*
* The logical size of the surface in layout pixels.
* The raw pixel data may be larger or smaller.
*/
uint32_t logical_width;
uint32_t logical_height;
};
/* Create a buffer which creates a new cairo CAIRO_FORMAT_ARGB32 surface */
struct lab_data_buffer *buffer_create_cairo(uint32_t width, uint32_t height,
float scale, bool free_on_destroy);
/*
* Create a buffer which holds (and takes ownership of) an existing
* CAIRO_FORMAT_ARGB32 image surface.
*
* The logical size is set to the surface size in pixels, ignoring
* device scale. No cairo context is created.
*/
struct lab_data_buffer *buffer_adopt_cairo_surface(cairo_surface_t *surface);
/* Create a buffer which wraps a given DRM_FORMAT_ARGB8888 pointer */
struct lab_data_buffer *buffer_create_wrap(void *pixel_data, uint32_t width,
uint32_t height, uint32_t stride, bool free_on_destroy);
/*
* Create a buffer which holds a new CAIRO_FORMAT_ARGB32 image surface.
* Additionally create a cairo context for drawing to the surface.
*/
struct lab_data_buffer *buffer_create_cairo(uint32_t logical_width,
uint32_t logical_height, float scale);
/*
* Create a buffer from an image surface, for display as an icon.
*
* The surface is either adopted by the buffer (which takes ownership),
* or copied and then destroyed.
*
* This function allows non-ARGB32 source images and converts to
* CAIRO_FORMAT_ARGB32 if needed.
*/
struct lab_data_buffer *buffer_convert_cairo_surface_for_icon(
cairo_surface_t *surface, uint32_t icon_size, float scale);
/*
* Create a buffer which holds (and takes ownership of) raw pixel data
* in pre-multiplied ARGB32 format.
*
* The logical size is set to the width and height of the pixel data.
* No cairo surface or context is created.
*/
struct lab_data_buffer *buffer_create_from_data(void *pixel_data, uint32_t width,
uint32_t height, uint32_t stride);
#endif /* LABWC_BUFFER_H */

View file

@ -1,9 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_BUTTON_PNG_H
#define LABWC_BUTTON_PNG_H
struct lab_data_buffer;
void button_png_load(const char *button_name, struct lab_data_buffer **buffer);
#endif /* LABWC_BUTTON_PNG_H */

View file

@ -1,10 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_BUTTON_SVG_H
#define LABWC_BUTTON_SVG_H
struct lab_data_buffer;
void button_svg_load(const char *button_name, struct lab_data_buffer **buffer,
int size);
#endif /* LABWC_BUTTON_SVG_H */

View file

@ -1,22 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_BUTTON_XBM_H
#define LABWC_BUTTON_XBM_H
struct lab_data_buffer;
/**
* button_xbm_from_bitmap() - create button from monochrome bitmap
* @bitmap: bitmap data array in hexadecimal xbm format
* @buffer: cairo-surface-buffer to create
* @rgba: color
*
* Example bitmap: char button[6] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
*/
void button_xbm_from_bitmap(const char *bitmap, struct lab_data_buffer **buffer,
float *rgba);
/* button_xbm_load - Convert xbm file to buffer with cairo surface */
void button_xbm_load(const char *button_name, struct lab_data_buffer **buffer,
float *rgba);
#endif /* LABWC_BUTTON_XBM_H */

View file

@ -1,17 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_BUTTON_COMMON_H
#define LABWC_BUTTON_COMMON_H
#include <stddef.h>
/**
* button_filename() - Get full filename for button.
* @name: The name of the button (for example 'iconify.xbm').
* @buf: Buffer to fill with the full filename
* @len: Length of buffer
*
* Example return value: /usr/share/themes/Numix/openbox-3/iconify.xbm
*/
void button_filename(const char *name, char *buf, size_t len);
#endif /* LABWC_BUTTON_COMMON_H */

View file

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_ARRAY_H
#define LABWC_ARRAY_H
#include <stdio.h>
#include <stdlib.h>
#include <wayland-server-core.h>
/*
@ -41,4 +43,34 @@ wl_array_len(struct wl_array *array)
pos && (const char *)pos >= (const char *)(array)->data; \
(pos)--)
/**
* array_add() - add item to wl_array and exit on allocation error
* @_arr: wl_array to add the item to
* @_val: the item to add to the array
*
* Let us illustrate the function of this macro by an example:
*
* uint32_t value = 5;
* array_add(array, value);
*
* ...is the equivalent of the code below which is how you would
* otherwise use the wl_array API:
*
* uint32_t *elm = wl_array_add(array, sizeof(uint32_t));
* if (!elm) {
* perror("failed to allocate memory");
* exit(EXIT_FAILURE);
* }
* *elm = value;
*/
#define array_add(_arr, _val) do { \
__typeof__(_val) *_entry = wl_array_add( \
(_arr), sizeof(__typeof__(_val))); \
if (!_entry) { \
perror("Failed to allocate memory"); \
exit(EXIT_FAILURE); \
} \
*_entry = (_val); \
} while (0)
#endif /* LABWC_ARRAY_H */

26
include/common/box.h Normal file
View file

@ -0,0 +1,26 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_BOX_H
#define LABWC_BOX_H
#include <wlr/util/box.h>
bool box_contains(struct wlr_box *box_super, struct wlr_box *box_sub);
bool box_intersects(struct wlr_box *box_a, struct wlr_box *box_b);
/* Returns the bounding box of 2 boxes */
void box_union(struct wlr_box *box_dest, struct wlr_box *box_a,
struct wlr_box *box_b);
/*
* Fits and centers a content box (width & height) within a bounding box
* (max_width & max_height). The content box is downscaled if necessary
* (preserving aspect ratio) but not upscaled.
*
* The returned x & y coordinates are the centered content position
* relative to the top-left corner of the bounding box.
*/
struct wlr_box box_fit_within(int width, int height, int max_width,
int max_height);
#endif /* LABWC_BOX_H */

View file

@ -43,6 +43,13 @@ void buf_expand_tilde(struct buf *s);
*/
void buf_expand_shell_variables(struct buf *s);
/**
* buf_add_fmt - add format string to C string buffer
* @s: buffer
* @fmt: format string to be added
*/
void buf_add_fmt(struct buf *s, const char *fmt, ...);
/**
* buf_add - add data to C string buffer
* @s: buffer

View file

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_DIRECTION_H
#define LABWC_DIRECTION_H
#include "view.h"
enum wlr_direction direction_from_view_edge(enum view_edge edge);
enum wlr_direction direction_get_opposite(enum wlr_direction direction);
#endif /* LABWC_DIRECTION_H */

View file

@ -6,7 +6,8 @@ struct lab_data_buffer;
enum font_slant {
FONT_SLANT_NORMAL = 0,
FONT_SLANT_ITALIC
FONT_SLANT_ITALIC,
FONT_SLANT_OBLIQUE
};
enum font_weight {

View file

@ -7,6 +7,7 @@
struct wlr_scene_node;
struct wlr_surface;
struct wlr_scene_output;
struct wlr_output_state;
struct wlr_surface *lab_wlr_surface_from_node(struct wlr_scene_node *node);
@ -18,6 +19,7 @@ struct wlr_surface *lab_wlr_surface_from_node(struct wlr_scene_node *node);
struct wlr_scene_node *lab_wlr_scene_get_prev_node(struct wlr_scene_node *node);
/* A variant of wlr_scene_output_commit() that respects wlr_output->pending */
bool lab_wlr_scene_output_commit(struct wlr_scene_output *scene_output);
bool lab_wlr_scene_output_commit(struct wlr_scene_output *scene_output,
struct wlr_output_state *output_state);
#endif /* LABWC_SCENE_HELPERS_H */

19
include/common/set.h Normal file
View file

@ -0,0 +1,19 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_SET_H
#define LABWC_SET_H
#include <stdbool.h>
#include <stdint.h>
#define LAB_SET_MAX_SIZE 16
struct lab_set {
uint32_t values[LAB_SET_MAX_SIZE];
int size;
};
bool lab_set_contains(struct lab_set *set, uint32_t value);
void lab_set_add(struct lab_set *set, uint32_t value);
void lab_set_remove(struct lab_set *set, uint32_t value);
#endif /* LABWC_SET_H */

View file

@ -322,6 +322,16 @@ static struct mouse_combos {
.button = "Left",
.event = "Click",
.action = "ToggleMaximize",
}, {
.context = "Shade",
.button = "Left",
.event = "Click",
.action = "ToggleShade",
}, {
.context = "AllDesktops",
.button = "Left",
.event = "Click",
.action = "ToggleOmnipresent",
}, {
.context = "Maximize",
.button = "Right",
@ -366,6 +376,32 @@ static struct mouse_combos {
.name = "atCursor",
.value = "no",
},
}, {
.context = "Icon",
.button = "Left",
.event = "Click",
.action = "ShowMenu",
.attributes[0] = {
.name = "menu",
.value = "client-menu",
},
.attributes[1] = {
.name = "atCursor",
.value = "no",
},
}, {
.context = "Icon",
.button = "Right",
.event = "Click",
.action = "ShowMenu",
.attributes[0] = {
.name = "menu",
.value = "client-menu",
},
.attributes[1] = {
.name = "atCursor",
.value = "no",
},
}, {
.context = "Root",
.button = "Left",

View file

@ -18,6 +18,7 @@ struct keybind {
xkb_keycode_t keycodes[MAX_KEYCODES];
size_t keycodes_len;
int keycodes_layout;
bool allow_when_locked;
struct wl_list actions; /* struct action.link */
struct wl_list link; /* struct rcxml.keybinds */
bool on_release;

View file

@ -31,6 +31,7 @@ struct libinput_category {
int click_method; /* -1 or libinput_config_click_method */
int send_events_mode; /* -1 or libinput_config_send_events_mode */
bool have_calibration_matrix;
double scroll_factor;
float calibration_matrix[6];
};

View file

@ -11,15 +11,18 @@
#include "common/font.h"
#include "config/touch.h"
#include "config/tablet.h"
#include "config/tablet-tool.h"
#include "config/libinput.h"
#include "resize-indicator.h"
#include "ssd.h"
#include "theme.h"
enum view_placement_policy {
LAB_PLACE_INVALID = 0,
LAB_PLACE_CENTER,
LAB_PLACE_CURSOR,
LAB_PLACE_AUTOMATIC
LAB_PLACE_AUTOMATIC,
LAB_PLACE_CASCADE,
};
enum adaptive_sync_mode {
@ -28,6 +31,13 @@ enum adaptive_sync_mode {
LAB_ADAPTIVE_SYNC_FULLSCREEN,
};
enum tearing_mode {
LAB_TEARING_DISABLED = 0,
LAB_TEARING_ENABLED,
LAB_TEARING_FULLSCREEN,
LAB_TEARING_FULLSCREEN_FORCED,
};
enum tiling_events_mode {
LAB_TILING_EVENTS_NEVER = 0,
LAB_TILING_EVENTS_REGION = 1 << 0,
@ -36,6 +46,11 @@ enum tiling_events_mode {
(LAB_TILING_EVENTS_REGION | LAB_TILING_EVENTS_EDGE),
};
struct title_button {
enum ssd_part_type type;
struct wl_list link;
};
struct usable_area_override {
struct border margin;
char *output;
@ -52,9 +67,12 @@ struct rcxml {
bool xdg_shell_server_side_deco;
int gap;
enum adaptive_sync_mode adaptive_sync;
bool allow_tearing;
enum tearing_mode allow_tearing;
bool reuse_output_mode;
enum view_placement_policy placement_policy;
bool xwayland_persistence;
int placement_cascade_offset_x;
int placement_cascade_offset_y;
/* focus */
bool focus_follow_mouse;
@ -63,11 +81,17 @@ struct rcxml {
/* theme */
char *theme_name;
char *icon_theme_name;
struct wl_list title_buttons_left;
struct wl_list title_buttons_right;
int corner_radius;
bool show_title;
bool title_layout_loaded;
bool ssd_keep_border;
bool shadows_enabled;
struct font font_activewindow;
struct font font_inactivewindow;
struct font font_menuheader;
struct font font_menuitem;
struct font font_osd;
@ -87,7 +111,6 @@ struct rcxml {
/* mouse */
long doubleclick_time; /* in ms */
struct wl_list mousebinds; /* struct mousebind.link */
double scroll_factor;
/* touch tablet */
struct wl_list touch_configs;
@ -101,6 +124,10 @@ struct rcxml {
uint16_t button_map_count;
struct button_map_entry button_map[BUTTON_MAP_MAX];
} tablet;
struct tablet_tool_config {
enum motion motion;
double relative_motion_sensitivity;
} tablet_tool;
/* libinput */
struct wl_list libinput_categories;
@ -108,6 +135,8 @@ struct rcxml {
/* resistance */
int screen_edge_strength;
int window_edge_strength;
int unsnap_threshold;
int unmaximize_threshold;
/* window snapping */
int snap_edge_range;

View file

@ -4,6 +4,12 @@
struct server;
/**
* session_run_script - run a named session script (or, in merge-config mode,
* all named session scripts) from the XDG path.
*/
void session_run_script(const char *script);
/**
* session_environment_init - set environment variables based on <key>=<value>
* pairs in `${XDG_CONFIG_DIRS:-/etc/xdg}/labwc/environment` with user override

View file

@ -0,0 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_TABLET_TOOL_CONFIG_H
#define LABWC_TABLET_TOOL_CONFIG_H
#include <stdint.h>
enum motion {
LAB_TABLET_MOTION_ABSOLUTE = 0,
LAB_TABLET_MOTION_RELATIVE,
};
enum motion tablet_parse_motion(const char *name);
#endif /* LABWC_TABLET_TOOL_CONFIG_H */

12
include/icon-loader.h Normal file
View file

@ -0,0 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_ICON_LOADER_H
#define LABWC_ICON_LOADER_H
struct server;
void icon_loader_init(struct server *server);
void icon_loader_finish(struct server *server);
struct lab_data_buffer *icon_loader_lookup(struct server *server,
const char *app_id, int size, float scale);
#endif /* LABWC_ICON_LOADER_H */

10
include/img/img-png.h Normal file
View file

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_IMG_PNG_H
#define LABWC_IMG_PNG_H
struct lab_data_buffer;
void img_png_load(const char *filename, struct lab_data_buffer **buffer,
int size, float scale);
#endif /* LABWC_IMG_PNG_H */

10
include/img/img-svg.h Normal file
View file

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_IMG_SVG_H
#define LABWC_IMG_SVG_H
struct lab_data_buffer;
void img_svg_load(const char *filename, struct lab_data_buffer **buffer,
int size, float scale);
#endif /* LABWC_IMG_SVG_H */

22
include/img/img-xbm.h Normal file
View file

@ -0,0 +1,22 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_IMG_XBM_H
#define LABWC_IMG_XBM_H
struct lab_data_buffer;
/**
* img_xbm_from_bitmap() - create button from monochrome bitmap
* @bitmap: bitmap data array in hexadecimal xbm format
* @buffer: cairo-surface-buffer to create
* @rgba: color
*
* Example bitmap: char button[6] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
*/
void img_xbm_from_bitmap(const char *bitmap, struct lab_data_buffer **buffer,
float *rgba);
/* img_xbm_load - Convert xbm file to buffer with cairo surface */
void img_xbm_load(const char *filename, struct lab_data_buffer **buffer,
float *rgba);
#endif /* LABWC_IMG_XBM_H */

10
include/img/img-xpm.h Normal file
View file

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_IMG_XPM_H
#define LABWC_IMG_XPM_H
struct lab_data_buffer;
void img_xpm_load(const char *filename, struct lab_data_buffer **buffer,
int size, float scale);
#endif /* LABWC_IMG_XPM_H */

View file

@ -11,7 +11,7 @@ struct seat;
struct server;
struct wlr_surface;
struct wlr_scene_node;
enum wlr_button_state;
enum wl_pointer_button_state;
/* Cursors used internally by labwc */
enum lab_cursors {
@ -142,15 +142,18 @@ bool cursor_process_button_release(struct seat *seat, uint32_t button, uint32_t
* Finishes cursor button release. The return value indicates if an interactive
* move/resize had been finished. Should be called after notifying a client.
*/
bool cursor_finish_button_release(struct seat *seat);
bool cursor_finish_button_release(struct seat *seat, uint32_t button);
void cursor_init(struct seat *seat);
void cursor_reload(struct seat *seat);
void cursor_emulate_move(struct seat *seat,
struct wlr_input_device *device,
double dx, double dy, uint32_t time_msec);
void cursor_emulate_move_absolute(struct seat *seat,
struct wlr_input_device *device,
double x, double y, uint32_t time_msec);
void cursor_emulate_button(struct seat *seat,
uint32_t button, enum wlr_button_state state, uint32_t time_msec);
uint32_t button, enum wl_pointer_button_state state, uint32_t time_msec);
void cursor_finish(struct seat *seat);
#endif /* LABWC_CURSOR_H */

View file

@ -36,7 +36,7 @@ struct drawing_tablet_pad {
struct wl_list link; /* seat.tablet_pads */
};
void tablet_pad_init(struct seat *seat, struct wlr_input_device *wlr_input_device);
void tablet_pad_create(struct seat *seat, struct wlr_input_device *wlr_input_device);
void tablet_pad_attach_tablet(struct seat *seat);
void tablet_pad_enter_surface(struct seat *seat, struct wlr_surface *wlr_surface);

View file

@ -17,7 +17,7 @@ struct drawing_tablet_tool {
struct wl_list link; /* seat.tablet_tools */
};
void tablet_tool_init(struct seat *seat,
void tablet_tool_create(struct seat *seat,
struct wlr_tablet_tool *wlr_tablet_tool);
bool tablet_tool_has_focused_surface(struct seat *seat);

View file

@ -14,7 +14,8 @@ struct drawing_tablet {
struct seat *seat;
struct wlr_tablet *tablet;
struct wlr_tablet_v2_tablet *tablet_v2;
double x, y;
enum motion motion_mode;
double x, y, dx, dy;
double distance;
double pressure;
double tilt_x, tilt_y;
@ -22,15 +23,13 @@ struct drawing_tablet {
double slider;
double wheel_delta;
struct {
struct wl_listener proximity;
struct wl_listener axis;
struct wl_listener tip;
struct wl_listener button;
struct wl_listener destroy;
} handlers;
struct wl_list link; /* seat.tablets */
};
void tablet_init(struct seat *seat, struct wlr_input_device *wlr_input_device);
void tablet_init(struct seat *seat);
void tablet_finish(struct seat *seat);
void tablet_create(struct seat *seat, struct wlr_input_device *wlr_input_device);
#endif /* LABWC_TABLET_H */

View file

@ -44,6 +44,7 @@
#include <wlr/types/wlr_input_method_v2.h>
#include <wlr/types/wlr_tablet_v2.h>
#include <wlr/util/log.h>
#include "common/set.h"
#include "config/keybind.h"
#include "config/rcxml.h"
#include "input/cursor.h"
@ -71,6 +72,8 @@ enum input_mode {
struct input {
struct wlr_input_device *wlr_input_device;
struct seat *seat;
/* Set for pointer/touch devices */
double scroll_factor;
struct wl_listener destroy;
struct wl_list link; /* seat.inputs */
};
@ -127,9 +130,8 @@ struct seat {
struct input_method_relay *input_method_relay;
/**
* pressed view/surface/node will usually be NULL and is only set on
* button press while the mouse is over a view or surface, and reset
* to NULL on button release.
* This is usually zeroed and is only set on button press while the
* mouse is over a view or surface, and zeroed on button release.
* It is used to send cursor motion events to a surface even though
* the cursor has left the surface in the meantime.
*
@ -142,13 +144,9 @@ struct seat {
*
* Both (view && !surface) and (surface && !view) are possible.
*/
struct {
struct view *view;
struct wlr_scene_node *node;
struct wlr_surface *surface;
struct wlr_surface *toplevel;
uint32_t resize_edges;
} pressed;
struct cursor_context pressed;
struct lab_set bound_buttons;
struct {
bool active;
@ -164,7 +162,6 @@ struct seat {
/* Used to prevent region snapping when starting a move with A-Left */
bool region_prevent_snap;
struct wl_client *active_client_while_inhibited;
struct wl_list inputs;
struct wl_listener new_input;
struct wl_listener focus_change;
@ -193,6 +190,11 @@ struct seat {
struct wl_listener touch_motion;
struct wl_listener touch_frame;
struct wl_listener tablet_tool_proximity;
struct wl_listener tablet_tool_axis;
struct wl_listener tablet_tool_tip;
struct wl_listener tablet_tool_button;
struct wl_list tablets;
struct wl_list tablet_tools;
struct wl_list tablet_pads;
@ -210,6 +212,12 @@ struct seat {
struct lab_data_buffer;
struct workspace;
enum lab_cycle_dir {
LAB_CYCLE_DIR_NONE,
LAB_CYCLE_DIR_FORWARD,
LAB_CYCLE_DIR_BACKWARD,
};
struct server {
struct wl_display *wl_display;
struct wl_event_loop *wl_event_loop; /* Can be used for timer events */
@ -220,11 +228,12 @@ struct server {
struct wlr_backend *backend;
} headless;
struct wlr_session *session;
struct wlr_linux_dmabuf_v1 *linux_dmabuf;
struct wlr_xdg_shell *xdg_shell;
struct wlr_layer_shell_v1 *layer_shell;
struct wl_listener new_xdg_surface;
struct wl_listener new_xdg_toplevel;
struct wl_listener new_layer_surface;
struct wl_listener kde_server_decoration;
@ -236,12 +245,9 @@ struct server {
struct wl_listener xwayland_new_surface;
#endif
struct wlr_input_inhibit_manager *input_inhibit;
struct wl_listener input_inhibit_activate;
struct wl_listener input_inhibit_deactivate;
struct wlr_xdg_activation_v1 *xdg_activation;
struct wl_listener xdg_activation_request;
struct wl_listener xdg_activation_new_token;
struct wl_list views;
struct wl_list unmanaged_surfaces;
@ -249,11 +255,14 @@ struct server {
struct seat seat;
struct wlr_scene *scene;
struct wlr_scene_output_layout *scene_layout;
bool direct_scanout_enabled;
/* cursor interactive */
enum input_mode input_mode;
struct view *grabbed_view;
/* Cursor position when interactive move/resize is requested */
double grab_x, grab_y;
/* View geometry when interactive move/resize is requested */
struct wlr_box grab_box;
uint32_t resize_edges;
@ -294,9 +303,16 @@ struct server {
struct wlr_scene_tree *menu_tree;
/* Workspaces */
struct wl_list workspaces; /* struct workspace.link */
struct workspace *workspace_current;
struct workspace *workspace_last;
struct {
struct wl_list all; /* struct workspace.link */
struct workspace *current;
struct workspace *last;
struct lab_cosmic_workspace_manager *cosmic_manager;
struct lab_cosmic_workspace_group *cosmic_group;
struct {
struct wl_listener layout_output_added;
} on;
} workspaces;
struct wl_list outputs;
struct wl_listener new_output;
@ -315,6 +331,8 @@ struct server {
*/
int pending_output_layout_change;
struct wl_listener renderer_lost;
struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
struct wl_listener gamma_control_set_gamma;
@ -349,6 +367,8 @@ struct server {
struct wlr_scene_tree *preview_parent;
struct wlr_scene_node *preview_anchor;
struct multi_rect *preview_outline;
enum lab_cycle_dir initial_direction;
bool initial_keybind_contained_shift;
} osd_state;
struct theme *theme;
@ -356,6 +376,8 @@ struct server {
struct menu *menu_current;
struct wl_list menus;
struct icon_loader *icon_loader;
pid_t primary_client_pid;
};
@ -365,6 +387,7 @@ struct output {
struct wl_list link; /* server.outputs */
struct server *server;
struct wlr_output *wlr_output;
struct wlr_output_state pending;
struct wlr_scene_output *scene_output;
struct wlr_scene_tree *layer_tree[LAB_NR_LAYERS];
struct wlr_scene_tree *layer_popup_tree;
@ -383,6 +406,8 @@ struct output {
bool leased;
bool gamma_lut_changed;
uint32_t nr_tearing_failures;
};
#undef LAB_NR_LAYERS
@ -421,7 +446,7 @@ void foreign_toplevel_update_outputs(struct view *view);
* - optionally raise above other views
*
* It's okay to call this function even if the view isn't mapped or the
* session is locked/input is inhibited; it will simply do nothing.
* session is locked; it will simply do nothing.
*/
void desktop_focus_view(struct view *view, bool raise);
@ -434,6 +459,7 @@ void desktop_focus_view_or_surface(struct seat *seat, struct view *view,
void desktop_arrange_all_views(struct server *server);
void desktop_focus_output(struct output *output);
void warp_cursor(struct view *view);
struct view *desktop_topmost_focusable_view(struct server *server);
/**
@ -442,12 +468,6 @@ struct view *desktop_topmost_focusable_view(struct server *server);
*/
void desktop_update_top_layer_visiblity(struct server *server);
enum lab_cycle_dir {
LAB_CYCLE_DIR_NONE,
LAB_CYCLE_DIR_FORWARD,
LAB_CYCLE_DIR_BACKWARD,
};
/**
* desktop_cycle_view - return view to 'cycle' to
* @start_view: reference point for finding next view to cycle to
@ -478,12 +498,21 @@ void seat_focus_surface(struct seat *seat, struct wlr_surface *surface);
void seat_focus_lock_surface(struct seat *seat, struct wlr_surface *surface);
void seat_set_focus_layer(struct seat *seat, struct wlr_layer_surface_v1 *layer);
void seat_set_pressed(struct seat *seat, struct view *view,
struct wlr_scene_node *node, struct wlr_surface *surface,
struct wlr_surface *toplevel, uint32_t resize_edges);
void seat_set_pressed(struct seat *seat, struct cursor_context *ctx);
void seat_reset_pressed(struct seat *seat);
void seat_output_layout_changed(struct seat *seat);
/**
* interactive_anchor_to_cursor() - repositions the geometry to remain
* underneath the cursor when its size changes during interactive move.
* This function also resizes server->grab_box and repositions it to remain
* underneath server->grab_{x,y}.
*
* geo->{width,height} are provided by the caller.
* geo->{x,y} are computed by this function.
*/
void interactive_anchor_to_cursor(struct server *server, struct wlr_box *geo);
void interactive_begin(struct view *view, enum input_mode mode, uint32_t edges);
void interactive_finish(struct view *view);
void interactive_cancel(struct view *view);
@ -497,27 +526,44 @@ struct output *output_from_wlr_output(struct server *server,
struct output *output_from_name(struct server *server, const char *name);
struct output *output_nearest_to(struct server *server, int lx, int ly);
struct output *output_nearest_to_cursor(struct server *server);
/**
* output_get_adjacent() - get next output, in a given direction,
* from a given output
*
* @output: reference output
* @edge: direction in which to look for the nearest output
* @wrap: if true, wrap around at layout edge
*
* Note: if output is NULL, the output nearest the cursor will be used as the
* reference instead.
*/
struct output *output_get_adjacent(struct output *output,
enum view_edge edge, bool wrap);
bool output_is_usable(struct output *output);
void output_update_usable_area(struct output *output);
void output_update_all_usable_areas(struct server *server, bool layout_changed);
bool output_get_tearing_allowance(struct output *output);
struct wlr_box output_usable_area_in_layout_coords(struct output *output);
struct wlr_box output_usable_area_scaled(struct output *output);
void handle_output_power_manager_set_mode(struct wl_listener *listener,
void *data);
void output_enable_adaptive_sync(struct wlr_output *output, bool enabled);
/**
* output_max_scale() - get maximum scale factor of all usable outputs.
* Used when loading/rendering resources (e.g. icons) that may be
* displayed on any output.
*/
float output_max_scale(struct server *server);
void new_tearing_hint(struct wl_listener *listener, void *data);
void server_init(struct server *server);
void server_start(struct server *server);
void server_finish(struct server *server);
/*
* wlroots "input inhibitor" extension (required for swaylock) blocks
* any client other than the requesting client from receiving events
*/
bool input_inhibit_blocks_surface(struct seat *seat,
struct wl_resource *resource);
void create_constraint(struct wl_listener *listener, void *data);
void constrain_cursor(struct server *server, struct wlr_pointer_constraint_v1
*constraint);

View file

@ -32,6 +32,7 @@ struct lab_layer_popup {
struct wl_listener commit;
struct wl_listener destroy;
struct wl_listener new_popup;
struct wl_listener reposition;
};
void layers_init(struct server *server);

View file

@ -20,5 +20,6 @@ bool output_wants_magnification(struct output *output);
void magnify(struct output *output, struct wlr_buffer *output_buffer,
struct wlr_box *damage);
bool is_magnify_on(void);
void magnify_reset(void);
#endif /* LABWC_MAGNIFIER_H */

View file

@ -27,6 +27,12 @@ struct menu_scene {
struct scaled_font_buffer *buffer;
};
enum menuitem_type {
LAB_MENU_ITEM = 0,
LAB_MENU_SEPARATOR_LINE,
LAB_MENU_TITLE,
};
struct menuitem {
struct wl_list actions;
char *execute;
@ -34,11 +40,14 @@ struct menuitem {
struct menu *parent;
struct menu *submenu;
bool selectable;
enum menuitem_type type;
int height;
int native_width;
struct wlr_scene_tree *tree;
struct menu_scene normal;
struct menu_scene selected;
struct menu_pipe_context *pipe_ctx;
struct view *client_list_view; /* used by internal client-list */
struct wl_list link; /* menu.menuitems */
};
@ -46,7 +55,6 @@ struct menuitem {
struct menu {
char *id;
char *label;
int item_height;
struct menu *parent;
struct {
@ -128,4 +136,7 @@ void menu_close_root(struct server *server);
/* menu_reconfigure - reload theme and content */
void menu_reconfigure(struct server *server);
void update_client_list_combined_menu(struct server *server);
void update_client_send_to_menu(struct server *server);
#endif /* LABWC_MENU_H */

34
include/output-state.h Normal file
View file

@ -0,0 +1,34 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_OUTPUT_STATE_H
#define LABWC_OUTPUT_STATE_H
#include <stdbool.h>
struct output;
struct wlr_output;
void output_state_init(struct output *output);
/* Forward port of removed functions */
bool wlr_output_test(struct wlr_output *wlr_output);
bool wlr_output_commit(struct wlr_output *wlr_output);
void wlr_output_enable(struct wlr_output *wlr_output, bool enabled);
void wlr_output_set_mode(struct wlr_output *wlr_output,
struct wlr_output_mode *mode);
void wlr_output_set_custom_mode(struct wlr_output *wlr_output,
int32_t width, int32_t height, int32_t refresh);
void wlr_output_set_scale(struct wlr_output *wlr_output, float scale);
void wlr_output_set_transform(struct wlr_output *wlr_output,
enum wl_output_transform transform);
void wlr_output_enable_adaptive_sync(struct wlr_output *wlr_output,
bool enabled);
#endif // LABWC_OUTPUT_STATE_H

View file

@ -0,0 +1,61 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_PROTOCOLS_COSMIC_WORKSPACES_INTERNAL_H
#define LABWC_PROTOCOLS_COSMIC_WORKSPACES_INTERNAL_H
struct lab_cosmic_workspace;
struct lab_cosmic_workspace_group;
struct lab_cosmic_workspace_manager;
enum pending_change {
/* group events */
CW_PENDING_WS_CREATE = 1 << 0,
/* ws events*/
CW_PENDING_WS_ACTIVATE = 1 << 1,
CW_PENDING_WS_DEACTIVATE = 1 << 2,
CW_PENDING_WS_REMOVE = 1 << 3,
};
struct transaction {
uint32_t change;
struct wl_list link;
};
struct transaction_workspace {
struct transaction base;
struct lab_cosmic_workspace *workspace;
};
struct transaction_group {
struct transaction base;
struct lab_cosmic_workspace_group *group;
char *new_workspace_name;
};
struct session_context {
int ref_count;
struct wl_list transactions;
};
struct wl_resource_addon {
struct session_context *ctx;
void *data;
};
struct wl_resource_addon *resource_addon_create(struct session_context *ctx);
void transaction_add_workspace_ev(struct lab_cosmic_workspace *ws,
struct wl_resource *resource, enum pending_change change);
void transaction_add_workspace_group_ev(struct lab_cosmic_workspace_group *group,
struct wl_resource *resource, enum pending_change change,
const char *new_workspace_name);
void resource_addon_destroy(struct wl_resource_addon *addon);
void group_output_send_initial_state(struct lab_cosmic_workspace_group *group,
struct wl_resource *group_resource);
void manager_schedule_done_event(struct lab_cosmic_workspace_manager *manager);
#endif /* LABWC_PROTOCOLS_COSMIC_WORKSPACES_INTERNAL_H */

View file

@ -0,0 +1,94 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef LABWC_PROTOCOLS_COSMIC_WORKSPACES_H
#define LABWC_PROTOCOLS_COSMIC_WORKSPACES_H
#include <stdbool.h>
#include <wayland-server-core.h>
struct wlr_output;
struct lab_cosmic_workspace_manager {
struct wl_global *global;
struct wl_list groups;
uint32_t caps;
struct wl_event_source *idle_source;
struct wl_event_loop *event_loop;
struct {
struct wl_listener display_destroy;
} on;
struct wl_list resources;
};
struct lab_cosmic_workspace_group {
struct lab_cosmic_workspace_manager *manager;
struct wl_list workspaces;
struct wl_array capabilities;
struct {
struct wl_signal create_workspace;
struct wl_signal destroy;
} events;
struct wl_list link;
struct wl_list outputs;
struct wl_list resources;
};
struct lab_cosmic_workspace {
struct lab_cosmic_workspace_group *group;
char *name;
struct wl_array coordinates;
struct wl_array capabilities;
uint32_t state; /* enum lab_cosmic_workspace_state */
uint32_t state_pending; /* enum lab_cosmic_workspace_state */
struct {
struct wl_signal activate;
struct wl_signal deactivate;
struct wl_signal remove;
struct wl_signal destroy;
} events;
struct wl_list link;
struct wl_list resources;
};
enum lab_cosmic_workspace_caps {
CW_CAP_NONE = 0,
CW_CAP_GRP_ALL = 0x000000ff,
CW_CAP_WS_ALL = 0x0000ff00,
/* group caps */
CW_CAP_GRP_WS_CREATE = 1 << 0,
/* workspace caps */
CW_CAP_WS_ACTIVATE = 1 << 8,
CW_CAP_WS_DEACTIVATE = 1 << 9,
CW_CAP_WS_REMOVE = 1 << 10,
};
struct lab_cosmic_workspace_manager *lab_cosmic_workspace_manager_create(
struct wl_display *display, uint32_t caps, uint32_t version);
struct lab_cosmic_workspace_group *lab_cosmic_workspace_group_create(
struct lab_cosmic_workspace_manager *manager);
void lab_cosmic_workspace_group_output_enter(
struct lab_cosmic_workspace_group *group, struct wlr_output *output);
void lab_cosmic_workspace_group_output_leave(
struct lab_cosmic_workspace_group *group, struct wlr_output *output);
void lab_cosmic_workspace_group_destroy(struct lab_cosmic_workspace_group *group);
struct lab_cosmic_workspace *lab_cosmic_workspace_create(struct lab_cosmic_workspace_group *group);
void lab_cosmic_workspace_set_name(struct lab_cosmic_workspace *workspace, const char *name);
void lab_cosmic_workspace_set_active(struct lab_cosmic_workspace *workspace, bool enabled);
void lab_cosmic_workspace_set_urgent(struct lab_cosmic_workspace *workspace, bool enabled);
void lab_cosmic_workspace_set_hidden(struct lab_cosmic_workspace *workspace, bool enabled);
void lab_cosmic_workspace_set_coordinates(struct lab_cosmic_workspace *workspace,
struct wl_array *coordinates);
void lab_cosmic_workspace_destroy(struct lab_cosmic_workspace *workspace);
#endif /* LABWC_PROTOCOLS_COSMIC_WORKSPACES_H */

View file

@ -3,7 +3,12 @@
#define LABWC_RESISTANCE_H
#include "labwc.h"
void resistance_move_apply(struct view *view, double *x, double *y);
/**
* resistance_unsnap_apply() - Apply resistance when dragging a
* maximized/tiled window. Returns true when the view needs to be un-tiled.
*/
bool resistance_unsnap_apply(struct view *view, int *x, int *y);
void resistance_move_apply(struct view *view, int *x, int *y);
void resistance_resize_apply(struct view *view, struct wlr_box *new_view_geo);
#endif /* LABWC_RESISTANCE_H */

View file

@ -10,6 +10,8 @@ struct server;
struct session_lock_manager {
struct server *server;
struct wlr_session_lock_manager_v1 *wlr_manager;
/* View re-focused on unlock */
struct view *last_active_view;
struct wlr_surface *focused;
/*
* When not locked: lock=NULL, locked=false
@ -19,7 +21,7 @@ struct session_lock_manager {
struct wlr_session_lock_v1 *lock;
bool locked;
struct wl_list session_lock_outputs;
struct wl_list lock_outputs;
struct wl_listener new_lock;
struct wl_listener destroy;

View file

@ -18,13 +18,16 @@
struct ssd_button {
struct view *view;
enum ssd_part_type type;
struct wlr_scene_node *normal;
struct wlr_scene_node *hover;
struct wlr_scene_node *toggled;
struct wlr_scene_node *toggled_hover;
struct wlr_scene_node *background;
struct wlr_scene_tree *icon_tree;
struct wlr_scene_tree *hover_tree;
/*
* Bitmap of lab_button_state that represents a combination of
* hover/toggled/rounded states.
*/
uint8_t state_set;
/*
* Button nodes for each combination of hover/toggled/rounded states.
* nodes[state_set] should be displayed.
*/
struct wlr_scene_node *nodes[LAB_BS_ALL + 1];
struct wl_listener destroy;
};
@ -49,13 +52,33 @@ struct ssd {
* don't update things we don't have to.
*/
struct {
bool was_maximized; /* To un-round corner buttons and toggle icon on maximize */
/* Button icons need to be swapped on shade or omnipresent toggles */
bool was_shaded;
bool was_omnipresent;
/*
* Corners need to be (un)rounded and borders need be shown/hidden
* when toggling maximization, and the button needs to be swapped on
* maximization toggles.
*/
bool was_maximized;
/*
* Corners need to be (un)rounded but borders should be kept shown when
* the window is (un)tiled and notified about it or when the window may
* become so small that only a squared scene-rect can be used to render
* such a small titlebar.
*/
bool was_squared;
struct wlr_box geometry;
struct ssd_state_title {
char *text;
struct ssd_state_title_width active;
struct ssd_state_title_width inactive;
} title;
char *app_id;
} state;
/* An invisible area around the view which allows resizing */
@ -99,9 +122,6 @@ struct ssd_part {
/* This part represented in scene graph */
struct wlr_scene_node *node;
/* Targeted geometry. May be NULL */
struct wlr_box *geometry;
struct wl_list link;
};
@ -124,19 +144,12 @@ struct ssd_part *add_scene_rect(
struct ssd_part *add_scene_buffer(
struct wl_list *list, enum ssd_part_type type,
struct wlr_scene_tree *parent, struct wlr_buffer *buffer, int x, int y);
struct ssd_part *add_scene_button(
struct wl_list *part_list, enum ssd_part_type type,
struct wlr_scene_tree *parent, float *bg_color,
struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer,
int x, struct view *view);
void add_toggled_icon(struct ssd_button *button, struct wl_list *part_list,
enum ssd_part_type type, struct wlr_buffer *icon_buffer,
struct wlr_buffer *hover_buffer);
struct ssd_part *add_scene_button_corner(
struct wl_list *part_list, enum ssd_part_type type,
enum ssd_part_type corner_type, struct wlr_scene_tree *parent,
struct wlr_buffer *corner_buffer, struct wlr_buffer *icon_buffer,
struct wlr_buffer *hover_buffer, int x, struct view *view);
struct ssd_part *add_scene_button(struct wl_list *part_list,
enum ssd_part_type type, struct wlr_scene_tree *parent,
struct lab_data_buffer *buffers[LAB_BS_ALL + 1], int x, int y,
struct view *view);
void update_window_icon_buffer(struct wlr_scene_node *button_node,
struct lab_data_buffer *buffer);
/* SSD internal helpers */
struct ssd_part *ssd_get_part(
@ -147,6 +160,7 @@ void ssd_destroy_parts(struct wl_list *list);
void ssd_titlebar_create(struct ssd *ssd);
void ssd_titlebar_update(struct ssd *ssd);
void ssd_titlebar_destroy(struct ssd *ssd);
bool ssd_should_be_squared(struct ssd *ssd);
void ssd_border_create(struct ssd *ssd);
void ssd_border_update(struct ssd *ssd);

View file

@ -5,8 +5,6 @@
#include <wayland-server-core.h>
#include "common/border.h"
#define SSD_BUTTON_COUNT 4
#define SSD_BUTTON_WIDTH 26
#define SSD_EXTENDED_AREA 8
/*
@ -23,12 +21,25 @@
*/
enum ssd_part_type {
LAB_SSD_NONE = 0,
LAB_SSD_BUTTON_CLOSE,
LAB_SSD_BUTTON_CLOSE = 1,
LAB_SSD_BUTTON_MAXIMIZE,
LAB_SSD_BUTTON_ICONIFY,
LAB_SSD_BUTTON_WINDOW_ICON,
LAB_SSD_BUTTON_WINDOW_MENU,
LAB_SSD_BUTTON_SHADE,
LAB_SSD_BUTTON_OMNIPRESENT,
/* only for internal use */
LAB_SSD_BUTTON_FIRST = LAB_SSD_BUTTON_CLOSE,
LAB_SSD_BUTTON_LAST = LAB_SSD_BUTTON_OMNIPRESENT,
LAB_SSD_BUTTON,
LAB_SSD_PART_TITLEBAR,
LAB_SSD_PART_TITLEBAR_CORNER_RIGHT,
LAB_SSD_PART_TITLEBAR_CORNER_LEFT,
LAB_SSD_PART_TITLE,
/* shared by shadows, borders and extents */
LAB_SSD_PART_CORNER_TOP_LEFT,
LAB_SSD_PART_CORNER_TOP_RIGHT,
LAB_SSD_PART_CORNER_BOTTOM_RIGHT,
@ -37,6 +48,7 @@ enum ssd_part_type {
LAB_SSD_PART_RIGHT,
LAB_SSD_PART_BOTTOM,
LAB_SSD_PART_LEFT,
LAB_SSD_CLIENT,
LAB_SSD_FRAME,
LAB_SSD_ROOT,
@ -74,12 +86,14 @@ struct wlr_scene_node;
*/
struct ssd *ssd_create(struct view *view, bool active);
struct border ssd_get_margin(const struct ssd *ssd);
int ssd_get_corner_width(void);
void ssd_update_margin(struct ssd *ssd);
void ssd_set_active(struct ssd *ssd, bool active);
void ssd_update_title(struct ssd *ssd);
void ssd_update_geometry(struct ssd *ssd);
void ssd_destroy(struct ssd *ssd);
void ssd_set_titlebar(struct ssd *ssd, bool enabled);
void ssd_update_window_icon(struct ssd *ssd);
void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable);
void ssd_enable_shade(struct ssd *ssd, bool enable);
@ -97,7 +111,6 @@ enum ssd_part_type ssd_at(const struct ssd *ssd,
enum ssd_part_type ssd_get_part_type(const struct ssd *ssd,
struct wlr_scene_node *node);
uint32_t ssd_resize_edges(enum ssd_part_type type);
bool ssd_is_button(enum ssd_part_type type);
bool ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate);
enum ssd_mode ssd_mode_parse(const char *mode);

View file

@ -10,6 +10,7 @@
#include <stdio.h>
#include <wlr/render/wlr_renderer.h>
#include "ssd.h"
enum lab_justification {
LAB_JUSTIFY_LEFT,
@ -25,9 +26,24 @@ struct theme_snapping_overlay {
float border_color[3][4];
};
enum lab_button_state {
LAB_BS_HOVERD = 1 << 0,
LAB_BS_TOGGLED = 1 << 1,
LAB_BS_ROUNDED = 1 << 2,
LAB_BS_ALL = LAB_BS_HOVERD | LAB_BS_TOGGLED | LAB_BS_ROUNDED,
};
struct theme {
int border_width;
int padding_height;
/*
* the space between title bar border and
* buttons on the left/right/top
*/
int window_titlebar_padding_width;
int window_titlebar_padding_height;
int title_height;
int menu_overlap_x;
int menu_overlap_y;
@ -44,20 +60,19 @@ struct theme {
float window_active_label_text_color[4];
float window_inactive_label_text_color[4];
enum lab_justification window_label_text_justify;
enum lab_justification menu_title_text_justify;
/* button colors */
float window_active_button_menu_unpressed_image_color[4];
float window_active_button_iconify_unpressed_image_color[4];
float window_active_button_max_unpressed_image_color[4];
float window_active_button_close_unpressed_image_color[4];
float window_inactive_button_menu_unpressed_image_color[4];
float window_inactive_button_iconify_unpressed_image_color[4];
float window_inactive_button_max_unpressed_image_color[4];
float window_inactive_button_close_unpressed_image_color[4];
/* TODO: add pressed and hover colors for buttons */
/* buttons */
int window_button_width;
int window_button_height;
int window_button_spacing;
/* the corner radius of the hover effect */
int window_button_hover_bg_corner_radius;
int menu_item_padding_x;
int menu_item_padding_y;
int menu_item_height;
float menu_items_bg_color[4];
float menu_items_text_color[4];
@ -72,6 +87,10 @@ struct theme {
int menu_separator_padding_height;
float menu_separator_color[4];
float menu_title_bg_color[4];
float menu_title_text_color[4];
int osd_border_width;
float osd_bg_color[4];
@ -99,31 +118,26 @@ struct theme {
float window_active_shadow_color[4];
float window_inactive_shadow_color[4];
struct {
/*
* The texture of a window buttons for each hover/toggled/rounded
* state. This can be accessed like:
*
* buttons[LAB_SSD_BUTTON_ICONIFY][LAB_BS_HOVERD | LAB_BS_TOGGLED]
*
* Elements in buttons[0] are all NULL since LAB_SSD_BUTTON_FIRST is 1.
*/
struct lab_data_buffer *buttons
[LAB_SSD_BUTTON_LAST + 1][LAB_BS_ALL + 1];
/* TODO: add toggled/hover/pressed/disabled colors for buttons */
float button_colors[LAB_SSD_BUTTON_LAST + 1][4];
/* TODO: move other window.(in)active.* entries to here */
} window[2]; /* indexed by THEME_INACTIVE and THEME_ACTIVE */
/* textures */
struct lab_data_buffer *button_close_active_unpressed;
struct lab_data_buffer *button_maximize_active_unpressed;
struct lab_data_buffer *button_restore_active_unpressed;
struct lab_data_buffer *button_iconify_active_unpressed;
struct lab_data_buffer *button_menu_active_unpressed;
struct lab_data_buffer *button_close_inactive_unpressed;
struct lab_data_buffer *button_maximize_inactive_unpressed;
struct lab_data_buffer *button_restore_inactive_unpressed;
struct lab_data_buffer *button_iconify_inactive_unpressed;
struct lab_data_buffer *button_menu_inactive_unpressed;
/* hover variants are optional and may be NULL */
struct lab_data_buffer *button_close_active_hover;
struct lab_data_buffer *button_maximize_active_hover;
struct lab_data_buffer *button_restore_active_hover;
struct lab_data_buffer *button_iconify_active_hover;
struct lab_data_buffer *button_menu_active_hover;
struct lab_data_buffer *button_close_inactive_hover;
struct lab_data_buffer *button_maximize_inactive_hover;
struct lab_data_buffer *button_restore_inactive_hover;
struct lab_data_buffer *button_iconify_inactive_hover;
struct lab_data_buffer *button_menu_inactive_hover;
struct lab_data_buffer *corner_top_left_active_normal;
struct lab_data_buffer *corner_top_right_active_normal;
@ -137,7 +151,10 @@ struct theme {
struct lab_data_buffer *shadow_corner_bottom_inactive;
struct lab_data_buffer *shadow_edge_inactive;
/* not set in rc.xml/themerc, but derived from font & padding_height */
/*
* Not set in rc.xml/themerc, but derived from the tallest titlebar
* object plus 2 * window_titlebar_padding_height
*/
int osd_window_switcher_item_height;
/* magnifier */
@ -145,6 +162,9 @@ struct theme {
int mag_border_width;
};
#define THEME_INACTIVE 0
#define THEME_ACTIVE 1
struct server;
/**

View file

@ -2,6 +2,7 @@
#ifndef LABWC_VIEW_H
#define LABWC_VIEW_H
#include "config/rcxml.h"
#include "config.h"
#include "ssd.h"
#include <stdbool.h>
@ -10,9 +11,18 @@
#include <wlr/util/box.h>
#include <xkbcommon/xkbcommon.h>
#define LAB_MIN_VIEW_WIDTH (SSD_BUTTON_WIDTH * SSD_BUTTON_COUNT)
#define LAB_MIN_VIEW_HEIGHT 60
/*
* Fallback view geometry used in some cases where a better position
* and/or size can't be determined. Try to avoid using these except as
* a last resort.
*/
#define VIEW_FALLBACK_X 100
#define VIEW_FALLBACK_Y 100
#define VIEW_FALLBACK_WIDTH 640
#define VIEW_FALLBACK_HEIGHT 480
/*
* In labwc, a view is a container for surfaces which can be moved around by
* the user. In practice this means XDG toplevel and XWayland windows.
@ -31,6 +41,12 @@ enum ssd_preference {
LAB_SSD_PREF_SERVER,
};
enum three_state {
LAB_STATE_UNSPECIFIED = 0,
LAB_STATE_ENABLED,
LAB_STATE_DISABLED
};
/**
* Directions in which a view can be maximized. "None" is used
* internally to mean "not maximized" but is not valid in rc.xml.
@ -188,6 +204,7 @@ struct view {
enum view_axis maximized;
bool fullscreen;
bool tearing_hint;
enum three_state force_tearing;
bool visible_on_all_workspaces;
enum view_edge tiled;
uint32_t edges_visible; /* enum wlr_edges bitset */
@ -281,6 +298,7 @@ struct xdg_toplevel_view {
/* Events unique to xdg-toplevel views */
struct wl_listener set_app_id;
struct wl_listener request_show_window_menu;
struct wl_listener new_popup;
};
@ -451,8 +469,15 @@ void view_moved(struct view *view);
void view_minimize(struct view *view, bool minimized);
bool view_compute_centered_position(struct view *view,
const struct wlr_box *ref, int w, int h, int *x, int *y);
void view_set_fallback_natural_geometry(struct view *view);
void view_store_natural_geometry(struct view *view);
/**
* view_apply_natural_geometry - adjust view->natural_geometry if it doesn't
* intersect with view->output and then apply it
*/
void view_apply_natural_geometry(struct view *view);
/**
* view_effective_height - effective height of view, with respect to shaded state
* @view: view for which effective height is desired
@ -475,7 +500,7 @@ void view_center(struct view *view, const struct wlr_box *ref);
* @policy: placement policy to apply
*/
void view_place_by_policy(struct view *view, bool allow_cursor,
enum view_placement_policy);
enum view_placement_policy policy);
void view_constrain_size_to_that_of_usable_area(struct view *view);
void view_restore_to(struct view *view, struct wlr_box geometry);
@ -495,6 +520,7 @@ void view_toggle_always_on_bottom(struct view *view);
void view_toggle_visible_on_all_workspaces(struct view *view);
bool view_is_tiled(struct view *view);
bool view_is_tiled_and_notify_tiled(struct view *view);
bool view_is_floating(struct view *view);
void view_move_to_workspace(struct view *view, struct workspace *workspace);
enum ssd_mode view_get_ssd_mode(struct view *view);
@ -529,6 +555,7 @@ const char *view_get_string_prop(struct view *view, const char *prop);
void view_update_title(struct view *view);
void view_update_app_id(struct view *view);
void view_reload_ssd(struct view *view);
int view_get_min_width(void);
void view_set_shade(struct view *view, bool shaded);
@ -540,8 +567,6 @@ void view_on_output_destroy(struct view *view);
void view_connect_map(struct view *view, struct wlr_surface *surface);
void view_destroy(struct view *view);
struct output *view_get_adjacent_output(struct view *view, enum view_edge edge,
bool wrap);
enum view_axis view_axis_parse(const char *direction);
enum view_edge view_edge_parse(const char *direction);
enum view_placement_policy view_placement_parse(const char *policy);

View file

@ -4,6 +4,7 @@
#include <stdbool.h>
#include <wayland-util.h>
#include <wayland-server-core.h>
struct seat;
struct server;
@ -19,6 +20,13 @@ struct workspace {
char *name;
struct wlr_scene_tree *tree;
struct lab_cosmic_workspace *cosmic_workspace;
struct {
struct wl_listener activate;
struct wl_listener deactivate;
struct wl_listener remove;
} on;
};
void workspaces_init(struct server *server);

View file

@ -69,6 +69,7 @@ struct xwayland_view {
struct wl_listener set_override_redirect;
struct wl_listener set_strut_partial;
struct wl_listener set_window_type;
struct wl_listener map_request;
/* Not (yet) implemented */
/* struct wl_listener set_role; */