2017-11-12 10:06:50 +11:00
|
|
|
#ifndef _SWAY_VIEW_H
|
|
|
|
#define _SWAY_VIEW_H
|
|
|
|
#include <wayland-server.h>
|
2017-11-23 13:06:08 +11:00
|
|
|
#include <wlr/types/wlr_surface.h>
|
2017-11-12 10:06:50 +11:00
|
|
|
#include <wlr/types/wlr_xdg_shell_v6.h>
|
2018-07-25 21:32:20 +10:00
|
|
|
#include "config.h"
|
2018-07-25 06:16:06 +10:00
|
|
|
#ifdef HAVE_XWAYLAND
|
2017-12-04 22:19:36 +11:00
|
|
|
#include <wlr/xwayland.h>
|
2018-07-25 06:16:06 +10:00
|
|
|
#endif
|
2018-04-01 07:49:40 +10:00
|
|
|
#include "sway/input/input-manager.h"
|
|
|
|
#include "sway/input/seat.h"
|
2017-11-12 10:06:50 +11:00
|
|
|
|
|
|
|
struct sway_container;
|
|
|
|
|
2018-04-06 01:38:14 +10:00
|
|
|
enum sway_view_type {
|
|
|
|
SWAY_VIEW_XDG_SHELL_V6,
|
2018-05-14 01:38:56 +10:00
|
|
|
SWAY_VIEW_XDG_SHELL,
|
2018-07-25 07:37:41 +10:00
|
|
|
#ifdef HAVE_XWAYLAND
|
2018-04-06 01:38:14 +10:00
|
|
|
SWAY_VIEW_XWAYLAND,
|
2018-07-25 07:37:41 +10:00
|
|
|
#endif
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
enum sway_view_prop {
|
|
|
|
VIEW_PROP_TITLE,
|
|
|
|
VIEW_PROP_APP_ID,
|
|
|
|
VIEW_PROP_CLASS,
|
|
|
|
VIEW_PROP_INSTANCE,
|
2018-05-13 08:16:36 +10:00
|
|
|
VIEW_PROP_WINDOW_TYPE,
|
|
|
|
VIEW_PROP_WINDOW_ROLE,
|
2018-07-25 07:37:41 +10:00
|
|
|
#ifdef HAVE_XWAYLAND
|
2018-05-13 08:16:36 +10:00
|
|
|
VIEW_PROP_X11_WINDOW_ID,
|
2018-07-25 07:37:41 +10:00
|
|
|
#endif
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sway_view_impl {
|
2018-07-21 12:13:00 +10:00
|
|
|
void (*get_constraints)(struct sway_view *view, double *min_width,
|
|
|
|
double *max_width, double *min_height, double *max_height);
|
2018-05-13 08:16:36 +10:00
|
|
|
const char *(*get_string_prop)(struct sway_view *view,
|
2018-04-06 01:38:14 +10:00
|
|
|
enum sway_view_prop prop);
|
2018-05-13 08:16:36 +10:00
|
|
|
uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop);
|
2018-06-03 16:35:06 +10:00
|
|
|
uint32_t (*configure)(struct sway_view *view, double lx, double ly,
|
|
|
|
int width, int height);
|
2018-04-06 01:38:14 +10:00
|
|
|
void (*set_activated)(struct sway_view *view, bool activated);
|
2018-06-28 02:53:13 +10:00
|
|
|
void (*set_tiled)(struct sway_view *view, bool tiled);
|
2018-04-16 20:36:40 +10:00
|
|
|
void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
|
2018-05-24 22:30:44 +10:00
|
|
|
bool (*wants_floating)(struct sway_view *view);
|
2018-07-13 05:01:33 +10:00
|
|
|
bool (*has_client_side_decorations)(struct sway_view *view);
|
2018-04-07 00:26:32 +10:00
|
|
|
void (*for_each_surface)(struct sway_view *view,
|
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
2018-04-06 01:38:14 +10:00
|
|
|
void (*close)(struct sway_view *view);
|
2018-06-26 13:18:33 +10:00
|
|
|
void (*destroy)(struct sway_view *view);
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sway_view {
|
|
|
|
enum sway_view_type type;
|
|
|
|
const struct sway_view_impl *impl;
|
|
|
|
|
2018-04-24 20:14:22 +10:00
|
|
|
struct sway_container *swayc; // NULL for unmapped views
|
2018-04-06 01:38:14 +10:00
|
|
|
struct wlr_surface *surface; // NULL for unmapped views
|
2018-04-30 21:24:13 +10:00
|
|
|
|
2018-05-26 16:26:10 +10:00
|
|
|
// Geometry of the view itself (excludes borders) in layout coordinates
|
2018-04-30 21:24:13 +10:00
|
|
|
double x, y;
|
2018-04-06 01:38:14 +10:00
|
|
|
int width, height;
|
2018-04-30 21:24:13 +10:00
|
|
|
|
2018-05-31 18:21:49 +10:00
|
|
|
double saved_x, saved_y;
|
|
|
|
int saved_width, saved_height;
|
|
|
|
|
2018-05-24 22:30:44 +10:00
|
|
|
// The size the view would want to be if it weren't tiled.
|
|
|
|
// Used when changing a view from tiled to floating.
|
|
|
|
int natural_width, natural_height;
|
|
|
|
|
2018-05-05 12:36:50 +10:00
|
|
|
char *title_format;
|
2018-04-30 21:24:13 +10:00
|
|
|
enum sway_container_border border;
|
|
|
|
int border_thickness;
|
2018-05-14 14:20:34 +10:00
|
|
|
bool border_top;
|
|
|
|
bool border_bottom;
|
|
|
|
bool border_left;
|
|
|
|
bool border_right;
|
2018-07-17 10:14:33 +10:00
|
|
|
bool using_csd;
|
2018-04-30 21:24:13 +10:00
|
|
|
|
2018-07-15 22:43:33 +10:00
|
|
|
struct timespec urgent;
|
|
|
|
bool allow_request_urgent;
|
|
|
|
struct wl_event_source *urgent_timer;
|
|
|
|
|
2018-06-23 16:24:11 +10:00
|
|
|
bool destroying;
|
|
|
|
|
2018-05-14 22:47:10 +10:00
|
|
|
list_t *executed_criteria; // struct criteria *
|
|
|
|
list_t *marks; // char *
|
2018-05-13 08:16:36 +10:00
|
|
|
|
2018-05-15 13:14:18 +10:00
|
|
|
struct wlr_texture *marks_focused;
|
|
|
|
struct wlr_texture *marks_focused_inactive;
|
|
|
|
struct wlr_texture *marks_unfocused;
|
|
|
|
struct wlr_texture *marks_urgent;
|
|
|
|
|
2018-04-06 01:38:14 +10:00
|
|
|
union {
|
|
|
|
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
|
2018-05-14 01:38:56 +10:00
|
|
|
struct wlr_xdg_surface *wlr_xdg_surface;
|
2018-07-25 07:37:41 +10:00
|
|
|
#ifdef HAVE_XWAYLAND
|
2018-04-06 01:38:14 +10:00
|
|
|
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
2018-07-25 07:37:41 +10:00
|
|
|
#endif
|
2018-04-06 01:38:14 +10:00
|
|
|
struct wlr_wl_shell_surface *wlr_wl_shell_surface;
|
|
|
|
};
|
2018-04-06 04:46:02 +10:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal unmap;
|
|
|
|
} events;
|
|
|
|
|
|
|
|
struct wl_listener surface_new_subsurface;
|
2018-04-06 13:50:21 +10:00
|
|
|
struct wl_listener container_reparent;
|
2018-04-06 01:38:14 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sway_xdg_shell_v6_view {
|
|
|
|
struct sway_view view;
|
2017-11-12 10:06:50 +11:00
|
|
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
struct wl_listener request_move;
|
|
|
|
struct wl_listener request_resize;
|
|
|
|
struct wl_listener request_maximize;
|
2018-04-16 20:36:40 +10:00
|
|
|
struct wl_listener request_fullscreen;
|
2018-07-23 07:20:07 +10:00
|
|
|
struct wl_listener set_title;
|
|
|
|
struct wl_listener set_app_id;
|
2018-04-06 06:48:11 +10:00
|
|
|
struct wl_listener new_popup;
|
2018-03-31 08:43:43 +11:00
|
|
|
struct wl_listener map;
|
|
|
|
struct wl_listener unmap;
|
2017-11-26 08:30:15 +11:00
|
|
|
struct wl_listener destroy;
|
2017-11-12 10:06:50 +11:00
|
|
|
};
|
|
|
|
|
2018-05-14 01:38:56 +10:00
|
|
|
struct sway_xdg_shell_view {
|
|
|
|
struct sway_view 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;
|
2018-07-23 07:20:07 +10:00
|
|
|
struct wl_listener set_title;
|
|
|
|
struct wl_listener set_app_id;
|
2018-05-14 01:38:56 +10:00
|
|
|
struct wl_listener new_popup;
|
|
|
|
struct wl_listener map;
|
|
|
|
struct wl_listener unmap;
|
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
2018-07-25 06:16:06 +10:00
|
|
|
#ifdef HAVE_XWAYLAND
|
2018-04-06 01:38:14 +10:00
|
|
|
struct sway_xwayland_view {
|
|
|
|
struct sway_view view;
|
2017-12-04 22:19:36 +11:00
|
|
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
struct wl_listener request_move;
|
|
|
|
struct wl_listener request_resize;
|
|
|
|
struct wl_listener request_maximize;
|
|
|
|
struct wl_listener request_configure;
|
2018-04-16 20:36:40 +10:00
|
|
|
struct wl_listener request_fullscreen;
|
2018-05-13 08:16:36 +10:00
|
|
|
struct wl_listener set_title;
|
|
|
|
struct wl_listener set_class;
|
|
|
|
struct wl_listener set_window_type;
|
2018-07-19 21:08:51 +10:00
|
|
|
struct wl_listener set_hints;
|
2018-03-31 04:34:25 +11:00
|
|
|
struct wl_listener map;
|
2018-03-31 08:43:43 +11:00
|
|
|
struct wl_listener unmap;
|
2017-12-04 22:19:36 +11:00
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
|
|
|
|
2018-04-03 04:35:43 +10:00
|
|
|
struct sway_xwayland_unmanaged {
|
|
|
|
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
|
|
|
struct wl_list link;
|
|
|
|
|
2018-04-06 08:48:35 +10:00
|
|
|
int lx, ly;
|
|
|
|
|
2018-04-06 07:22:39 +10:00
|
|
|
struct wl_listener request_configure;
|
2018-04-16 20:36:40 +10:00
|
|
|
struct wl_listener request_fullscreen;
|
2018-04-06 07:08:30 +10:00
|
|
|
struct wl_listener commit;
|
|
|
|
struct wl_listener map;
|
|
|
|
struct wl_listener unmap;
|
2018-04-03 04:35:43 +10:00
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
2018-07-25 06:16:06 +10:00
|
|
|
#endif
|
2018-04-06 04:46:02 +10:00
|
|
|
struct sway_view_child;
|
|
|
|
|
|
|
|
struct sway_view_child_impl {
|
|
|
|
void (*destroy)(struct sway_view_child *child);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A view child is a surface in the view tree, such as a subsurface or a popup.
|
|
|
|
*/
|
|
|
|
struct sway_view_child {
|
|
|
|
const struct sway_view_child_impl *impl;
|
|
|
|
|
|
|
|
struct sway_view *view;
|
|
|
|
struct wlr_surface *surface;
|
|
|
|
|
|
|
|
struct wl_listener surface_commit;
|
|
|
|
struct wl_listener surface_new_subsurface;
|
|
|
|
struct wl_listener surface_destroy;
|
|
|
|
struct wl_listener view_unmap;
|
|
|
|
};
|
|
|
|
|
2018-04-06 06:48:11 +10:00
|
|
|
struct sway_xdg_popup_v6 {
|
|
|
|
struct sway_view_child child;
|
|
|
|
|
|
|
|
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
|
|
|
|
|
|
|
|
struct wl_listener new_popup;
|
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
|
|
|
|
2018-05-14 01:38:56 +10:00
|
|
|
struct sway_xdg_popup {
|
|
|
|
struct sway_view_child child;
|
|
|
|
|
|
|
|
struct wlr_xdg_surface *wlr_xdg_surface;
|
|
|
|
|
|
|
|
struct wl_listener new_popup;
|
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
|
|
|
|
2018-01-22 01:09:53 +11:00
|
|
|
const char *view_get_title(struct sway_view *view);
|
|
|
|
|
|
|
|
const char *view_get_app_id(struct sway_view *view);
|
|
|
|
|
|
|
|
const char *view_get_class(struct sway_view *view);
|
|
|
|
|
|
|
|
const char *view_get_instance(struct sway_view *view);
|
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
uint32_t view_get_x11_window_id(struct sway_view *view);
|
|
|
|
|
2018-05-13 08:17:46 +10:00
|
|
|
const char *view_get_window_role(struct sway_view *view);
|
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
uint32_t view_get_window_type(struct sway_view *view);
|
|
|
|
|
2018-05-27 21:59:38 +10:00
|
|
|
const char *view_get_shell(struct sway_view *view);
|
2018-05-05 12:36:50 +10:00
|
|
|
|
2018-07-21 12:13:00 +10:00
|
|
|
void view_get_constraints(struct sway_view *view, double *min_width,
|
|
|
|
double *max_width, double *min_height, double *max_height);
|
|
|
|
|
2018-06-03 16:35:06 +10:00
|
|
|
uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
2018-04-03 00:57:45 +10:00
|
|
|
int height);
|
2018-01-22 01:09:53 +11:00
|
|
|
|
2018-05-01 17:36:12 +10:00
|
|
|
/**
|
|
|
|
* Configure the view's position and size based on the swayc's position and
|
|
|
|
* size, taking borders into consideration.
|
|
|
|
*/
|
2018-04-30 21:24:13 +10:00
|
|
|
void view_autoconfigure(struct sway_view *view);
|
|
|
|
|
2018-01-22 01:09:53 +11:00
|
|
|
void view_set_activated(struct sway_view *view, bool activated);
|
|
|
|
|
2018-06-28 02:53:13 +10:00
|
|
|
void view_set_tiled(struct sway_view *view, bool tiled);
|
|
|
|
|
2018-01-22 01:09:53 +11:00
|
|
|
void view_close(struct sway_view *view);
|
|
|
|
|
2018-05-06 04:43:12 +10:00
|
|
|
void view_damage_from(struct sway_view *view);
|
2018-04-03 00:57:45 +10:00
|
|
|
|
2018-04-07 00:26:32 +10:00
|
|
|
void view_for_each_surface(struct sway_view *view,
|
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
|
|
|
|
2018-04-03 00:57:45 +10:00
|
|
|
// view implementation
|
|
|
|
|
2018-04-06 01:38:14 +10:00
|
|
|
void view_init(struct sway_view *view, enum sway_view_type type,
|
|
|
|
const struct sway_view_impl *impl);
|
|
|
|
|
2018-06-23 16:24:11 +10:00
|
|
|
void view_free(struct sway_view *view);
|
|
|
|
|
2018-04-06 01:38:14 +10:00
|
|
|
void view_destroy(struct sway_view *view);
|
|
|
|
|
2018-04-01 07:49:40 +10:00
|
|
|
void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
|
|
|
|
|
2018-06-26 13:15:45 +10:00
|
|
|
void view_unmap(struct sway_view *view);
|
2018-02-26 09:23:36 +11:00
|
|
|
|
2018-05-24 22:30:44 +10:00
|
|
|
void view_update_position(struct sway_view *view, double lx, double ly);
|
2018-05-01 19:59:36 +10:00
|
|
|
|
2018-04-03 00:57:45 +10:00
|
|
|
void view_update_size(struct sway_view *view, int width, int height);
|
2018-03-31 04:18:50 +11:00
|
|
|
|
2018-04-06 04:46:02 +10:00
|
|
|
void view_child_init(struct sway_view_child *child,
|
|
|
|
const struct sway_view_child_impl *impl, struct sway_view *view,
|
|
|
|
struct wlr_surface *surface);
|
|
|
|
|
|
|
|
void view_child_destroy(struct sway_view_child *child);
|
|
|
|
|
2018-06-30 15:00:24 +10:00
|
|
|
|
|
|
|
struct sway_view *view_from_wlr_xdg_surface(
|
|
|
|
struct wlr_xdg_surface *xdg_surface);
|
|
|
|
struct sway_view *view_from_wlr_xdg_surface_v6(
|
|
|
|
struct wlr_xdg_surface_v6 *xdg_surface_v6);
|
2018-07-25 06:16:06 +10:00
|
|
|
#ifdef HAVE_XWAYLAND
|
2018-06-30 15:00:24 +10:00
|
|
|
struct sway_view *view_from_wlr_xwayland_surface(
|
|
|
|
struct wlr_xwayland_surface *xsurface);
|
2018-07-25 06:16:06 +10:00
|
|
|
#endif
|
2018-06-30 15:00:24 +10:00
|
|
|
struct sway_view *view_from_wlr_surface(struct wlr_surface *surface);
|
|
|
|
|
2018-05-05 12:36:50 +10:00
|
|
|
/**
|
|
|
|
* Re-read the view's title property and update any relevant title bars.
|
|
|
|
* The force argument makes it recreate the title bars even if the title hasn't
|
|
|
|
* changed.
|
|
|
|
*/
|
|
|
|
void view_update_title(struct sway_view *view, bool force);
|
|
|
|
|
2018-05-13 08:16:36 +10:00
|
|
|
/**
|
|
|
|
* Run any criteria that match the view and haven't been run on this view
|
|
|
|
* before.
|
|
|
|
*/
|
|
|
|
void view_execute_criteria(struct sway_view *view);
|
|
|
|
|
2018-05-14 22:47:10 +10:00
|
|
|
/**
|
|
|
|
* Find any view that has the given mark and remove the mark from the view.
|
|
|
|
* Returns true if it matched a view.
|
|
|
|
*/
|
|
|
|
bool view_find_and_unmark(char *mark);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all marks from the view.
|
|
|
|
*/
|
|
|
|
void view_clear_marks(struct sway_view *view);
|
|
|
|
|
|
|
|
bool view_has_mark(struct sway_view *view, char *mark);
|
|
|
|
|
2018-07-14 20:10:36 +10:00
|
|
|
void view_add_mark(struct sway_view *view, char *mark);
|
|
|
|
|
2018-05-15 13:14:18 +10:00
|
|
|
void view_update_marks_textures(struct sway_view *view);
|
|
|
|
|
2018-05-20 09:11:55 +10:00
|
|
|
/**
|
|
|
|
* Returns true if there's a possibility the view may be rendered on screen.
|
|
|
|
* Intended for damage tracking.
|
|
|
|
*/
|
|
|
|
bool view_is_visible(struct sway_view *view);
|
|
|
|
|
2018-07-15 22:43:33 +10:00
|
|
|
void view_set_urgent(struct sway_view *view, bool enable);
|
|
|
|
|
|
|
|
bool view_is_urgent(struct sway_view *view);
|
|
|
|
|
2017-11-12 10:06:50 +11:00
|
|
|
#endif
|