mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-15 04:27:52 -05:00
For now, this behavior is controlled with an ifdef. At least kwin seems very buggy when the decorations are positioned like this (but normally you'd use server-side decorations with kwin anyway). This commit also changes 'use_csd' to be a tri-state variable; when instantiating a window it is set to 'unknown'. If there's no decoration manager available (e.g. weston), we immediately set it to 'yes' (use CSDs). Otherwise, we wait for the decoration manager callback to indicate whether we should use CSDs or not.
202 lines
4.4 KiB
C
202 lines
4.4 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <wayland-client.h>
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
#include <primary-selection-unstable-v1.h>
|
|
#include <presentation-time.h>
|
|
|
|
#include <tllist.h>
|
|
|
|
#include "fdm.h"
|
|
|
|
struct monitor {
|
|
struct wayland *wayl;
|
|
struct wl_output *output;
|
|
struct zxdg_output_v1 *xdg;
|
|
char *name;
|
|
|
|
int x;
|
|
int y;
|
|
|
|
int width_mm;
|
|
int height_mm;
|
|
|
|
int width_px;
|
|
int height_px;
|
|
|
|
int x_ppi;
|
|
int y_ppi;
|
|
|
|
int scale;
|
|
float refresh;
|
|
|
|
char *make;
|
|
char *model;
|
|
float inch; /* e.g. 24" */
|
|
};
|
|
|
|
struct kbd {
|
|
struct xkb_context *xkb;
|
|
struct xkb_keymap *xkb_keymap;
|
|
struct xkb_state *xkb_state;
|
|
struct xkb_compose_table *xkb_compose_table;
|
|
struct xkb_compose_state *xkb_compose_state;
|
|
struct {
|
|
int fd;
|
|
|
|
bool dont_re_repeat;
|
|
int32_t delay;
|
|
int32_t rate;
|
|
uint32_t key;
|
|
} repeat;
|
|
|
|
xkb_mod_index_t mod_shift;
|
|
xkb_mod_index_t mod_alt;
|
|
xkb_mod_index_t mod_ctrl;
|
|
xkb_mod_index_t mod_meta;
|
|
|
|
/* Enabled modifiers */
|
|
bool shift;
|
|
bool alt;
|
|
bool ctrl;
|
|
bool meta;
|
|
};
|
|
|
|
struct wl_clipboard {
|
|
struct wl_data_source *data_source;
|
|
struct wl_data_offer *data_offer;
|
|
char *text;
|
|
uint32_t serial;
|
|
};
|
|
|
|
struct wl_primary {
|
|
struct zwp_primary_selection_source_v1 *data_source;
|
|
struct zwp_primary_selection_offer_v1 *data_offer;
|
|
char *text;
|
|
uint32_t serial;
|
|
};
|
|
|
|
#define FOOT_CSD_OUTSIDE 1
|
|
extern const int csd_border_size;
|
|
extern const int csd_title_size;
|
|
|
|
struct wayland;
|
|
struct wl_window {
|
|
struct terminal *term;
|
|
struct wl_surface *surface;
|
|
struct xdg_surface *xdg_surface;
|
|
struct xdg_toplevel *xdg_toplevel;
|
|
|
|
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
|
|
|
|
enum {CSD_UNKNOWN, CSD_NO, CSD_YES } use_csd;
|
|
|
|
struct {
|
|
struct wl_surface *surface[5];
|
|
struct wl_subsurface *sub_surface[5];
|
|
} csd;
|
|
|
|
/* Scrollback search */
|
|
struct wl_surface *search_surface;
|
|
struct wl_subsurface *search_sub_surface;
|
|
|
|
struct wl_callback *frame_callback;
|
|
|
|
tll(const struct monitor *) on_outputs; /* Outputs we're mapped on */
|
|
|
|
bool is_configured;
|
|
struct {
|
|
bool is_activated;
|
|
int width;
|
|
int height;
|
|
} configure;
|
|
};
|
|
|
|
struct config;
|
|
struct terminal;
|
|
struct wayland {
|
|
const struct config *conf;
|
|
struct fdm *fdm;
|
|
struct wl_display *display;
|
|
struct wl_registry *registry;
|
|
struct wl_compositor *compositor;
|
|
struct wl_subcompositor *sub_compositor;
|
|
struct wl_shm *shm;
|
|
|
|
struct wl_seat *seat;
|
|
struct wl_keyboard *keyboard;
|
|
struct zxdg_output_manager_v1 *xdg_output_manager;
|
|
|
|
struct xdg_wm_base *shell;
|
|
struct zxdg_decoration_manager_v1 *xdg_decoration_manager;
|
|
|
|
struct wp_presentation *presentation;
|
|
uint32_t presentation_clock_id;
|
|
|
|
/* Keyboard */
|
|
struct kbd kbd;
|
|
|
|
/* Clipboard */
|
|
uint32_t input_serial;
|
|
struct wl_data_device_manager *data_device_manager;
|
|
struct wl_data_device *data_device;
|
|
struct zwp_primary_selection_device_manager_v1 *primary_selection_device_manager;
|
|
struct zwp_primary_selection_device_v1 *primary_selection_device;
|
|
|
|
struct wl_clipboard clipboard;
|
|
struct wl_primary primary;
|
|
|
|
/* Cursor */
|
|
struct {
|
|
struct wl_pointer *pointer;
|
|
uint32_t serial;
|
|
|
|
struct wl_surface *surface;
|
|
struct wl_cursor_theme *theme;
|
|
struct wl_cursor *cursor;
|
|
int size;
|
|
char *theme_name;
|
|
const char *xcursor;
|
|
|
|
const struct terminal *pending_terminal;
|
|
struct wl_callback *xcursor_callback;
|
|
} pointer;
|
|
|
|
struct {
|
|
int col;
|
|
int row;
|
|
int button;
|
|
|
|
int count;
|
|
int last_button;
|
|
struct timeval last_time;
|
|
|
|
/* We used a discrete axis event in the current pointer frame */
|
|
bool have_discrete;
|
|
} mouse;
|
|
|
|
bool have_argb8888;
|
|
tll(struct monitor) monitors; /* All available outputs */
|
|
|
|
tll(struct terminal *) terms;
|
|
struct terminal *kbd_focus;
|
|
struct terminal *mouse_focus;
|
|
};
|
|
|
|
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm);
|
|
void wayl_destroy(struct wayland *wayl);
|
|
|
|
void wayl_flush(struct wayland *wayl);
|
|
void wayl_roundtrip(struct wayland *wayl);
|
|
|
|
struct terminal *wayl_terminal_from_surface(
|
|
struct wayland *wayl, struct wl_surface *surface);
|
|
|
|
struct wl_window *wayl_win_init(struct terminal *term);
|
|
void wayl_win_destroy(struct wl_window *win);
|