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;
|
|
|
|
struct sway_view;
|
|
|
|
|
|
|
|
struct sway_xdg_surface_v6 {
|
|
|
|
struct sway_view *view;
|
|
|
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
struct wl_listener request_move;
|
|
|
|
struct wl_listener request_resize;
|
|
|
|
struct wl_listener request_maximize;
|
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
|
|
|
};
|
|
|
|
|
2017-12-04 22:19:36 +11:00
|
|
|
struct sway_xwayland_surface {
|
|
|
|
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_configure;
|
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;
|
|
|
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
};
|
|
|
|
|
2017-12-04 06:21:26 +11:00
|
|
|
struct sway_wl_shell_surface {
|
|
|
|
struct sway_view *view;
|
|
|
|
|
|
|
|
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;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
enum sway_view_type {
|
|
|
|
SWAY_WL_SHELL_VIEW,
|
|
|
|
SWAY_XDG_SHELL_V6_VIEW,
|
|
|
|
SWAY_XWAYLAND_VIEW,
|
|
|
|
// Keep last
|
|
|
|
SWAY_VIEW_TYPES,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum sway_view_prop {
|
|
|
|
VIEW_PROP_TITLE,
|
|
|
|
VIEW_PROP_APP_ID,
|
|
|
|
VIEW_PROP_CLASS,
|
|
|
|
VIEW_PROP_INSTANCE,
|
|
|
|
};
|
|
|
|
|
2018-04-01 08:07:44 +10:00
|
|
|
struct sway_view_impl {
|
|
|
|
const char *(*get_prop)(struct sway_view *view,
|
|
|
|
enum sway_view_prop prop);
|
2018-04-03 00:57:45 +10:00
|
|
|
void (*configure)(struct sway_view *view, double ox, double oy, int width,
|
|
|
|
int height);
|
2018-04-01 08:07:44 +10:00
|
|
|
void (*set_activated)(struct sway_view *view, bool activated);
|
|
|
|
void (*close)(struct sway_view *view);
|
|
|
|
};
|
|
|
|
|
2017-11-12 10:06:50 +11:00
|
|
|
struct sway_view {
|
|
|
|
enum sway_view_type type;
|
2018-04-01 08:07:44 +10:00
|
|
|
const struct sway_view_impl *impl;
|
|
|
|
|
|
|
|
struct sway_container *swayc; // NULL for unmanaged views
|
|
|
|
struct wlr_surface *surface; // NULL for unmapped views
|
2017-11-26 07:49:10 +11:00
|
|
|
int width, height;
|
2017-11-12 10:06:50 +11:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;
|
2017-12-04 22:19:36 +11:00
|
|
|
struct wlr_xwayland_surface *wlr_xwayland_surface;
|
2017-12-04 02:49:13 +11:00
|
|
|
struct wlr_wl_shell_surface *wlr_wl_shell_surface;
|
2017-11-12 10:06:50 +11:00
|
|
|
};
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct sway_xdg_surface_v6 *sway_xdg_surface_v6;
|
2017-12-04 22:19:36 +11:00
|
|
|
struct sway_xwayland_surface *sway_xwayland_surface;
|
2017-12-04 02:49:13 +11:00
|
|
|
struct sway_wl_shell_surface *sway_wl_shell_surface;
|
2017-11-12 10:06:50 +11:00
|
|
|
};
|
|
|
|
|
2018-01-15 05:19:21 +11:00
|
|
|
// only used for unmanaged views (shell specific)
|
2018-04-01 07:49:40 +10:00
|
|
|
struct wl_list unmanaged_view_link; // sway_root::unmanaged_views
|
2017-11-12 10:06:50 +11:00
|
|
|
};
|
|
|
|
|
2018-04-01 08:07:44 +10:00
|
|
|
struct sway_view *view_create(enum sway_view_type type,
|
|
|
|
const struct sway_view_impl *impl);
|
2018-04-01 07:49:40 +10:00
|
|
|
|
|
|
|
void view_destroy(struct sway_view *view);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
void view_close(struct sway_view *view);
|
|
|
|
|
2018-04-03 00:57:45 +10:00
|
|
|
void view_damage_whole(struct sway_view *view);
|
|
|
|
|
|
|
|
void view_damage_from(struct sway_view *view);
|
|
|
|
|
|
|
|
// view implementation
|
|
|
|
|
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
|
|
|
|
2017-11-12 10:06:50 +11:00
|
|
|
#endif
|