diff options
author | Reza Jelveh <[email protected]> | 2024-04-15 13:39:41 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2024-04-15 01:39:41 -0400 |
commit | fb86ed6b0588dfdebfb66ce875bc63cfa0a897f6 (patch) | |
tree | 29857a1769107adc58696f08d379f608aa4e29a2 /include | |
parent | a5e79676c4bd22fc5902182acf0667907202a465 (diff) |
feat: 1.9 merge (#277)
Co-authored-by: William McKinnon <[email protected]>
Co-authored-by: Erik Reider <[email protected]>
Diffstat (limited to 'include')
31 files changed, 193 insertions, 387 deletions
diff --git a/include/pango.h b/include/pango.h index 1db113c2..228e39cf 100644 --- a/include/pango.h +++ b/include/pango.h @@ -5,6 +5,7 @@ #include <stdint.h> #include <cairo.h> #include <pango/pangocairo.h> +#include "stringop.h" /** * Utility function which escape characters a & < > ' ". @@ -16,9 +17,9 @@ size_t escape_markup_text(const char *src, char *dest); PangoLayout *get_pango_layout(cairo_t *cairo, const PangoFontDescription *desc, const char *text, double scale, bool markup); void get_text_size(cairo_t *cairo, const PangoFontDescription *desc, int *width, int *height, - int *baseline, double scale, bool markup, const char *fmt, ...); + int *baseline, double scale, bool markup, const char *fmt, ...) _SWAY_ATTRIB_PRINTF(8, 9); void get_text_metrics(const PangoFontDescription *desc, int *height, int *baseline); void render_text(cairo_t *cairo, PangoFontDescription *desc, - double scale, bool markup, const char *fmt, ...); + double scale, bool markup, const char *fmt, ...) _SWAY_ATTRIB_PRINTF(5, 6); #endif diff --git a/include/stringop.h b/include/stringop.h index b29f59b2..19a50f23 100644 --- a/include/stringop.h +++ b/include/stringop.h @@ -5,6 +5,12 @@ #include <stddef.h> #include "list.h" +#ifdef __GNUC__ +#define _SWAY_ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end))) +#else +#define _SWAY_ATTRIB_PRINTF(start, end) +#endif + void strip_whitespace(char *str); void strip_quotes(char *str); @@ -31,4 +37,7 @@ char *argsep(char **stringp, const char *delim, char *matched_delim); // Expand a path using shell replacements such as $HOME and ~ bool expand_path(char **path); +char *vformat_str(const char *fmt, va_list args) _SWAY_ATTRIB_PRINTF(1, 0); +char *format_str(const char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2); + #endif diff --git a/include/sway/commands.h b/include/sway/commands.h index b8f5660a..8f21b989 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -3,13 +3,14 @@ #include <wlr/util/edges.h> #include "config.h" +#include "stringop.h" struct sway_container; typedef struct cmd_results *sway_cmd(int argc, char **argv); struct cmd_handler { - char *command; + const char *command; sway_cmd *handle; }; @@ -46,7 +47,7 @@ enum expected_args { struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val); -const struct cmd_handler *find_handler(char *line, +const struct cmd_handler *find_handler(const char *line, const struct cmd_handler *cmd_handlers, size_t handlers_size); /** @@ -76,7 +77,7 @@ struct cmd_results *config_commands_command(char *exec); /** * Allocates a cmd_results object. */ -struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...); +struct cmd_results *cmd_results_new(enum cmd_status status, const char *error, ...) _SWAY_ATTRIB_PRINTF(2, 3); /** * Frees a cmd_results object. */ @@ -174,8 +175,6 @@ sway_cmd cmd_max_render_time; sway_cmd cmd_mode; sway_cmd cmd_mouse_warping; sway_cmd cmd_move; -sway_cmd cmd_new_float; -sway_cmd cmd_new_window; sway_cmd cmd_nop; sway_cmd cmd_opacity; sway_cmd cmd_saturation; @@ -185,6 +184,7 @@ sway_cmd cmd_no_focus; sway_cmd cmd_output; sway_cmd cmd_permit; sway_cmd cmd_popup_during_fullscreen; +sway_cmd cmd_primary_selection; sway_cmd cmd_reject; sway_cmd cmd_reload; sway_cmd cmd_rename; @@ -290,10 +290,12 @@ sway_cmd input_cmd_map_to_region; sway_cmd input_cmd_middle_emulation; sway_cmd input_cmd_natural_scroll; sway_cmd input_cmd_pointer_accel; +sway_cmd input_cmd_rotation_angle; sway_cmd input_cmd_scroll_factor; sway_cmd input_cmd_repeat_delay; sway_cmd input_cmd_repeat_rate; sway_cmd input_cmd_scroll_button; +sway_cmd input_cmd_scroll_button_lock; sway_cmd input_cmd_scroll_method; sway_cmd input_cmd_tap; sway_cmd input_cmd_tap_button_map; diff --git a/include/sway/config.h b/include/sway/config.h index de49bbff..84e4ab8e 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -12,8 +12,10 @@ #include "../include/config.h" #include "gesture.h" #include "list.h" +#include "stringop.h" #include "swaynag.h" #include "tree/container.h" +#include "scenefx/types/fx/blur_data.h" #include "sway/input/tablet.h" #include "sway/tree/root.h" #include "wlr-layer-shell-unstable-v1-protocol.h" @@ -155,10 +157,12 @@ struct input_config { int middle_emulation; int natural_scroll; float pointer_accel; + float rotation_angle; float scroll_factor; int repeat_delay; int repeat_rate; int scroll_button; + int scroll_button_lock; int scroll_method; int send_events; int tap; @@ -470,15 +474,6 @@ enum xwayland_mode { XWAYLAND_MODE_IMMEDIATE, }; -struct blur_parameters { - int num_passes; - int radius; - float noise; - float brightness; - float contrast; - float saturation; -}; - /** * The configuration struct. The result of loading a config file. */ @@ -501,7 +496,7 @@ struct sway_config { bool blur_enabled; bool blur_xray; - struct blur_parameters blur_params; + struct blur_data blur_params; bool titlebar_separator; bool scratchpad_minimize; @@ -564,6 +559,7 @@ struct sway_config { bool auto_back_and_forth; bool show_marks; enum alignment title_align; + bool primary_selection; bool tiling_drag; int tiling_drag_threshold; @@ -657,7 +653,7 @@ void run_deferred_bindings(void); /** * Adds a warning entry to the swaynag instance used for errors. */ -void config_add_swaynag_warning(char *fmt, ...); +void config_add_swaynag_warning(char *fmt, ...) _SWAY_ATTRIB_PRINTF(1, 2); /** * Free config struct diff --git a/include/sway/criteria.h b/include/sway/criteria.h index 59f57f94..8da345ea 100644 --- a/include/sway/criteria.h +++ b/include/sway/criteria.h @@ -43,6 +43,7 @@ struct criteria { struct pattern *window_role; enum atom_name window_type; #endif + bool all; bool floating; bool tiling; char urgent; // 'l' for latest or 'o' for oldest diff --git a/include/sway/desktop/fx_renderer/fx_framebuffer.h b/include/sway/desktop/fx_renderer/fx_framebuffer.h deleted file mode 100644 index 3372cd00..00000000 --- a/include/sway/desktop/fx_renderer/fx_framebuffer.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef FX_FRAMEBUFFER_H -#define FX_FRAMEBUFFER_H - -#include <GLES2/gl2.h> -#include <stdbool.h> -#include <wlr/types/wlr_output.h> - -#include "sway/desktop/fx_renderer/fx_stencilbuffer.h" -#include "sway/desktop/fx_renderer/fx_texture.h" - -struct fx_framebuffer { - GLuint fb; - struct fx_stencilbuffer stencil_buffer; - struct fx_texture texture; -}; - -struct fx_framebuffer fx_framebuffer_create(); - -void fx_framebuffer_bind(struct fx_framebuffer *buffer); - -void fx_framebuffer_update(struct fx_framebuffer *buffer, int width, int height); - -void fx_framebuffer_add_stencil_buffer(struct fx_framebuffer *buffer, int width, int height); - -void fx_framebuffer_release(struct fx_framebuffer *buffer); - -#endif diff --git a/include/sway/desktop/fx_renderer/fx_renderer.h b/include/sway/desktop/fx_renderer/fx_renderer.h deleted file mode 100644 index 7643caaf..00000000 --- a/include/sway/desktop/fx_renderer/fx_renderer.h +++ /dev/null @@ -1,236 +0,0 @@ -#ifndef _SWAY_OPENGL_H -#define _SWAY_OPENGL_H - -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> -#include <stdbool.h> -#include <wlr/render/egl.h> - -#include "sway/desktop/fx_renderer/fx_framebuffer.h" -#include "sway/desktop/fx_renderer/fx_texture.h" - -enum corner_location { TOP_LEFT, TOP_RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT, ALL, NONE }; - -enum fx_tex_shader_source { - SHADER_SOURCE_TEXTURE_RGBA = 1, - SHADER_SOURCE_TEXTURE_RGBX = 2, - SHADER_SOURCE_TEXTURE_EXTERNAL = 3, -}; - -enum fx_rounded_quad_shader_source { - SHADER_SOURCE_QUAD_ROUND = 1, - SHADER_SOURCE_QUAD_ROUND_TOP_LEFT = 2, - SHADER_SOURCE_QUAD_ROUND_TOP_RIGHT = 3, - SHADER_SOURCE_QUAD_ROUND_BOTTOM_RIGHT = 4, - SHADER_SOURCE_QUAD_ROUND_BOTTOM_LEFT = 5, -}; - -struct decoration_data { - float alpha; - float saturation; - int corner_radius; - float dim; - float *dim_color; - bool has_titlebar; - bool discard_transparent; - bool blur; - bool shadow; -}; - -struct blur_shader { - GLuint program; - GLint proj; - GLint tex; - GLint pos_attrib; - GLint tex_attrib; - GLint radius; - GLint halfpixel; -}; - -struct effects_shader { - GLuint program; - GLint proj; - GLint tex; - GLint pos_attrib; - GLint tex_attrib; - GLfloat noise; - GLfloat brightness; - GLfloat contrast; - GLfloat saturation; -}; - -struct box_shadow_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint position; - GLint size; - GLint blur_sigma; - GLint corner_radius; -}; - -struct corner_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint is_top_left; - GLint is_top_right; - GLint is_bottom_left; - GLint is_bottom_right; - GLint position; - GLint radius; - GLint half_size; - GLint half_thickness; -}; - -struct quad_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; -}; - -struct rounded_quad_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint size; - GLint position; - GLint radius; -}; - -struct stencil_mask_shader { - GLuint program; - GLint proj; - GLint color; - GLint pos_attrib; - GLint half_size; - GLint position; - GLint radius; -}; - -struct tex_shader { - GLuint program; - GLint proj; - GLint tex; - GLint alpha; - GLint pos_attrib; - GLint tex_attrib; - GLint size; - GLint position; - GLint radius; - GLint saturation; - GLint dim; - GLint dim_color; - GLint has_titlebar; - GLint discard_transparent; -}; - -struct fx_renderer { - float projection[9]; - - int viewport_width, viewport_height; - - struct wlr_output *wlr_output; - - // The framebuffer used by wlroots - struct fx_framebuffer wlr_buffer; - // Contains the blurred background for tiled windows - struct fx_framebuffer blur_buffer; - // Contains the original pixels to draw over the areas where artifact are visible - struct fx_framebuffer blur_saved_pixels_buffer; - // Blur swaps between the two effects buffers everytime it scales the image - // Buffer used for effects - struct fx_framebuffer effects_buffer; - // Swap buffer used for effects - struct fx_framebuffer effects_buffer_swapped; - - // The region where there's blur - pixman_region32_t blur_padding_region; - - bool blur_buffer_dirty; - - struct { - bool OES_egl_image_external; - } exts; - - struct { - PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; - } procs; - - struct { - struct box_shadow_shader box_shadow; - struct blur_shader blur1; - struct blur_shader blur2; - struct effects_shader blur_effects; - struct corner_shader corner; - struct quad_shader quad; - struct rounded_quad_shader rounded_quad; - struct rounded_quad_shader rounded_tl_quad; - struct rounded_quad_shader rounded_tr_quad; - struct rounded_quad_shader rounded_bl_quad; - struct rounded_quad_shader rounded_br_quad; - struct stencil_mask_shader stencil_mask; - struct tex_shader tex_rgba; - struct tex_shader tex_rgbx; - struct tex_shader tex_ext; - } shaders; -}; - -struct decoration_data get_undecorated_decoration_data(); - -struct fx_renderer *fx_renderer_create(struct wlr_egl *egl, struct wlr_output *output); - -void fx_renderer_fini(struct fx_renderer *renderer); - -void fx_renderer_begin(struct fx_renderer *renderer, int width, int height); - -void fx_renderer_end(struct fx_renderer *renderer); - -void fx_renderer_clear(const float color[static 4]); - -void fx_renderer_scissor(struct wlr_box *box); - -// Initialize the stenciling work -void fx_renderer_stencil_mask_init(); - -// Close the mask -void fx_renderer_stencil_mask_close(bool draw_inside_mask); - -// Finish stenciling and clear the buffer -void fx_renderer_stencil_mask_fini(); - -bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, struct fx_texture *fx_texture, - const struct wlr_fbox *src_box, const struct wlr_box *dst_box, const float matrix[static 9], - struct decoration_data deco_data); - -bool fx_render_texture_with_matrix(struct fx_renderer *renderer, struct fx_texture *fx_texture, - const struct wlr_box *dst_box, const float matrix[static 9], struct decoration_data deco_data); - -void fx_render_rect(struct fx_renderer *renderer, const struct wlr_box *box, - const float color[static 4], const float projection[static 9]); - -void fx_render_rounded_rect(struct fx_renderer *renderer, const struct wlr_box *box, - const float color[static 4], const float matrix[static 9], int radius, - enum corner_location corner_location); - -void fx_render_border_corner(struct fx_renderer *renderer, const struct wlr_box *box, - const float color[static 4], const float matrix[static 9], - enum corner_location corner_location, int radius, int border_thickness); - -void fx_render_box_shadow(struct fx_renderer *renderer, const struct wlr_box *box, - const struct wlr_box *inner_box, const float color[static 4], - const float matrix[static 9], int corner_radius, float blur_sigma); - -void fx_render_blur(struct fx_renderer *renderer, const float matrix[static 9], - struct fx_framebuffer **buffer, struct blur_shader *shader, - const struct wlr_box *box, int blur_radius); - -void fx_render_blur_effects(struct fx_renderer *renderer, const float matrix[static 9], - struct fx_framebuffer **buffer, float blur_noise, float blur_brightness, - float blur_contrast, float blur_saturation); - -#endif diff --git a/include/sway/desktop/fx_renderer/fx_stencilbuffer.h b/include/sway/desktop/fx_renderer/fx_stencilbuffer.h deleted file mode 100644 index 157c0282..00000000 --- a/include/sway/desktop/fx_renderer/fx_stencilbuffer.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef FX_STENCILBUFFER_H -#define FX_STENCILBUFFER_H - -#include <GLES2/gl2.h> -#include <stdbool.h> -#include <wlr/render/wlr_texture.h> - -struct fx_stencilbuffer { - GLuint rb; - int width; - int height; -}; - -struct fx_stencilbuffer fx_stencilbuffer_create(); - -void fx_stencilbuffer_release(struct fx_stencilbuffer *stencil_buffer); - -#endif diff --git a/include/sway/desktop/fx_renderer/fx_texture.h b/include/sway/desktop/fx_renderer/fx_texture.h deleted file mode 100644 index 62e635e6..00000000 --- a/include/sway/desktop/fx_renderer/fx_texture.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FX_TEXTURE_H -#define FX_TEXTURE_H - -#include <GLES2/gl2.h> -#include <stdbool.h> -#include <wlr/render/wlr_texture.h> - -struct fx_texture { - GLuint target; - GLuint id; - bool has_alpha; - int width; - int height; -}; - -struct fx_texture fx_texture_create(); - -struct fx_texture fx_texture_from_wlr_texture(struct wlr_texture *tex); - -void fx_texture_release(struct fx_texture *texture); - -#endif diff --git a/include/sway/desktop/fx_renderer/matrix.h b/include/sway/desktop/fx_renderer/matrix.h deleted file mode 100644 index 6931e8d2..00000000 --- a/include/sway/desktop/fx_renderer/matrix.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _MATRIX_H -#define _MATRIX_H - -#include <wlr/types/wlr_output.h> - -void matrix_projection(float mat[static 9], int width, int height, - enum wl_output_transform transform); - -#endif diff --git a/include/sway/desktop/idle_inhibit_v1.h b/include/sway/desktop/idle_inhibit_v1.h index 58d54c68..84cc666d 100644 --- a/include/sway/desktop/idle_inhibit_v1.h +++ b/include/sway/desktop/idle_inhibit_v1.h @@ -1,8 +1,6 @@ #ifndef _SWAY_DESKTOP_IDLE_INHIBIT_V1_H #define _SWAY_DESKTOP_IDLE_INHIBIT_V1_H #include <wlr/types/wlr_idle_inhibit_v1.h> -#include <wlr/types/wlr_idle.h> -#include "sway/server.h" enum sway_idle_inhibit_mode { INHIBIT_IDLE_APPLICATION, // Application set inhibitor (when visible) @@ -16,12 +14,9 @@ struct sway_idle_inhibit_manager_v1 { struct wlr_idle_inhibit_manager_v1 *wlr_manager; struct wl_listener new_idle_inhibitor_v1; struct wl_list inhibitors; - - struct wlr_idle *idle; }; 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; @@ -33,8 +28,7 @@ struct sway_idle_inhibitor_v1 { bool sway_idle_inhibit_v1_is_active( struct sway_idle_inhibitor_v1 *inhibitor); -void sway_idle_inhibit_v1_check_active( - struct sway_idle_inhibit_manager_v1 *manager); +void sway_idle_inhibit_v1_check_active(void); void sway_idle_inhibit_v1_user_inhibitor_register(struct sway_view *view, enum sway_idle_inhibit_mode mode); @@ -48,6 +42,6 @@ struct sway_idle_inhibitor_v1 *sway_idle_inhibit_v1_application_inhibitor_for_vi void sway_idle_inhibit_v1_user_inhibitor_destroy( struct sway_idle_inhibitor_v1 *inhibitor); -struct sway_idle_inhibit_manager_v1 *sway_idle_inhibit_manager_v1_create( - struct wl_display *wl_display, struct wlr_idle *idle); +bool sway_idle_inhibit_manager_v1_init(void); + #endif diff --git a/include/sway/desktop/launcher.h b/include/sway/desktop/launcher.h index 3b577f74..412068a9 100644 --- a/include/sway/desktop/launcher.h +++ b/include/sway/desktop/launcher.h @@ -2,14 +2,19 @@ #define _SWAY_LAUNCHER_H #include <stdlib.h> +#include <wayland-server-core.h> +#include "sway/input/seat.h" struct launcher_ctx { pid_t pid; - char *name; + char *fallback_name; struct wlr_xdg_activation_token_v1 *token; struct wl_listener token_destroy; + struct sway_seat *seat; + struct wl_listener seat_destroy; bool activated; + bool had_focused_surface; struct sway_node *node; struct wl_listener node_destroy; @@ -25,7 +30,10 @@ void launcher_ctx_consume(struct launcher_ctx *ctx); void launcher_ctx_destroy(struct launcher_ctx *ctx); -struct launcher_ctx *launcher_ctx_create(void); +struct launcher_ctx *launcher_ctx_create_internal(void); + +struct launcher_ctx *launcher_ctx_create( + struct wlr_xdg_activation_token_v1 *token, struct sway_node *node); const char *launcher_ctx_get_token_name(struct launcher_ctx *ctx); diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 8a2898dd..1e21c66f 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h @@ -35,7 +35,6 @@ struct sway_cursor { pixman_region32_t confine; // invalid if active_constraint == NULL bool active_confine_requires_warp; - struct wlr_pointer_gestures_v1 *pointer_gestures; struct wl_listener hold_begin; struct wl_listener hold_end; struct wl_listener pinch_begin; @@ -53,6 +52,7 @@ struct sway_cursor { struct wl_listener touch_down; struct wl_listener touch_up; + struct wl_listener touch_cancel; struct wl_listener touch_motion; struct wl_listener touch_frame; bool simulating_pointer_from_touch; @@ -64,6 +64,7 @@ struct sway_cursor { struct wl_listener tool_proximity; struct wl_listener tool_button; bool simulating_pointer_from_tool_tip; + bool simulating_pointer_from_tool_button; uint32_t tool_buttons; struct wl_listener request_set_cursor; @@ -107,6 +108,10 @@ 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 pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, + struct wlr_input_device *device, double dx, double dy, + double dx_unaccel, double dy_unaccel); + void dispatch_cursor_button(struct sway_cursor *cursor, struct wlr_input_device *device, uint32_t time_msec, uint32_t button, enum wlr_button_state state); @@ -140,4 +145,6 @@ uint32_t get_mouse_button(const char *name, char **error); const char *get_mouse_button_name(uint32_t button); +void handle_request_set_cursor_shape(struct wl_listener *listener, void *data); + #endif diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index c9bd08f0..4bd51709 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h @@ -25,6 +25,7 @@ struct sway_input_manager { struct wlr_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit; struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; struct wlr_virtual_pointer_manager_v1 *virtual_pointer; + struct wlr_pointer_gestures_v1 *pointer_gestures; struct wl_listener new_input; struct wl_listener inhibit_activate; @@ -44,7 +45,7 @@ void input_manager_configure_xcursor(void); void input_manager_apply_input_config(struct input_config *input_config); -void input_manager_configure_all_inputs(void); +void input_manager_configure_all_input_mappings(void); void input_manager_reset_input(struct sway_input_device *input_device); diff --git a/include/sway/input/libinput.h b/include/sway/input/libinput.h index e4b1acc3..1f84a8e3 100644 --- a/include/sway/input/libinput.h +++ b/include/sway/input/libinput.h @@ -4,6 +4,9 @@ bool sway_input_configure_libinput_device(struct sway_input_device *device); +void sway_input_configure_libinput_device_send_events( + 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); diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index e3a46872..6063ead3 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h @@ -4,6 +4,7 @@ #include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> #include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_seat.h> +#include <wlr/types/wlr_touch.h> #include <wlr/util/edges.h> #include "sway/config.h" #include "sway/input/input-manager.h" @@ -11,6 +12,7 @@ #include "sway/input/text_input.h" struct sway_seat; +struct fx_render_context; struct sway_seatop_impl { void (*button)(struct sway_seat *seat, uint32_t time_msec, @@ -36,14 +38,21 @@ struct sway_seatop_impl { void (*swipe_end)(struct sway_seat *seat, struct wlr_pointer_swipe_end_event *event); void (*rebase)(struct sway_seat *seat, uint32_t time_msec); + void (*touch_motion)(struct sway_seat *seat, + struct wlr_touch_motion_event *event, double lx, double ly); + void (*touch_up)(struct sway_seat *seat, + struct wlr_touch_up_event *event); + void (*touch_down)(struct sway_seat *seat, + struct wlr_touch_down_event *event, double lx, double ly); + void (*touch_cancel)(struct sway_seat *seat, + struct wlr_touch_cancel_event *event); void (*tablet_tool_motion)(struct sway_seat *seat, 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); void (*unref)(struct sway_seat *seat, struct sway_container *con); - void (*render)(struct sway_seat *seat, struct sway_output *output, - pixman_region32_t *damage); + void (*render)(struct sway_seat *seat, struct fx_render_context *ctx); bool allow_set_cursor; }; @@ -72,6 +81,7 @@ struct sway_drag_icon { struct wl_list link; // sway_root::drag_icons double x, y; // in layout-local coordinates + int dx, dy; // offset in surface-local coordinates struct wl_listener surface_commit; struct wl_listener map; @@ -94,8 +104,9 @@ struct sway_seat { struct sway_workspace *workspace; char *prev_workspace_name; // for workspace back_and_forth - // If the focused layer is set, views cannot receive keyboard focus struct wlr_layer_surface_v1 *focused_layer; + // If the exclusive layer is set, views cannot receive keyboard focus + bool has_exclusive_layer; // If exclusive_client is set, no other clients will receive input events struct wl_client *exclusive_client; @@ -157,6 +168,9 @@ void seat_add_device(struct sway_seat *seat, void seat_configure_device(struct sway_seat *seat, struct sway_input_device *device); +void seat_configure_device_mapping(struct sway_seat *seat, + struct sway_input_device *input_device); + void seat_reset_device(struct sway_seat *seat, struct sway_input_device *input_device); @@ -255,10 +269,13 @@ 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, double sx, double sy); + 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); + struct wlr_surface *surface, double sx, double sy); + +void seatop_begin_touch_down(struct sway_seat *seat, struct wlr_surface *surface, + struct wlr_touch_down_event *event, double sx, double sy, double lx, double ly); void seatop_begin_move_floating(struct sway_seat *seat, struct sway_container *con); @@ -318,6 +335,18 @@ void seatop_swipe_update(struct sway_seat *seat, void seatop_swipe_end(struct sway_seat *seat, struct wlr_pointer_swipe_end_event *event); +void seatop_touch_motion(struct sway_seat *seat, + struct wlr_touch_motion_event *event, double lx, double ly); + +void seatop_touch_up(struct sway_seat *seat, + struct wlr_touch_up_event *event); + +void seatop_touch_down(struct sway_seat *seat, + struct wlr_touch_down_event *event, double lx, double ly); + +void seatop_touch_cancel(struct sway_seat *seat, + struct wlr_touch_cancel_event *event); + void seatop_rebase(struct sway_seat *seat, uint32_t time_msec); /** @@ -336,8 +365,7 @@ void seatop_unref(struct sway_seat *seat, struct sway_container *con); * Instructs a seatop to render anything that it needs to render * (eg. dropzone for move-tiling) */ -void seatop_render(struct sway_seat *seat, struct sway_output *output, - pixman_region32_t *damage); +void seatop_render(struct sway_seat *seat, struct fx_render_context *ctx); bool seatop_allows_set_cursor(struct sway_seat *seat); diff --git a/include/sway/input/text_input.h b/include/sway/input/text_input.h index c70fd935..214e61d1 100644 --- a/include/sway/input/text_input.h +++ b/include/sway/input/text_input.h @@ -4,12 +4,11 @@ #include <wlr/types/wlr_text_input_v3.h> #include <wlr/types/wlr_input_method_v2.h> #include <wlr/types/wlr_compositor.h> -#include "sway/input/seat.h" /** * The relay structure manages the relationship between text-input and * input_method interfaces on a given seat. Multiple text-input interfaces may - * be bound to a relay, but at most one will be focused (reveiving events) at + * be bound to a relay, but at most one will be focused (receiving events) at * a time. At most one input-method interface may be bound to the seat. The * relay manages life cycle of both sides. When both sides are present and * focused, the relay passes messages between them. diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h index bc4f781a..d4c00942 100644 --- a/include/sway/ipc-server.h +++ b/include/sway/ipc-server.h @@ -21,5 +21,6 @@ void ipc_event_mode(const char *mode, bool pango); void ipc_event_shutdown(const char *reason); void ipc_event_binding(struct sway_binding *binding); void ipc_event_input(const char *change, struct sway_input_device *device); +void ipc_event_output(void); #endif diff --git a/include/sway/layers.h b/include/sway/layers.h index 5871f0d8..bb7cbb22 100644 --- a/include/sway/layers.h +++ b/include/sway/layers.h @@ -60,6 +60,10 @@ struct sway_layer_subsurface { }; struct sway_output; + +struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface( + struct wlr_surface *surface); + void arrange_layers(struct sway_output *output); struct sway_layer_surface *layer_from_wlr_layer_surface_v1( diff --git a/include/sway/output.h b/include/sway/output.h index bd65237e..a60ddec8 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -6,23 +6,33 @@ #include <wlr/types/wlr_damage_ring.h> #include <wlr/types/wlr_output.h> #include "config.h" -#include "sway/desktop/fx_renderer/fx_renderer.h" +#include "scenefx/render/pass.h" #include "sway/tree/node.h" #include "sway/tree/view.h" +struct decoration_data get_undecorated_decoration_data(); + struct sway_server; struct sway_container; +struct decoration_data { + float alpha; + float saturation; + int corner_radius; + float dim; + float *dim_color; + bool has_titlebar; + bool discard_transparent; + bool blur; + bool shadow; +}; + struct render_data { + struct fx_render_context *ctx; pixman_region32_t *damage; struct wlr_box *clip_box; struct decoration_data deco_data; -}; - -struct blur_stencil_data { - struct fx_texture *stencil_texture; - const struct wlr_fbox *stencil_src_box; - float *stencil_matrix; + struct sway_view *view; }; struct sway_output_state { @@ -36,8 +46,6 @@ struct sway_output { struct sway_server *server; struct wl_list link; - struct fx_renderer *renderer; - struct wl_list layers[4]; // sway_layer_surface::link struct wlr_box usable_area; @@ -48,21 +56,20 @@ struct sway_output { int width, height; // transformed buffer size enum wl_output_subpixel detected_subpixel; enum scale_filter_mode scale_filter; - // last applied mode when the output is powered off - struct wlr_output_mode *current_mode; bool enabling, enabled; list_t *workspaces; struct sway_output_state current; + struct wl_listener layout_destroy; struct wl_listener destroy; struct wl_listener commit; - struct wl_listener mode; struct wl_listener present; struct wl_listener damage; struct wl_listener frame; struct wl_listener needs_frame; + struct wl_listener request_state; struct { struct wl_signal disable; @@ -72,6 +79,7 @@ struct sway_output { uint32_t refresh_nsec; int max_render_time; // In milliseconds struct wl_event_source *repaint_timer; + bool gamma_lut_changed; }; struct sway_output_non_desktop { @@ -80,6 +88,14 @@ struct sway_output_non_desktop { struct wl_listener destroy; }; +struct fx_render_context { + struct sway_output *output; + struct wlr_renderer *renderer; + pixman_region32_t *output_damage; + + struct fx_gles_render_pass *pass; +}; + struct sway_output *output_create(struct wlr_output *wlr_output); void output_destroy(struct sway_output *output); @@ -111,6 +127,9 @@ void output_damage_box(struct sway_output *output, struct wlr_box *box); void output_damage_whole_container(struct sway_output *output, struct sway_container *con); +bool output_match_name_or_id(struct sway_output *output, + const char *name_or_id); + // this ONLY includes the enabled outputs struct sway_output *output_by_name_or_id(const char *name_or_id); @@ -127,8 +146,7 @@ bool output_has_opaque_overlay_layer_surface(struct sway_output *output); struct sway_workspace *output_get_active_workspace(struct sway_output *output); -void output_render(struct sway_output *output, struct timespec *when, - pixman_region32_t *damage); +void output_render(struct fx_render_context *ctx); void output_surface_for_each_surface(struct sway_output *output, struct wlr_surface *surface, double ox, double oy, @@ -181,20 +199,16 @@ void output_get_box(struct sway_output *output, struct wlr_box *box); enum sway_container_layout output_get_default_layout( struct sway_output *output); -void render_rect(struct sway_output *output, - pixman_region32_t *output_damage, const struct wlr_box *_box, +void render_rect(struct fx_render_context *ctx, const struct wlr_box *_box, float color[static 4]); -void render_rounded_rect(struct sway_output *output, - pixman_region32_t *output_damage, const struct wlr_box *_box, - float color[static 4], int corner_radius, - enum corner_location corner_location); - -void render_blur(bool optimized, struct sway_output *output, - pixman_region32_t *output_damage, const struct wlr_box *dst_box, - pixman_region32_t *opaque_region, struct decoration_data *deco_data, - struct blur_stencil_data *stencil_data); +void render_rounded_rect(struct fx_render_context *ctx, const struct wlr_box *_box, + float color[static 4], int corner_radius, enum corner_location corner_location); +void render_blur(struct fx_render_context *ctx, struct wlr_texture *texture, + const struct wlr_fbox *src_box, const struct wlr_box *dst_box, + bool optimized_blur, pixman_region32_t *opaque_region, + struct decoration_data deco_data); void premultiply_alpha(float color[4], float opacity); @@ -204,6 +218,8 @@ enum wlr_direction opposite_direction(enum wlr_direction d); void handle_output_layout_change(struct wl_listener *listener, void *data); +void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data); + void handle_output_manager_apply(struct wl_listener *listener, void *data); void handle_output_manager_test(struct wl_listener *listener, void *data); diff --git a/include/sway/server.h b/include/sway/server.h index 96c3623f..ef70ae4e 100644 --- a/include/sway/server.h +++ b/include/sway/server.h @@ -3,14 +3,12 @@ #include <stdbool.h> #include <wayland-server-core.h> #include <wlr/backend.h> -#include <wlr/backend/session.h> #include <wlr/render/allocator.h> #include <wlr/render/wlr_renderer.h> #include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_input_method_v2.h> #include <wlr/types/wlr_foreign_toplevel_management_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> @@ -22,6 +20,7 @@ #include <wlr/types/wlr_xdg_shell.h> #include "config.h" #include "list.h" +#include "sway/desktop/idle_inhibit_v1.h" #if HAVE_XWAYLAND #include "sway/xwayland.h" #endif @@ -34,9 +33,10 @@ struct sway_server { const char *socket; struct wlr_backend *backend; + struct wlr_session *session; // secondary headless backend used for creating virtual outputs on-the-fly struct wlr_backend *headless_backend; - struct wlr_renderer *wlr_renderer; + struct wlr_renderer *renderer; struct wlr_allocator *allocator; struct wlr_compositor *compositor; @@ -51,9 +51,8 @@ struct sway_server { struct wl_listener new_output; struct wl_listener output_layout_change; - struct wlr_idle *idle; struct wlr_idle_notifier_v1 *idle_notifier_v1; - struct sway_idle_inhibit_manager_v1 *idle_inhibit_manager_v1; + struct sway_idle_inhibit_manager_v1 idle_inhibit_manager_v1; struct wlr_layer_shell_v1 *layer_shell; struct wl_listener layer_shell_surface; @@ -91,6 +90,9 @@ struct sway_server { struct wl_listener output_manager_apply; struct wl_listener output_manager_test; + struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1; + struct wl_listener gamma_control_set_gamma; + struct { bool locked; struct wlr_session_lock_manager_v1 *manager; @@ -110,9 +112,17 @@ struct sway_server { struct wlr_input_method_manager_v2 *input_method; struct wlr_text_input_manager_v3 *text_input; struct wlr_foreign_toplevel_manager_v1 *foreign_toplevel_manager; + struct wlr_content_type_manager_v1 *content_type_manager_v1; + struct wlr_data_control_manager_v1 *data_control_manager_v1; + struct wlr_screencopy_manager_v1 *screencopy_manager_v1; + struct wlr_export_dmabuf_manager_v1 *export_dmabuf_manager_v1; + struct wlr_security_context_manager_v1 *security_context_manager_v1; struct wlr_xdg_activation_v1 *xdg_activation_v1; struct wl_listener xdg_activation_v1_request_activate; + struct wl_listener xdg_activation_v1_new_token; + + struct wl_listener request_set_cursor_shape; struct wl_list pending_launcher_ctxs; // launcher_ctx::link @@ -174,6 +184,8 @@ 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); +void xdg_activation_v1_handle_new_token(struct wl_listener *listener, + void *data); void set_rr_scheduling(void); diff --git a/include/sway/surface.h b/include/sway/surface.h index fb1cd775..a7a8ec3f 100644 --- a/include/sway/surface.h +++ b/include/sway/surface.h @@ -15,4 +15,10 @@ struct sway_surface { struct wl_event_source *frame_done_timer; }; +void surface_update_outputs(struct wlr_surface *surface); +void surface_enter_output(struct wlr_surface *surface, + struct sway_output *output); +void surface_leave_output(struct wlr_surface *surface, + struct sway_output *output); + #endif diff --git a/include/sway/swaynag.h b/include/sway/swaynag.h index 74d9ea18..03bd52c3 100644 --- a/include/sway/swaynag.h +++ b/include/sway/swaynag.h @@ -1,6 +1,7 @@ #ifndef _SWAY_SWAYNAG_H #define _SWAY_SWAYNAG_H #include <wayland-server-core.h> +#include "stringop.h" struct swaynag_instance { struct wl_client *client; @@ -21,7 +22,7 @@ bool swaynag_spawn(const char *swaynag_command, // Write a log message to swaynag->fd[1]. This will fail when swaynag->detailed // is false. void swaynag_log(const char *swaynag_command, struct swaynag_instance *swaynag, - const char *fmt, ...); + const char *fmt, ...) _SWAY_ATTRIB_PRINTF(3, 4); // If swaynag->detailed, close swaynag->fd[1] so swaynag displays void swaynag_show(struct swaynag_instance *swaynag); diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 3cd668f9..42fb71bf 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -119,6 +119,11 @@ struct sway_container { float saturation; + // Stores last output size and position for adjusting coordinates of + // scratchpad windows. + // Unused for non-scratchpad windows. + struct wlr_box transform; + float alpha; int corner_radius; @@ -206,6 +211,9 @@ size_t container_titlebar_height(void); void floating_calculate_constraints(int *min_width, int *max_width, int *min_height, int *max_height); +void floating_fix_coordinates(struct sway_container *con, + struct wlr_box *old, struct wlr_box *new); + void container_floating_resize_and_center(struct sway_container *con); void container_floating_set_default_size(struct sway_container *con); diff --git a/include/sway/tree/node.h b/include/sway/tree/node.h index 470ee3b5..03a389a4 100644 --- a/include/sway/tree/node.h +++ b/include/sway/tree/node.h @@ -1,5 +1,6 @@ #ifndef _SWAY_NODE_H #define _SWAY_NODE_H +#include <wayland-server-core.h> #include <stdbool.h> #include "list.h" diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 7b52aa4b..76cfdf3a 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -2,7 +2,7 @@ #define _SWAY_VIEW_H #include <wayland-server-core.h> #include <wlr/types/wlr_compositor.h> -#include "config.h" +#include "sway/config.h" #if HAVE_XWAYLAND #include <wlr/xwayland.h> #endif @@ -162,6 +162,8 @@ struct sway_xwayland_view { struct wl_listener set_window_type; struct wl_listener set_hints; struct wl_listener set_decorations; + struct wl_listener associate; + struct wl_listener dissociate; struct wl_listener map; struct wl_listener unmap; struct wl_listener destroy; @@ -179,6 +181,8 @@ struct sway_xwayland_unmanaged { struct wl_listener request_fullscreen; struct wl_listener commit; struct wl_listener set_geometry; + struct wl_listener associate; + struct wl_listener dissociate; struct wl_listener map; struct wl_listener unmap; struct wl_listener destroy; @@ -273,7 +277,12 @@ void view_set_activated(struct sway_view *view, bool activated); /** * Called when the view requests to be focused. */ -void view_request_activate(struct sway_view *view); +void view_request_activate(struct sway_view *view, struct sway_seat *seat); + +/* + * Called when the view requests urgent state + */ +void view_request_urgent(struct sway_view *view); /** * If possible, instructs the client to change their decoration mode. diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index d25afbb2..1e7d9b82 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -2,6 +2,7 @@ #define _SWAY_WORKSPACE_H #include <stdbool.h> +#include "sway/config.h" #include "sway/tree/container.h" #include "sway/tree/node.h" diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 3ad0bdf3..197d2190 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -4,6 +4,7 @@ #include "config.h" #include "input.h" #include "pool-buffer.h" +#include "cursor-shape-v1-client-protocol.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" #include "xdg-output-unstable-v1-client-protocol.h" @@ -30,6 +31,7 @@ struct swaybar { struct wl_compositor *compositor; struct zwlr_layer_shell_v1 *layer_shell; struct zxdg_output_manager_v1 *xdg_output_manager; + struct wp_cursor_shape_manager_v1 *cursor_shape_manager; struct wl_shm *shm; struct swaybar_config *config; diff --git a/include/swaybar/tray/item.h b/include/swaybar/tray/item.h index c02a5582..73937a0c 100644 --- a/include/swaybar/tray/item.h +++ b/include/swaybar/tray/item.h @@ -4,6 +4,7 @@ #include <cairo.h> #include <stdbool.h> #include <stdint.h> +#include <wayland-util.h> #include "swaybar/tray/tray.h" #include "list.h" diff --git a/include/swaynag/swaynag.h b/include/swaynag/swaynag.h index 2d68b6c9..fb9e9c21 100644 --- a/include/swaynag/swaynag.h +++ b/include/swaynag/swaynag.h @@ -4,6 +4,8 @@ #include <strings.h> #include "list.h" #include "pool-buffer.h" +#include "cursor-shape-v1-client-protocol.h" + #include "swaynag/types.h" #define SWAYNAG_MAX_HEIGHT 500 @@ -58,6 +60,7 @@ struct swaynag_button { struct swaynag_details { bool visible; char *message; + char *details_text; int x; int y; @@ -67,7 +70,7 @@ struct swaynag_details { int offset; int visible_lines; int total_lines; - struct swaynag_button button_details; + struct swaynag_button *button_details; struct swaynag_button button_up; struct swaynag_button button_down; }; @@ -84,6 +87,7 @@ struct swaynag { struct swaynag_output *output; struct zwlr_layer_shell_v1 *layer_shell; struct zwlr_layer_surface_v1 *layer_surface; + struct wp_cursor_shape_manager_v1 *cursor_shape_manager; struct wl_surface *surface; uint32_t width; diff --git a/include/swaynag/types.h b/include/swaynag/types.h index 18f218e0..9c3c50db 100644 --- a/include/swaynag/types.h +++ b/include/swaynag/types.h @@ -1,10 +1,13 @@ #ifndef _SWAYNAG_TYPES_H #define _SWAYNAG_TYPES_H +#include <stdint.h> +#include <pango/pangocairo.h> +#include "list.h" + struct swaynag_type { char *name; - char *font; // Used for debugging. PangoFontDescription *font_description; char *output; uint32_t anchors; |