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>
|
2017-12-04 22:19:36 +11:00
|
|
|
#include <wlr/xwayland.h>
|
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_WL_SHELL,
|
|
|
|
SWAY_VIEW_XDG_SHELL_V6,
|
|
|
|
SWAY_VIEW_XWAYLAND,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum sway_view_prop {
|
|
|
|
VIEW_PROP_TITLE,
|
|
|
|
VIEW_PROP_APP_ID,
|
|
|
|
VIEW_PROP_CLASS,
|
|
|
|
VIEW_PROP_INSTANCE,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sway_view_impl {
|
|
|
|
const char *(*get_prop)(struct sway_view *view,
|
|
|
|
enum sway_view_prop prop);
|
|
|
|
void (*configure)(struct sway_view *view, double ox, double oy, int width,
|
|
|
|
int height);
|
|
|
|
void (*set_activated)(struct sway_view *view, bool activated);
|
2018-04-16 20:36:40 +10:00
|
|
|
void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
|
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);
|
|
|
|
void (*destroy)(struct sway_view *view);
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
|
int width, height;
|
2018-04-16 20:36:40 +10:00
|
|
|
bool is_fullscreen;
|
2018-04-06 01:38:14 +10:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
|
|
|
|
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
|
|
|
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-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-26 07:49:10 +11:00
|
|
|
|
|
|
|
int pending_width, pending_height;
|
2017-11-12 10:06:50 +11:00
|
|
|
};
|
|
|
|
|
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-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;
|
|
|
|
|
|
|
|
int pending_width, pending_height;
|
|
|
|
};
|
|
|
|
|
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-04-06 01:38:14 +10:00
|
|
|
struct sway_wl_shell_view {
|
|
|
|
struct sway_view view;
|
2017-12-04 06:21:26 +11:00
|
|
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
struct wl_listener request_move;
|
2017-11-12 10:06:50 +11:00
|
|
|
struct wl_listener request_resize;
|
|
|
|
struct wl_listener request_maximize;
|
2018-04-16 20:36:40 +10:00
|
|
|
struct wl_listener request_fullscreen;
|
2018-04-18 00:10:32 +10:00
|
|
|
struct wl_listener set_state;
|
2017-11-26 08:30:15 +11:00
|
|
|
struct wl_listener destroy;
|
2017-11-26 07:49:10 +11:00
|
|
|
|
|
|
|
int pending_width, pending_height;
|
2017-11-12 10:06:50 +11:00
|
|
|
};
|
|
|
|
|
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 unmap;
|
|
|
|
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-04-03 00:57:45 +10:00
|
|
|
void view_configure(struct sway_view *view, double ox, double oy, int width,
|
|
|
|
int height);
|
2018-01-22 01:09:53 +11:00
|
|
|
|
|
|
|
void view_set_activated(struct sway_view *view, bool activated);
|
|
|
|
|
2018-04-16 20:36:40 +10:00
|
|
|
void view_set_fullscreen(struct sway_view *view, bool fullscreen);
|
|
|
|
|
2018-01-22 01:09:53 +11:00
|
|
|
void view_close(struct sway_view *view);
|
|
|
|
|
2018-04-07 01:27:40 +10:00
|
|
|
void view_damage(struct sway_view *view, bool whole);
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
void view_unmap(struct sway_view *view);
|
2018-02-26 09:23:36 +11:00
|
|
|
|
2018-04-03 00:57:45 +10:00
|
|
|
void view_update_position(struct sway_view *view, double ox, double oy);
|
2018-03-31 04:18:50 +11: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);
|
|
|
|
|
2017-11-12 10:06:50 +11:00
|
|
|
#endif
|