Merge branch 'master' of https://github.com/swaywm/sway into zwlr-workspaces-implenent

This commit is contained in:
dmitry 2021-11-16 22:48:24 +03:00
commit c375120d7c
174 changed files with 5228 additions and 2954 deletions

View file

@ -1,6 +1,6 @@
#ifndef _SWAY_BACKGROUND_IMAGE_H
#define _SWAY_BACKGROUND_IMAGE_H
#include "cairo.h"
#include "cairo_util.h"
enum background_mode {
BACKGROUND_MODE_STRETCH,

View file

@ -1,8 +1,8 @@
#ifndef _SWAY_CAIRO_H
#define _SWAY_CAIRO_H
#ifndef _SWAY_CAIRO_UTIL_H
#define _SWAY_CAIRO_UTIL_H
#include "config.h"
#include <stdint.h>
#include <cairo/cairo.h>
#include <cairo.h>
#include <wayland-client-protocol.h>
void cairo_set_source_u32(cairo_t *cairo, uint32_t color);

View file

@ -1,6 +1,9 @@
#ifndef _SWAY_IPC_CLIENT_H
#define _SWAY_IPC_CLIENT_H
// arbitrary number, it's probably sufficient, higher number = more memory usage
#define JSON_MAX_DEPTH 512
#include <stdbool.h>
#include <stdint.h>
#include <sys/time.h>

View file

@ -3,7 +3,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <cairo/cairo.h>
#include <cairo.h>
#include <pango/pangocairo.h>
/**
@ -17,7 +17,8 @@ PangoLayout *get_pango_layout(cairo_t *cairo, const char *font,
const char *text, double scale, bool markup);
void get_text_size(cairo_t *cairo, const char *font, int *width, int *height,
int *baseline, double scale, bool markup, const char *fmt, ...);
void pango_printf(cairo_t *cairo, const char *font,
void get_text_metrics(const char *font, int *height, int *baseline);
void render_text(cairo_t *cairo, const char *font,
double scale, bool markup, const char *fmt, ...);
#endif

View file

@ -1,6 +1,6 @@
#ifndef _SWAY_BUFFERS_H
#define _SWAY_BUFFERS_H
#include <cairo/cairo.h>
#include <cairo.h>
#include <pango/pangocairo.h>
#include <stdbool.h>
#include <stdint.h>

View file

@ -12,7 +12,7 @@ char *lenient_strcat(char *dest, const char *src);
char *lenient_strncat(char *dest, const char *src, size_t len);
// strcmp that also handles null pointers.
int lenient_strcmp(char *a, char *b);
int lenient_strcmp(const char *a, const char *b);
// Simply split a string with delims, free with `list_free_items_and_destroy`
list_t *split_string(const char *str, const char *delims);

View file

@ -46,8 +46,8 @@ enum expected_args {
struct cmd_results *checkarg(int argc, const char *name,
enum expected_args type, int val);
struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
size_t handlers_size);
const struct cmd_handler *find_handler(char *line,
const struct cmd_handler *cmd_handlers, size_t handlers_size);
/**
* Parse and executes a command.
@ -68,7 +68,7 @@ struct cmd_results *config_command(char *command, char **new_block);
* Parse and handle a sub command
*/
struct cmd_results *config_subcommand(char **argv, int argc,
struct cmd_handler *handlers, size_t handlers_size);
const struct cmd_handler *handlers, size_t handlers_size);
/*
* Parses a command policy rule.
*/
@ -97,6 +97,12 @@ void container_resize_tiled(struct sway_container *parent, uint32_t axis,
struct sway_container *container_find_resize_parent(struct sway_container *con,
uint32_t edge);
/**
* Handlers shared by exec and exec_always.
*/
sway_cmd cmd_exec_validate;
sway_cmd cmd_exec_process;
sway_cmd cmd_assign;
sway_cmd cmd_bar;
sway_cmd cmd_bindcode;
@ -222,6 +228,7 @@ sway_cmd bar_cmd_unbindcode;
sway_cmd bar_cmd_unbindsym;
sway_cmd bar_cmd_wrap_scroll;
sway_cmd bar_cmd_workspace_buttons;
sway_cmd bar_cmd_workspace_min_width;
sway_cmd bar_colors_cmd_active_workspace;
sway_cmd bar_colors_cmd_background;
@ -257,6 +264,7 @@ sway_cmd input_cmd_scroll_button;
sway_cmd input_cmd_scroll_method;
sway_cmd input_cmd_tap;
sway_cmd input_cmd_tap_button_map;
sway_cmd input_cmd_tool_mode;
sway_cmd input_cmd_xkb_capslock;
sway_cmd input_cmd_xkb_file;
sway_cmd input_cmd_xkb_layout;
@ -274,6 +282,7 @@ sway_cmd output_cmd_dpms;
sway_cmd output_cmd_enable;
sway_cmd output_cmd_max_render_time;
sway_cmd output_cmd_mode;
sway_cmd output_cmd_modeline;
sway_cmd output_cmd_position;
sway_cmd output_cmd_scale;
sway_cmd output_cmd_scale_filter;

View file

@ -5,12 +5,15 @@
#include <string.h>
#include <time.h>
#include <wlr/interfaces/wlr_switch.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/util/box.h>
#include <xkbcommon/xkbcommon.h>
#include <xf86drmMode.h>
#include "../include/config.h"
#include "list.h"
#include "swaynag.h"
#include "tree/container.h"
#include "sway/input/tablet.h"
#include "sway/tree/root.h"
#include "wlr-layer-shell-unstable-v1-protocol.h"
@ -116,6 +119,11 @@ enum input_config_mapped_to {
MAPPED_TO_REGION,
};
struct input_config_tool {
enum wlr_tablet_tool_type type;
enum sway_tablet_tool_mode mode;
};
/**
* options for input devices
*/
@ -160,6 +168,8 @@ struct input_config {
char *mapped_to_output;
struct wlr_box *mapped_to_region;
list_t *tools;
bool capturable;
struct wlr_box region;
};
@ -172,6 +182,12 @@ struct seat_attachment_config {
// TODO other things are configured here for some reason
};
enum seat_config_hide_cursor_when_typing {
HIDE_WHEN_TYPING_DEFAULT, // the default is currently disabled
HIDE_WHEN_TYPING_ENABLE,
HIDE_WHEN_TYPING_DISABLE,
};
enum seat_config_allow_constrain {
CONSTRAIN_DEFAULT, // the default is currently enabled
CONSTRAIN_ENABLE,
@ -207,6 +223,7 @@ struct seat_config {
int fallback; // -1 means not set
list_t *attachments; // list of seat_attachment configs
int hide_cursor_timeout;
enum seat_config_hide_cursor_when_typing hide_cursor_when_typing;
enum seat_config_allow_constrain allow_constrain;
enum seat_config_shortcuts_inhibit shortcuts_inhibit;
enum seat_keyboard_grouping keyboard_grouping;
@ -241,6 +258,7 @@ struct output_config {
int width, height;
float refresh_rate;
int custom_mode;
drmModeModeInfo drm_mode;
int x, y;
float scale;
enum scale_filter_mode scale_filter;
@ -265,6 +283,12 @@ struct side_gaps {
int left;
};
enum smart_gaps_mode {
SMART_GAPS_OFF,
SMART_GAPS_ON,
SMART_GAPS_INVERSE_OUTER,
};
/**
* Stores configuration for a workspace, regardless of whether the workspace
* exists.
@ -276,6 +300,12 @@ struct workspace_config {
struct side_gaps gaps_outer;
};
enum pango_markup_config {
PANGO_MARKUP_DISABLED = false,
PANGO_MARKUP_ENABLED = true,
PANGO_MARKUP_DEFAULT // The default is font dependent ("pango:" prefix)
};
struct bar_config {
char *swaybar_command;
struct wl_client *client;
@ -307,7 +337,7 @@ struct bar_config {
char *position;
list_t *bindings;
char *status_command;
bool pango_markup;
enum pango_markup_config pango_markup;
char *font;
int height; // -1 not defined
bool workspace_buttons;
@ -320,6 +350,7 @@ struct bar_config {
struct side_gaps gaps;
int status_padding;
int status_edge_padding;
uint32_t workspace_min_width;
struct {
char *background;
char *statusline;
@ -393,14 +424,6 @@ enum sway_popup_during_fullscreen {
POPUP_LEAVE,
};
enum command_context {
CONTEXT_CONFIG = 1 << 0,
CONTEXT_BINDING = 1 << 1,
CONTEXT_IPC = 1 << 2,
CONTEXT_CRITERIA = 1 << 3,
CONTEXT_ALL = 0xFFFFFFFF,
};
enum focus_follows_mouse_mode {
FOLLOWS_NO,
FOLLOWS_YES,
@ -463,8 +486,8 @@ struct sway_config {
enum sway_container_layout default_orientation;
enum sway_container_layout default_layout;
char *font;
size_t font_height;
size_t font_baseline;
int font_height;
int font_baseline;
bool pango_markup;
int titlebar_border_thickness;
int titlebar_h_padding;
@ -495,7 +518,7 @@ struct sway_config {
bool tiling_drag;
int tiling_drag_threshold;
bool smart_gaps;
enum smart_gaps_mode smart_gaps;
int gaps_inner;
struct side_gaps gaps_outer;
@ -542,7 +565,7 @@ struct sway_config {
struct sway_node *node;
struct sway_container *container;
struct sway_workspace *workspace;
bool using_criteria;
bool node_overridden; // True if the node is selected by means other than focus
struct {
int argc;
char **argv;
@ -673,14 +696,13 @@ void free_bar_binding(struct bar_binding *binding);
void free_workspace_config(struct workspace_config *wsc);
/**
* Updates the value of config->font_height based on the max title height
* reported by each container. If recalculate is true, the containers will
* recalculate their heights before reporting.
*
* Updates the value of config->font_height based on the metrics for title's
* font as reported by pango.
*
* If the height has changed, all containers will be rearranged to take on the
* new size.
*/
void config_update_font_height(bool recalculate);
void config_update_font_height(void);
/**
* Convert bindsym into bindcode using the first configured layout.

View file

@ -22,6 +22,7 @@ struct sway_idle_inhibit_manager_v1 {
struct sway_idle_inhibitor_v1 {
struct sway_idle_inhibit_manager_v1 *manager;
struct wlr_idle_inhibitor_v1 *wlr_inhibitor;
struct sway_view *view;
enum sway_idle_inhibit_mode mode;

View file

@ -28,6 +28,12 @@ struct sway_view;
*/
void transaction_commit_dirty(void);
/*
* Same as transaction_commit_dirty, but signalling that this is a
* client-initiated change has already taken effect.
*/
void transaction_commit_dirty_client(void);
/**
* Notify the transaction system that a view is ready for the new layout.
*
@ -38,11 +44,11 @@ void transaction_notify_view_ready_by_serial(struct sway_view *view,
/**
* Notify the transaction system that a view is ready for the new layout, but
* identifying the instruction by width and height rather than by serial.
* identifying the instruction by geometry rather than by serial.
*
* This is used by xwayland views, as they don't have serials.
*/
void transaction_notify_view_ready_by_size(struct sway_view *view,
int width, int height);
void transaction_notify_view_ready_by_geometry(struct sway_view *view,
double x, double y, int width, int height);
#endif

View file

@ -6,6 +6,7 @@
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_surface.h>
#include "sway/input/seat.h"
#include "config.h"
#define SWAY_CURSOR_PRESSED_BUTTONS_CAP 32
@ -51,7 +52,9 @@ struct sway_cursor {
struct wl_listener touch_down;
struct wl_listener touch_up;
struct wl_listener touch_motion;
struct wl_listener touch_frame;
bool simulating_pointer_from_touch;
bool pointer_touch_up;
int32_t pointer_touch_id;
struct wl_listener tool_axis;
@ -68,6 +71,10 @@ struct sway_cursor {
struct wl_event_source *hide_source;
bool hidden;
// This field is just a cache of the field in seat_config in order to avoid
// costly seat_config lookups on every keypress. HIDE_WHEN_TYPING_DEFAULT
// indicates that there is no cached value.
enum seat_config_hide_cursor_when_typing hide_when_typing;
size_t pressed_button_count;
};
@ -90,10 +97,13 @@ void cursor_rebase(struct sway_cursor *cursor);
void cursor_rebase_all(void);
void cursor_update_image(struct sway_cursor *cursor, struct sway_node *node);
void cursor_handle_activity(struct sway_cursor *cursor,
void cursor_handle_activity_from_idle_source(struct sway_cursor *cursor,
enum sway_input_idle_source idle_source);
void cursor_handle_activity_from_device(struct sway_cursor *cursor,
struct wlr_input_device *device);
void cursor_unhide(struct sway_cursor *cursor);
int cursor_get_timeout(struct sway_cursor *cursor);
void cursor_notify_key_press(struct sway_cursor *cursor);
void dispatch_cursor_button(struct sway_cursor *cursor,
struct wlr_input_device *device, uint32_t time_msec, uint32_t button,
@ -110,7 +120,7 @@ void cursor_set_image_surface(struct sway_cursor *cursor,
struct wl_client *client);
void cursor_warp_to_container(struct sway_cursor *cursor,
struct sway_container *container);
struct sway_container *container, bool force);
void cursor_warp_to_workspace(struct sway_cursor *cursor,
struct sway_workspace *workspace);

View file

@ -6,4 +6,6 @@ void sway_input_configure_libinput_device(struct sway_input_device *device);
void sway_input_reset_libinput_device(struct sway_input_device *device);
bool sway_libinput_device_is_builtin(struct sway_input_device *device);
#endif

View file

@ -16,13 +16,12 @@ struct sway_seatop_impl {
void (*button)(struct sway_seat *seat, uint32_t time_msec,
struct wlr_input_device *device, uint32_t button,
enum wlr_button_state state);
void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec,
double dx, double dy);
void (*pointer_motion)(struct sway_seat *seat, uint32_t time_msec);
void (*pointer_axis)(struct sway_seat *seat,
struct wlr_event_pointer_axis *event);
void (*rebase)(struct sway_seat *seat, uint32_t time_msec);
void (*tablet_tool_motion)(struct sway_seat *seat,
struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy);
struct sway_tablet_tool *tool, uint32_t time_msec);
void (*tablet_tool_tip)(struct sway_seat *seat, struct sway_tablet_tool *tool,
uint32_t time_msec, enum wlr_tablet_tool_tip_state state);
void (*end)(struct sway_seat *seat);
@ -240,7 +239,10 @@ enum wlr_edges find_resize_edge(struct sway_container *cont,
void seatop_begin_default(struct sway_seat *seat);
void seatop_begin_down(struct sway_seat *seat, struct sway_container *con,
uint32_t time_msec, int sx, int sy);
uint32_t time_msec, double sx, double sy);
void seatop_begin_down_on_surface(struct sway_seat *seat,
struct wlr_surface *surface, uint32_t time_msec, double sx, double sy);
void seatop_begin_move_floating(struct sway_seat *seat,
struct sway_container *con);
@ -269,11 +271,7 @@ void seatop_button(struct sway_seat *seat, uint32_t time_msec,
struct wlr_input_device *device, uint32_t button,
enum wlr_button_state state);
/**
* dx and dy are distances relative to previous position.
*/
void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec,
double dx, double dy);
void seatop_pointer_motion(struct sway_seat *seat, uint32_t time_msec);
void seatop_pointer_axis(struct sway_seat *seat,
struct wlr_event_pointer_axis *event);
@ -283,7 +281,7 @@ void seatop_tablet_tool_tip(struct sway_seat *seat,
enum wlr_tablet_tool_tip_state state);
void seatop_tablet_tool_motion(struct sway_seat *seat,
struct sway_tablet_tool *tool, uint32_t time_msec, double dx, double dy);
struct sway_tablet_tool *tool, uint32_t time_msec);
void seatop_rebase(struct sway_seat *seat, uint32_t time_msec);

View file

@ -11,11 +11,17 @@ struct sway_tablet {
struct wlr_tablet_v2_tablet *tablet_v2;
};
enum sway_tablet_tool_mode {
SWAY_TABLET_TOOL_MODE_ABSOLUTE,
SWAY_TABLET_TOOL_MODE_RELATIVE,
};
struct sway_tablet_tool {
struct sway_seat *seat;
struct sway_tablet *tablet;
struct wlr_tablet_v2_tablet_tool *tablet_v2_tool;
enum sway_tablet_tool_mode mode;
double tilt_x, tilt_y;
struct wl_listener set_cursor;

View file

@ -28,7 +28,10 @@ struct sway_input_method_relay {
struct wl_listener input_method_new;
struct wl_listener input_method_commit;
struct wl_listener input_method_grab_keyboard;
struct wl_listener input_method_destroy;
struct wl_listener input_method_keyboard_grab_destroy;
};
struct sway_text_input {
@ -53,6 +56,8 @@ struct sway_text_input {
void sway_input_method_relay_init(struct sway_seat *seat,
struct sway_input_method_relay *relay);
void sway_input_method_relay_finish(struct sway_input_method_relay *relay);
// Updates currently focused surface. Surface must belong to the same seat.
void sway_input_method_relay_set_focus(struct sway_input_method_relay *relay,
struct wlr_surface *surface);

View file

@ -1,7 +1,6 @@
#ifndef _SWAY_LAYERS_H
#define _SWAY_LAYERS_H
#include <stdbool.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_layer_shell_v1.h>
@ -20,8 +19,11 @@ struct sway_layer_surface {
struct wl_listener surface_commit;
struct wl_listener output_destroy;
struct wl_listener new_popup;
struct wl_listener new_subsurface;
struct wlr_box geo;
bool mapped;
struct wlr_box extent;
enum zwlr_layer_shell_v1_layer layer;
};
@ -39,6 +41,16 @@ struct sway_layer_popup {
struct wl_listener new_popup;
};
struct sway_layer_subsurface {
struct wlr_subsurface *wlr_subsurface;
struct sway_layer_surface *layer_surface;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener commit;
};
struct sway_output;
void arrange_layers(struct sway_output *output);

View file

@ -3,7 +3,6 @@
#include <time.h>
#include <unistd.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_workspace_v1.h>
#include "config.h"
@ -44,9 +43,8 @@ struct sway_output {
struct sway_output_state current;
struct wl_listener destroy;
struct wl_listener commit;
struct wl_listener mode;
struct wl_listener transform;
struct wl_listener scale;
struct wl_listener present;
struct wl_listener damage_destroy;
struct wl_listener damage_frame;
@ -77,8 +75,8 @@ struct sway_output *output_get_in_direction(struct sway_output *reference,
void output_add_workspace(struct sway_output *output,
struct sway_workspace *workspace);
typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, struct sway_view *view,
struct wlr_surface *surface, struct wlr_box *box, float rotation,
typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
struct sway_view *view, struct wlr_surface *surface, struct wlr_box *box,
void *user_data);
void output_damage_whole(struct sway_output *output);
@ -121,7 +119,7 @@ void output_view_for_each_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data);
void output_view_for_each_popup(struct sway_output *output,
void output_view_for_each_popup_surface(struct sway_output *output,
struct sway_view *view, sway_surface_iterator_func_t iterator,
void *user_data);
@ -129,11 +127,11 @@ void output_layer_for_each_surface(struct sway_output *output,
struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
void *user_data);
void output_layer_for_each_surface_toplevel(struct sway_output *output,
void output_layer_for_each_toplevel_surface(struct sway_output *output,
struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
void *user_data);
void output_layer_for_each_surface_popup(struct sway_output *output,
void output_layer_for_each_popup_surface(struct sway_output *output,
struct wl_list *layer_surfaces, sway_surface_iterator_func_t iterator,
void *user_data);

View file

@ -10,6 +10,7 @@
#include <wlr/types/wlr_input_method_v2.h>
#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
#include <wlr/types/wlr_workspace_v1.h>
#include <wlr/types/wlr_drm_lease_v1.h>
#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_output_management_v1.h>
#include <wlr/types/wlr_output_power_management_v1.h>
@ -24,6 +25,8 @@
#include "sway/xwayland.h"
#endif
struct sway_transaction;
struct sway_server {
struct wl_display *wl_display;
struct wl_event_loop *wl_event_loop;
@ -71,6 +74,9 @@ struct sway_server {
struct wl_listener xdg_decoration;
struct wl_list xdg_decorations; // sway_xdg_decoration::link
struct wlr_drm_lease_v1_manager *drm_lease_manager;
struct wl_listener drm_lease_request;
struct wlr_presentation *presentation;
struct wlr_pointer_constraints_v1 *pointer_constraints;
@ -88,8 +94,25 @@ struct sway_server {
struct wlr_workspace_manager_v1 *workspace_manager;
struct wl_listener workspace_manager_commit_request;
struct wlr_xdg_activation_v1 *xdg_activation_v1;
struct wl_listener xdg_activation_v1_request_activate;
// The timeout for transactions, after which a transaction is applied
// regardless of readiness.
size_t txn_timeout_ms;
list_t *transactions;
// Stores a transaction after it has been committed, but is waiting for
// views to ack the new dimensions before being applied. A queued
// transaction is frozen and must not have new instructions added to it.
struct sway_transaction *queued_transaction;
// Stores a pending transaction that will be committed once the existing
// queued transaction is applied and freed. The pending transaction can be
// updated with new instructions as needed.
struct sway_transaction *pending_transaction;
// Stores the nodes that have been marked as "dirty" and will be put into
// the pending transaction.
list_t *dirty_nodes;
};
@ -99,6 +122,7 @@ struct sway_debug {
bool noatomic; // Ignore atomic layout updates
bool txn_timings; // Log verbose messages about transactions
bool txn_wait; // Always wait for the timeout before applying
bool noscanout; // Disable direct scan-out
enum {
DAMAGE_DEFAULT, // Default behaviour
@ -116,6 +140,8 @@ void server_fini(struct sway_server *server);
bool server_start(struct sway_server *server);
void server_run(struct sway_server *server);
void restore_nofile_limit(void);
void handle_compositor_new_surface(struct wl_listener *listener, void *data);
void handle_new_output(struct wl_listener *listener, void *data);
@ -128,5 +154,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data);
void handle_server_decoration(struct wl_listener *listener, void *data);
void handle_xdg_decoration(struct wl_listener *listener, void *data);
void handle_pointer_constraint(struct wl_listener *listener, void *data);
void xdg_activation_v1_handle_request_activate(struct wl_listener *listener,
void *data);
#endif

View file

@ -2,7 +2,6 @@
#define _SWAY_CONTAINER_H
#include <stdint.h>
#include <sys/types.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include "list.h"
#include "sway/tree/node.h"
@ -46,9 +45,9 @@ struct sway_container_state {
enum sway_fullscreen_mode fullscreen_mode;
struct sway_workspace *workspace;
struct sway_container *parent;
list_t *children;
struct sway_workspace *workspace; // NULL when hidden in the scratchpad
struct sway_container *parent; // NULL if container in root of workspace
list_t *children; // struct sway_container
struct sway_container *focused_inactive_child;
bool focused;
@ -60,6 +59,7 @@ struct sway_container_state {
bool border_left;
bool border_right;
// These are in layout coordinates.
double content_x, content_y;
double content_width, content_height;
};
@ -68,26 +68,29 @@ struct sway_container {
struct sway_node node;
struct sway_view *view;
// The pending state is the main container properties, and the current state is in the below struct.
// This means most places of the code can refer to the main variables (pending state) and it'll just work.
struct sway_container_state current;
struct sway_container_state pending;
char *title; // The view's title (unformatted)
char *formatted_title; // The title displayed in the title bar
enum sway_container_layout layout;
enum sway_container_layout prev_split_layout;
// Whether stickiness has been enabled on this container. Use
// `container_is_sticky_[or_child]` rather than accessing this field
// directly; it'll also check that the container is floating.
bool is_sticky;
// For C_ROOT, this has no meaning
// For other types, this is the position in layout coordinates
// Includes borders
double x, y;
double width, height;
double saved_x, saved_y;
double saved_width, saved_height;
// Used when the view changes to CSD unexpectedly. This will be a non-B_CSD
// border which we use to restore when the view returns to SSD.
enum sway_container_border saved_border;
// The share of the space of parent container this container occupies
double width_fraction;
double height_fraction;
@ -97,33 +100,11 @@ struct sway_container {
double child_total_width;
double child_total_height;
// These are in layout coordinates.
double content_x, content_y;
int content_width, content_height;
// In most cases this is the same as the content x and y, but if the view
// refuses to resize to the content dimensions then it can be smaller.
// These are in layout coordinates.
double surface_x, surface_y;
enum sway_fullscreen_mode fullscreen_mode;
enum sway_container_border border;
// Used when the view changes to CSD unexpectedly. This will be a non-B_CSD
// border which we use to restore when the view returns to SSD.
enum sway_container_border saved_border;
int border_thickness;
bool border_top;
bool border_bottom;
bool border_left;
bool border_right;
struct sway_workspace *workspace; // NULL when hidden in the scratchpad
struct sway_container *parent; // NULL if container in root of workspace
list_t *children; // struct sway_container
// Outputs currently being intersected
list_t *outputs; // struct sway_output
@ -138,8 +119,6 @@ struct sway_container {
struct wlr_texture *title_focused_inactive;
struct wlr_texture *title_unfocused;
struct wlr_texture *title_urgent;
size_t title_height;
size_t title_baseline;
list_t *marks; // char *
struct wlr_texture *marks_focused;
@ -181,6 +160,11 @@ struct sway_container *tiling_container_at(
void container_for_each_child(struct sway_container *container,
void (*f)(struct sway_container *container, void *data), void *data);
/**
* Returns the fullscreen container obstructing this container if it exists.
*/
struct sway_container *container_obstructing_fullscreen_container(struct sway_container *container);
/**
* Returns true if the given container is an ancestor of this container.
*/
@ -197,11 +181,6 @@ struct sway_container *container_flatten(struct sway_container *container);
void container_update_title_textures(struct sway_container *container);
/**
* Calculate the container's title_height property.
*/
void container_calculate_title_height(struct sway_container *container);
size_t container_build_representation(enum sway_container_layout layout,
list_t *children, char *buffer);
@ -228,9 +207,16 @@ void container_set_geometry_from_content(struct sway_container *con);
/**
* Determine if the given container is itself floating.
* This will return false for any descendants of a floating container.
*
* Uses pending container state.
*/
bool container_is_floating(struct sway_container *container);
/**
* Same as above, but for current container state.
*/
bool container_is_current_floating(struct sway_container *container);
/**
* Get a container's box in layout coordinates.
*/
@ -296,6 +282,7 @@ bool container_is_fullscreen_or_child(struct sway_container *container);
/**
* Return the output which will be used for scale purposes.
* This is the most recently entered output.
* If the container is not on any output, return NULL.
*/
struct sway_output *container_get_effective_output(struct sway_container *con);
@ -367,4 +354,21 @@ bool container_is_scratchpad_hidden(struct sway_container *con);
bool container_is_scratchpad_hidden_or_child(struct sway_container *con);
bool container_is_sticky(struct sway_container *con);
bool container_is_sticky_or_child(struct sway_container *con);
/**
* This will destroy pairs of redundant H/V splits
* e.g. H[V[H[app app]] app] -> H[app app app]
* The middle "V[H[" are eliminated by a call to container_squash
* on the V[ con. It's grandchildren are added to it's parent.
*
* This function is roughly equivalent to i3's tree_flatten here:
* https://github.com/i3/i3/blob/1f0c628cde40cf87371481041b7197344e0417c6/src/tree.c#L651
*
* Returns the number of new containers added to the parent
*/
int container_squash(struct sway_container *con);
#endif

View file

@ -47,7 +47,7 @@ struct sway_view_impl {
bool (*wants_floating)(struct sway_view *view);
void (*for_each_surface)(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
void (*for_each_popup)(struct sway_view *view,
void (*for_each_popup_surface)(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
bool (*is_transient_for)(struct sway_view *child,
struct sway_view *ancestor);
@ -99,7 +99,9 @@ struct sway_view {
struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
struct wl_listener foreign_activate_request;
struct wl_listener foreign_fullscreen_request;
struct wl_listener foreign_close_request;
struct wl_listener foreign_destroy;
bool destroying;
@ -110,7 +112,6 @@ struct sway_view {
#if HAVE_XWAYLAND
struct wlr_xwayland_surface *wlr_xwayland_surface;
#endif
struct wlr_wl_shell_surface *wlr_wl_shell_surface;
};
struct {
@ -130,7 +131,6 @@ struct sway_xdg_shell_view {
struct wl_listener commit;
struct wl_listener request_move;
struct wl_listener request_resize;
struct wl_listener request_maximize;
struct wl_listener request_fullscreen;
struct wl_listener set_title;
struct wl_listener set_app_id;
@ -160,6 +160,7 @@ struct sway_xwayland_view {
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener override_redirect;
};
struct sway_xwayland_unmanaged {
@ -171,15 +172,17 @@ struct sway_xwayland_unmanaged {
struct wl_listener request_configure;
struct wl_listener request_fullscreen;
struct wl_listener commit;
struct wl_listener set_geometry;
struct wl_listener map;
struct wl_listener unmap;
struct wl_listener destroy;
struct wl_listener override_redirect;
};
#endif
struct sway_view_child;
struct sway_view_child_impl {
void (*get_root_coords)(struct sway_view_child *child, int *sx, int *sy);
void (*get_view_coords)(struct sway_view_child *child, int *sx, int *sy);
void (*destroy)(struct sway_view_child *child);
};
@ -292,9 +295,9 @@ void view_for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
/**
* Iterate all popups recursively.
* Iterate all popup surfaces of a view.
*/
void view_for_each_popup(struct sway_view *view,
void view_for_each_popup_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data);
// view implementation
@ -306,12 +309,22 @@ void view_destroy(struct sway_view *view);
void view_begin_destroy(struct sway_view *view);
/**
* Map a view, ie. make it visible in the tree.
*
* `fullscreen` should be set to true (and optionally `fullscreen_output`
* should be populated) if the view should be made fullscreen immediately.
*
* `decoration` should be set to true if the client prefers CSD. The client's
* preference may be ignored.
*/
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
bool fullscreen, struct wlr_output *fullscreen_output, bool decoration);
void view_unmap(struct sway_view *view);
void view_update_size(struct sway_view *view, int width, int height);
void view_update_size(struct sway_view *view);
void view_center_surface(struct sway_view *view);
void view_child_init(struct sway_view_child *child,
const struct sway_view_child_impl *impl, struct sway_view *view,

View file

@ -63,20 +63,20 @@ void workspace_consider_destroy(struct sway_workspace *ws);
char *workspace_next_name(const char *output_name);
bool workspace_switch(struct sway_workspace *workspace,
bool no_auto_back_and_forth);
struct sway_workspace *workspace_auto_back_and_forth(
struct sway_workspace *workspace);
bool workspace_switch(struct sway_workspace *workspace);
struct sway_workspace *workspace_by_number(const char* name);
struct sway_workspace *workspace_by_name(const char*);
struct sway_workspace *workspace_output_next(
struct sway_workspace *current, bool create);
struct sway_workspace *workspace_output_next(struct sway_workspace *current);
struct sway_workspace *workspace_next(struct sway_workspace *current);
struct sway_workspace *workspace_output_prev(
struct sway_workspace *current, bool create);
struct sway_workspace *workspace_output_prev(struct sway_workspace *current);
struct sway_workspace *workspace_prev(struct sway_workspace *current);
@ -113,13 +113,20 @@ void workspace_unwrap_children(struct sway_workspace *ws,
void workspace_detach(struct sway_workspace *workspace);
void workspace_add_tiling(struct sway_workspace *workspace,
struct sway_container *workspace_add_tiling(struct sway_workspace *workspace,
struct sway_container *con);
void workspace_add_floating(struct sway_workspace *workspace,
struct sway_container *con);
void workspace_insert_tiling(struct sway_workspace *workspace,
/**
* Adds a tiling container to the workspace without considering
* the workspace_layout, so the con will not be split.
*/
void workspace_insert_tiling_direct(struct sway_workspace *workspace,
struct sway_container *con, int index);
struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
struct sway_container *con, int index);
void workspace_remove_gaps(struct sway_workspace *ws);
@ -135,4 +142,14 @@ void workspace_get_box(struct sway_workspace *workspace, struct wlr_box *box);
size_t workspace_num_tiling_views(struct sway_workspace *ws);
size_t workspace_num_sticky_containers(struct sway_workspace *ws);
/**
* workspace_squash is container_flatten in the reverse
* direction. Instead of eliminating redundant splits that are
* parents of the target container, it eliminates pairs of
* redundant H/V splits that are children of the workspace.
*/
void workspace_squash(struct sway_workspace *workspace);
#endif

View file

@ -38,6 +38,7 @@ struct swaybar_config {
bool binding_mode_indicator;
bool wrap_scroll;
bool workspace_buttons;
uint32_t workspace_min_width;
list_t *bindings;
struct wl_list outputs; // config_output::link
int height;

View file

@ -19,6 +19,7 @@ struct i3bar_block {
// Airblader features
uint32_t background;
uint32_t border;
bool border_set;
int border_top;
int border_bottom;
int border_left;

View file

@ -2,10 +2,12 @@
#define _SWAYBAR_TRAY_TRAY_H
#include "config.h"
#ifdef HAVE_SYSTEMD
#if HAVE_LIBSYSTEMD
#include <systemd/sd-bus.h>
#elif HAVE_ELOGIND
#elif HAVE_LIBELOGIND
#include <elogind/sd-bus.h>
#elif HAVE_BASU
#include <basu/sd-bus.h>
#endif
#include <cairo.h>
#include <stdint.h>

View file

@ -7,9 +7,12 @@ struct swaynag_type {
char *font;
char *output;
uint32_t anchors;
int32_t layer; // enum zwlr_layer_shell_v1_layer or -1 if unset
// Colors
uint32_t button_text;
uint32_t button_background;
uint32_t details_background;
uint32_t background;
uint32_t text;
uint32_t border;

View file

@ -29,12 +29,6 @@ enum movement_unit parse_movement_unit(const char *unit);
int parse_movement_amount(int argc, char **argv,
struct movement_amount *amount);
/**
* Get the current time, in milliseconds.
*/
uint32_t get_current_time_msec(void);
/**
* Wrap i into the range [0, max]
*/