2019-12-21 14:06:56 +00:00
|
|
|
/* Copyright (c), Charlotte Meyer <dev@buffet.sh>
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KIWMI_DESKTOP_VIEW_H
|
|
|
|
#define KIWMI_DESKTOP_VIEW_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-01-19 23:36:12 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2019-12-21 14:06:56 +00:00
|
|
|
#include <wayland-server.h>
|
|
|
|
#include <wlr/types/wlr_xdg_shell.h>
|
2020-01-08 17:24:13 +00:00
|
|
|
#include <wlr/util/edges.h>
|
2019-12-21 14:06:56 +00:00
|
|
|
|
2020-01-19 23:36:12 +00:00
|
|
|
enum kiwmi_view_prop {
|
|
|
|
KIWMI_VIEW_PROP_APP_ID,
|
|
|
|
KIWMI_VIEW_PROP_TITLE,
|
|
|
|
};
|
|
|
|
|
2019-12-21 14:06:56 +00:00
|
|
|
enum kiwmi_view_type {
|
|
|
|
KIWMI_VIEW_XDG_SHELL,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct kiwmi_view {
|
|
|
|
struct wl_list link;
|
2021-08-27 13:06:12 +00:00
|
|
|
struct wl_list children; // struct kiwmi_view_child::link
|
2019-12-21 14:06:56 +00:00
|
|
|
|
|
|
|
struct kiwmi_desktop *desktop;
|
|
|
|
|
|
|
|
const struct kiwmi_view_impl *impl;
|
|
|
|
|
|
|
|
enum kiwmi_view_type type;
|
|
|
|
union {
|
|
|
|
struct wlr_xdg_surface *xdg_surface;
|
|
|
|
};
|
|
|
|
|
2019-12-26 20:55:10 +00:00
|
|
|
struct wlr_surface *wlr_surface;
|
|
|
|
|
2020-01-19 17:28:19 +00:00
|
|
|
struct wlr_box geom;
|
|
|
|
|
2019-12-21 14:06:56 +00:00
|
|
|
struct wl_listener map;
|
|
|
|
struct wl_listener unmap;
|
2020-01-19 17:28:19 +00:00
|
|
|
struct wl_listener commit;
|
2019-12-21 14:06:56 +00:00
|
|
|
struct wl_listener destroy;
|
2021-08-27 13:06:12 +00:00
|
|
|
struct wl_listener new_popup;
|
|
|
|
struct wl_listener new_subsurface;
|
2020-01-17 19:51:56 +00:00
|
|
|
struct wl_listener request_move;
|
|
|
|
struct wl_listener request_resize;
|
2019-12-21 14:06:56 +00:00
|
|
|
|
2020-01-26 19:28:00 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
2019-12-21 14:06:56 +00:00
|
|
|
|
|
|
|
bool mapped;
|
2019-12-31 17:31:18 +00:00
|
|
|
bool hidden;
|
2020-01-02 23:39:15 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct wl_signal unmap;
|
2020-01-20 23:21:17 +00:00
|
|
|
struct wl_signal request_move;
|
|
|
|
struct wl_signal request_resize;
|
2020-01-26 19:18:52 +00:00
|
|
|
struct wl_signal post_render;
|
|
|
|
struct wl_signal pre_render;
|
2020-01-02 23:39:15 +00:00
|
|
|
} events;
|
2020-01-21 19:47:51 +00:00
|
|
|
|
|
|
|
struct kiwmi_xdg_decoration *decoration;
|
2019-12-21 14:06:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct kiwmi_view_impl {
|
2019-12-30 23:23:35 +00:00
|
|
|
void (*close)(struct kiwmi_view *view);
|
2021-11-24 19:55:20 +00:00
|
|
|
void (*for_each_surface)(
|
2019-12-21 14:06:56 +00:00
|
|
|
struct kiwmi_view *view,
|
2021-08-27 13:13:37 +00:00
|
|
|
wlr_surface_iterator_func_t callback,
|
2019-12-21 14:06:56 +00:00
|
|
|
void *user_data);
|
2020-01-19 23:36:12 +00:00
|
|
|
pid_t (*get_pid)(struct kiwmi_view *view);
|
2019-12-26 20:55:10 +00:00
|
|
|
void (*set_activated)(struct kiwmi_view *view, bool activated);
|
2020-01-08 16:39:20 +00:00
|
|
|
void (*set_size)(struct kiwmi_view *view, uint32_t width, uint32_t height);
|
2020-01-19 23:36:12 +00:00
|
|
|
const char *(
|
|
|
|
*get_string_prop)(struct kiwmi_view *view, enum kiwmi_view_prop prop);
|
2020-01-08 17:24:13 +00:00
|
|
|
void (*set_tiled)(struct kiwmi_view *view, enum wlr_edges edges);
|
2019-12-26 20:55:10 +00:00
|
|
|
struct wlr_surface *(*surface_at)(
|
|
|
|
struct kiwmi_view *view,
|
|
|
|
double sx,
|
|
|
|
double sy,
|
|
|
|
double *sub_x,
|
|
|
|
double *sub_y);
|
2019-12-21 14:06:56 +00:00
|
|
|
};
|
|
|
|
|
2021-08-27 13:06:12 +00:00
|
|
|
enum kiwmi_view_child_type {
|
|
|
|
KIWMI_VIEW_CHILD_SUBSURFACE,
|
|
|
|
KIWMI_VIEW_CHILD_XDG_POPUP,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct kiwmi_view_child {
|
|
|
|
struct wl_list link;
|
|
|
|
struct wl_list children; // struct kiwmi_view_child::link
|
|
|
|
|
|
|
|
struct kiwmi_view *view;
|
|
|
|
struct kiwmi_view_child *parent;
|
|
|
|
|
|
|
|
enum kiwmi_view_child_type type;
|
|
|
|
const struct kiwmi_view_child_impl *impl;
|
|
|
|
|
|
|
|
struct wlr_surface *wlr_surface;
|
|
|
|
union {
|
|
|
|
struct wlr_subsurface *wlr_subsurface;
|
|
|
|
struct wlr_xdg_popup *wlr_xdg_popup;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool mapped;
|
|
|
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
struct wl_listener map;
|
|
|
|
struct wl_listener unmap;
|
|
|
|
struct wl_listener new_popup;
|
|
|
|
struct wl_listener new_subsurface;
|
|
|
|
struct wl_listener extension_destroy; // the union'ed object destroy
|
|
|
|
struct wl_listener surface_destroy; // wlr_surface::events.destroy
|
|
|
|
};
|
|
|
|
|
|
|
|
struct kiwmi_view_child_impl {
|
|
|
|
void (*reconfigure)(struct kiwmi_view_child *child);
|
|
|
|
};
|
|
|
|
|
2020-01-20 23:21:17 +00:00
|
|
|
struct kiwmi_request_resize_event {
|
|
|
|
struct kiwmi_view *view;
|
|
|
|
uint32_t edges;
|
|
|
|
};
|
|
|
|
|
2019-12-30 23:23:35 +00:00
|
|
|
void view_close(struct kiwmi_view *view);
|
2021-11-24 19:55:20 +00:00
|
|
|
void view_for_each_surface(
|
2019-12-21 14:06:56 +00:00
|
|
|
struct kiwmi_view *view,
|
2021-08-27 13:13:37 +00:00
|
|
|
wlr_surface_iterator_func_t callback,
|
2019-12-21 14:06:56 +00:00
|
|
|
void *user_data);
|
2020-01-19 23:36:12 +00:00
|
|
|
pid_t view_get_pid(struct kiwmi_view *view);
|
2020-01-08 22:26:17 +00:00
|
|
|
void view_get_size(struct kiwmi_view *view, uint32_t *width, uint32_t *height);
|
2020-01-19 23:36:12 +00:00
|
|
|
const char *view_get_app_id(struct kiwmi_view *view);
|
|
|
|
const char *view_get_title(struct kiwmi_view *view);
|
2019-12-26 20:55:10 +00:00
|
|
|
void view_set_activated(struct kiwmi_view *view, bool activated);
|
2020-01-08 16:39:20 +00:00
|
|
|
void view_set_size(struct kiwmi_view *view, uint32_t width, uint32_t height);
|
2021-08-14 20:06:00 +00:00
|
|
|
void view_set_pos(struct kiwmi_view *view, uint32_t x, uint32_t y);
|
2020-01-08 17:24:13 +00:00
|
|
|
void view_set_tiled(struct kiwmi_view *view, enum wlr_edges edges);
|
2019-12-26 20:55:10 +00:00
|
|
|
struct wlr_surface *view_surface_at(
|
|
|
|
struct kiwmi_view *view,
|
|
|
|
double sx,
|
|
|
|
double sy,
|
|
|
|
double *sub_x,
|
|
|
|
double *sub_y);
|
2019-12-21 14:06:56 +00:00
|
|
|
|
2019-12-31 04:46:18 +00:00
|
|
|
void view_focus(struct kiwmi_view *view);
|
2019-12-26 20:55:10 +00:00
|
|
|
struct kiwmi_view *view_at(
|
|
|
|
struct kiwmi_desktop *desktop,
|
|
|
|
double lx,
|
|
|
|
double ly,
|
|
|
|
struct wlr_surface **surface,
|
|
|
|
double *sx,
|
|
|
|
double *sy);
|
2020-01-17 19:51:56 +00:00
|
|
|
void view_move(struct kiwmi_view *view);
|
|
|
|
void view_resize(struct kiwmi_view *view, uint32_t edges);
|
2019-12-26 20:55:10 +00:00
|
|
|
struct kiwmi_view *view_create(
|
|
|
|
struct kiwmi_desktop *desktop,
|
|
|
|
enum kiwmi_view_type type,
|
|
|
|
const struct kiwmi_view_impl *impl);
|
2019-12-24 15:43:36 +00:00
|
|
|
|
2021-08-27 13:06:12 +00:00
|
|
|
void
|
|
|
|
view_init_subsurfaces(struct kiwmi_view_child *child, struct kiwmi_view *view);
|
|
|
|
bool view_child_is_mapped(struct kiwmi_view_child *child);
|
|
|
|
void view_child_damage(struct kiwmi_view_child *child);
|
|
|
|
void view_child_destroy(struct kiwmi_view_child *child);
|
|
|
|
struct kiwmi_view_child *view_child_create(
|
|
|
|
struct kiwmi_view_child *parent,
|
|
|
|
struct kiwmi_view *view,
|
|
|
|
struct wlr_surface *wlr_surface,
|
|
|
|
enum kiwmi_view_child_type type,
|
|
|
|
const struct kiwmi_view_child_impl *impl);
|
|
|
|
struct kiwmi_view_child *view_child_subsurface_create(
|
|
|
|
struct kiwmi_view_child *parent,
|
|
|
|
struct kiwmi_view *view,
|
|
|
|
struct wlr_subsurface *subsurface);
|
|
|
|
|
2019-12-21 14:06:56 +00:00
|
|
|
#endif /* KIWMI_DESKTOP_VIEW_H */
|