2022-11-21 10:10:39 -05:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
|
#ifndef __LABWC_VIEW_H
|
|
|
|
|
#define __LABWC_VIEW_H
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <wayland-util.h>
|
|
|
|
|
#include <wlr/util/box.h>
|
|
|
|
|
|
2022-11-22 20:13:06 +00:00
|
|
|
/*
|
|
|
|
|
* In labwc, a view is a container for surfaces which can be moved around by
|
|
|
|
|
* the user. In practice this means XDG toplevel and XWayland windows.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-11-21 10:10:39 -05:00
|
|
|
enum view_type {
|
|
|
|
|
LAB_XDG_SHELL_VIEW,
|
|
|
|
|
#if HAVE_XWAYLAND
|
|
|
|
|
LAB_XWAYLAND_VIEW,
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-26 16:46:28 -05:00
|
|
|
struct view;
|
2022-11-21 10:10:39 -05:00
|
|
|
struct view_impl {
|
|
|
|
|
void (*configure)(struct view *view, struct wlr_box geo);
|
|
|
|
|
void (*close)(struct view *view);
|
|
|
|
|
const char *(*get_string_prop)(struct view *view, const char *prop);
|
|
|
|
|
void (*map)(struct view *view);
|
|
|
|
|
void (*move)(struct view *view, int x, int y);
|
|
|
|
|
void (*set_activated)(struct view *view, bool activated);
|
|
|
|
|
void (*set_fullscreen)(struct view *view, bool fullscreen);
|
|
|
|
|
void (*unmap)(struct view *view);
|
|
|
|
|
void (*maximize)(struct view *view, bool maximize);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct view {
|
|
|
|
|
struct server *server;
|
|
|
|
|
enum view_type type;
|
|
|
|
|
const struct view_impl *impl;
|
|
|
|
|
struct wl_list link;
|
|
|
|
|
struct output *output;
|
|
|
|
|
struct workspace *workspace;
|
|
|
|
|
struct wlr_surface *surface;
|
|
|
|
|
struct wlr_scene_tree *scene_tree;
|
|
|
|
|
struct wlr_scene_node *scene_node;
|
|
|
|
|
|
|
|
|
|
bool mapped;
|
|
|
|
|
bool been_mapped;
|
2022-11-21 15:38:20 -05:00
|
|
|
bool ssd_enabled;
|
2022-11-21 10:10:39 -05:00
|
|
|
bool minimized;
|
|
|
|
|
bool maximized;
|
|
|
|
|
uint32_t tiled; /* private, enum view_edge in src/view.c */
|
2022-07-07 19:05:54 +02:00
|
|
|
|
|
|
|
|
/* Pointer to an output owned struct region, may be NULL or already free'd */
|
2022-07-06 17:04:21 +02:00
|
|
|
struct region *tiled_region;
|
2022-07-07 19:05:54 +02:00
|
|
|
/* Set to region->name when tiled_region is free'd by a destroying output */
|
|
|
|
|
char *tiled_region_evacuate;
|
|
|
|
|
|
2022-11-21 10:10:39 -05:00
|
|
|
struct wlr_output *fullscreen;
|
|
|
|
|
|
|
|
|
|
/* geometry of the wlr_surface contained within the view */
|
|
|
|
|
int x, y, w, h;
|
|
|
|
|
|
|
|
|
|
/* user defined geometry before maximize / tiling / fullscreen */
|
|
|
|
|
struct wlr_box natural_geometry;
|
|
|
|
|
|
|
|
|
|
struct view_pending_move_resize {
|
|
|
|
|
bool update_x, update_y;
|
|
|
|
|
int x, y;
|
|
|
|
|
uint32_t width, height;
|
|
|
|
|
uint32_t configure_serial;
|
|
|
|
|
} pending_move_resize;
|
|
|
|
|
|
2022-11-26 16:46:28 -05:00
|
|
|
struct ssd *ssd;
|
2022-11-21 10:10:39 -05:00
|
|
|
|
|
|
|
|
struct wlr_foreign_toplevel_handle_v1 *toplevel_handle;
|
|
|
|
|
struct wl_listener toplevel_handle_request_maximize;
|
|
|
|
|
struct wl_listener toplevel_handle_request_minimize;
|
|
|
|
|
struct wl_listener toplevel_handle_request_fullscreen;
|
|
|
|
|
struct wl_listener toplevel_handle_request_activate;
|
|
|
|
|
struct wl_listener toplevel_handle_request_close;
|
|
|
|
|
|
|
|
|
|
struct wl_listener map;
|
|
|
|
|
struct wl_listener unmap;
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
|
struct wl_listener surface_destroy;
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
|
struct wl_listener request_move;
|
|
|
|
|
struct wl_listener request_resize;
|
|
|
|
|
struct wl_listener request_activate;
|
|
|
|
|
struct wl_listener request_minimize;
|
|
|
|
|
struct wl_listener request_maximize;
|
|
|
|
|
struct wl_listener request_fullscreen;
|
|
|
|
|
struct wl_listener set_title;
|
2022-11-22 20:13:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct xdg_toplevel_view {
|
|
|
|
|
struct view base;
|
2022-11-25 13:41:12 -05:00
|
|
|
struct wlr_xdg_surface *xdg_surface;
|
2022-11-22 20:13:06 +00:00
|
|
|
|
|
|
|
|
/* Events unique to xdg-toplevel views */
|
|
|
|
|
struct wl_listener set_app_id;
|
|
|
|
|
struct wl_listener new_popup;
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-21 10:10:39 -05:00
|
|
|
void view_set_activated(struct view *view);
|
|
|
|
|
void view_close(struct view *view);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* view_move_resize - resize and move view
|
|
|
|
|
* @view: view to be resized and moved
|
|
|
|
|
* @geo: the new geometry
|
|
|
|
|
* NOTE: Only use this when the view actually changes width and/or height
|
|
|
|
|
* otherwise the serials might cause a delay in moving xdg-shell clients.
|
|
|
|
|
* For move only, use view_move()
|
|
|
|
|
*/
|
|
|
|
|
void view_move_resize(struct view *view, struct wlr_box geo);
|
|
|
|
|
void view_move(struct view *view, int x, int y);
|
|
|
|
|
void view_moved(struct view *view);
|
|
|
|
|
void view_minimize(struct view *view, bool minimized);
|
|
|
|
|
/* view_wlr_output - return the output that a view is mostly on */
|
|
|
|
|
struct wlr_output *view_wlr_output(struct view *view);
|
|
|
|
|
void view_store_natural_geometry(struct view *view);
|
|
|
|
|
void view_center(struct view *view);
|
|
|
|
|
void view_restore_to(struct view *view, struct wlr_box geometry);
|
2022-11-21 13:17:14 -05:00
|
|
|
void view_set_untiled(struct view *view);
|
2022-11-21 10:10:39 -05:00
|
|
|
void view_maximize(struct view *view, bool maximize,
|
|
|
|
|
bool store_natural_geometry);
|
|
|
|
|
void view_set_fullscreen(struct view *view, bool fullscreen,
|
|
|
|
|
struct wlr_output *wlr_output);
|
|
|
|
|
void view_toggle_maximize(struct view *view);
|
|
|
|
|
void view_toggle_decorations(struct view *view);
|
|
|
|
|
void view_toggle_always_on_top(struct view *view);
|
2022-12-29 04:50:21 +01:00
|
|
|
bool view_is_always_on_top(struct view *view);
|
2022-11-21 13:03:49 -05:00
|
|
|
void view_move_to_workspace(struct view *view, struct workspace *workspace);
|
2022-11-21 10:10:39 -05:00
|
|
|
void view_set_decorations(struct view *view, bool decorations);
|
|
|
|
|
void view_toggle_fullscreen(struct view *view);
|
|
|
|
|
void view_adjust_for_layout_change(struct view *view);
|
|
|
|
|
void view_discover_output(struct view *view);
|
|
|
|
|
void view_move_to_edge(struct view *view, const char *direction);
|
|
|
|
|
void view_snap_to_edge(struct view *view, const char *direction,
|
|
|
|
|
bool store_natural_geometry);
|
2022-07-06 17:04:21 +02:00
|
|
|
void view_snap_to_region(struct view *view, struct region *region,
|
|
|
|
|
bool store_natural_geometry);
|
2022-11-21 10:10:39 -05:00
|
|
|
const char *view_get_string_prop(struct view *view, const char *prop);
|
|
|
|
|
void view_update_title(struct view *view);
|
|
|
|
|
void view_update_app_id(struct view *view);
|
2022-11-26 02:13:42 -05:00
|
|
|
void view_reload_ssd(struct view *view);
|
2022-11-21 10:10:39 -05:00
|
|
|
|
|
|
|
|
void view_impl_map(struct view *view);
|
|
|
|
|
void view_adjust_size(struct view *view, int *w, int *h);
|
|
|
|
|
|
2022-12-17 20:47:46 +00:00
|
|
|
bool view_compute_centered_position(struct view *view, int w, int h,
|
|
|
|
|
int *x, int *y);
|
|
|
|
|
|
2022-11-21 10:10:39 -05:00
|
|
|
void view_on_output_destroy(struct view *view);
|
|
|
|
|
void view_destroy(struct view *view);
|
|
|
|
|
|
2022-11-25 13:41:12 -05:00
|
|
|
/* xdg.c */
|
|
|
|
|
struct wlr_xdg_surface *xdg_surface_from_view(struct view *view);
|
|
|
|
|
|
2022-11-21 10:10:39 -05:00
|
|
|
#endif /* __LABWC_VIEW_H */
|