2021-11-26 06:59:02 +03:00
|
|
|
/**
|
|
|
|
* @brief Internal definitions used by the Yutani compositor.
|
|
|
|
*
|
|
|
|
* @copyright
|
2018-09-22 13:14:46 +03:00
|
|
|
* This file is part of ToaruOS and is released under the terms
|
|
|
|
* of the NCSA / University of Illinois License - see LICENSE.md
|
2021-11-26 06:59:02 +03:00
|
|
|
* Copyright (C) 2013-2021 K. Lange
|
2018-09-22 13:14:46 +03:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2018-10-12 05:15:40 +03:00
|
|
|
#include <_cheader.h>
|
2018-09-22 13:14:46 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <toaru/yutani.h>
|
|
|
|
|
2018-10-12 05:15:40 +03:00
|
|
|
_Begin_C_Header
|
|
|
|
|
2018-09-22 13:14:46 +03:00
|
|
|
/* Mouse resolution scaling */
|
|
|
|
#define MOUSE_SCALE 3
|
|
|
|
#define YUTANI_INCOMING_MOUSE_SCALE * 3
|
|
|
|
|
|
|
|
/* Mouse cursor hotspot */
|
|
|
|
#define MOUSE_OFFSET_X 26
|
|
|
|
#define MOUSE_OFFSET_Y 26
|
|
|
|
|
|
|
|
/* Mouse cursor size */
|
|
|
|
#define MOUSE_WIDTH 64
|
|
|
|
#define MOUSE_HEIGHT 64
|
|
|
|
|
|
|
|
/* How much the mouse needs to move to break off a tiled window */
|
|
|
|
#define UNTILE_SENSITIVITY (MOUSE_SCALE * 5)
|
|
|
|
|
|
|
|
/* Screenshot modes */
|
|
|
|
#define YUTANI_SCREENSHOT_FULL 1
|
|
|
|
#define YUTANI_SCREENSHOT_WINDOW 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Animation effect types.
|
|
|
|
* XXX: Should this be in the client library?
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
YUTANI_EFFECT_NONE,
|
|
|
|
|
|
|
|
/* Basic animations */
|
|
|
|
YUTANI_EFFECT_FADE_IN,
|
|
|
|
YUTANI_EFFECT_FADE_OUT,
|
|
|
|
|
|
|
|
/* XXX: Are these used? */
|
|
|
|
YUTANI_EFFECT_MINIMIZE,
|
|
|
|
YUTANI_EFFECT_UNMINIMIZE,
|
2019-01-12 14:09:49 +03:00
|
|
|
|
|
|
|
/* Dialog animations, faster than the fades */
|
|
|
|
YUTANI_EFFECT_SQUEEZE_IN,
|
|
|
|
YUTANI_EFFECT_SQUEEZE_OUT,
|
2021-08-11 07:03:33 +03:00
|
|
|
|
|
|
|
YUTANI_EFFECT_DISAPPEAR,
|
2018-09-22 13:14:46 +03:00
|
|
|
} yutani_effect;
|
|
|
|
|
|
|
|
/* Animation lengths */
|
|
|
|
static int yutani_animation_lengths[] = {
|
|
|
|
0, /* None */
|
|
|
|
200, /* Fade In */
|
|
|
|
200, /* Fade Out */
|
|
|
|
0, /* Minimize */
|
|
|
|
0, /* Unminimized */
|
2019-01-12 14:09:49 +03:00
|
|
|
100, /* Squeeze in */
|
|
|
|
100, /* Squeeze out */
|
2021-08-11 07:03:33 +03:00
|
|
|
10, /* Disappear */
|
2019-01-12 14:09:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static int yutani_is_closing_animation[] = {
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
1,
|
2021-08-11 07:03:33 +03:00
|
|
|
1,
|
2018-09-22 13:14:46 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Debug Options */
|
|
|
|
#define YUTANI_DEBUG_WINDOW_BOUNDS 1
|
|
|
|
#define YUTANI_DEBUG_WINDOW_SHAPES 1
|
|
|
|
|
|
|
|
/* Command line flag values */
|
|
|
|
struct {
|
|
|
|
int nested;
|
|
|
|
int nest_width;
|
|
|
|
int nest_height;
|
|
|
|
} yutani_options = {
|
|
|
|
.nested = 0,
|
|
|
|
.nest_width = 640,
|
|
|
|
.nest_height = 480,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Server window definitions
|
|
|
|
*/
|
|
|
|
typedef struct YutaniServerWindow {
|
|
|
|
/* Window identifier number */
|
|
|
|
yutani_wid_t wid;
|
|
|
|
|
|
|
|
/* Window location */
|
|
|
|
signed long x;
|
|
|
|
signed long y;
|
|
|
|
|
|
|
|
/* Stack order */
|
|
|
|
unsigned short z;
|
|
|
|
|
|
|
|
/* Window size */
|
|
|
|
int32_t width;
|
|
|
|
int32_t height;
|
|
|
|
|
|
|
|
/* Canvas buffer */
|
|
|
|
uint8_t * buffer;
|
|
|
|
uint32_t bufid;
|
|
|
|
uint32_t newbufid;
|
|
|
|
uint8_t * newbuffer;
|
|
|
|
|
|
|
|
/* Connection that owns this window */
|
2021-05-31 04:47:02 +03:00
|
|
|
uintptr_t owner;
|
2018-09-22 13:14:46 +03:00
|
|
|
|
|
|
|
/* Rotation of windows XXX */
|
|
|
|
int16_t rotation;
|
|
|
|
|
|
|
|
/* Client advertisements */
|
|
|
|
uint32_t client_flags;
|
2021-10-31 16:25:00 +03:00
|
|
|
uint32_t client_icon;
|
2018-09-22 13:14:46 +03:00
|
|
|
uint32_t client_length;
|
|
|
|
char * client_strings;
|
|
|
|
|
|
|
|
/* Window animations */
|
2021-05-31 04:47:02 +03:00
|
|
|
uint64_t anim_mode;
|
|
|
|
uint64_t anim_start;
|
2018-09-22 13:14:46 +03:00
|
|
|
|
|
|
|
/* Alpha shaping threshold */
|
|
|
|
int alpha_threshold;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mouse cursor selection
|
|
|
|
* Originally, this specified whether the mouse was
|
|
|
|
* hidden, but it plays double duty since client
|
|
|
|
* control over mouse cursors was added.
|
|
|
|
*/
|
|
|
|
int show_mouse;
|
|
|
|
int default_mouse;
|
|
|
|
|
|
|
|
/* Tiling / untiling information */
|
|
|
|
int tiled;
|
|
|
|
int32_t untiled_width;
|
|
|
|
int32_t untiled_height;
|
|
|
|
int32_t untiled_left;
|
|
|
|
int32_t untiled_top;
|
|
|
|
|
|
|
|
/* Client-configurable server behavior flags */
|
|
|
|
uint32_t server_flags;
|
|
|
|
|
|
|
|
/* Window opacity */
|
|
|
|
int opacity;
|
2021-08-11 06:58:00 +03:00
|
|
|
|
|
|
|
/* Window is hidden? */
|
|
|
|
int hidden;
|
2018-09-22 13:14:46 +03:00
|
|
|
} yutani_server_window_t;
|
|
|
|
|
|
|
|
typedef struct YutaniGlobals {
|
|
|
|
/* Display resolution */
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
|
|
|
uint32_t stride;
|
|
|
|
|
|
|
|
/* TODO: What about multiple screens?
|
|
|
|
*
|
|
|
|
* Obviously this is the whole canvas size,
|
|
|
|
* but we need to be able to track different
|
|
|
|
* monitors if/when we ever get support for that.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Core graphics context */
|
|
|
|
void * backend_framebuffer;
|
|
|
|
gfx_context_t * backend_ctx;
|
|
|
|
|
|
|
|
/* Mouse location */
|
|
|
|
signed int mouse_x;
|
|
|
|
signed int mouse_y;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Previous mouse location, so that events can have
|
|
|
|
* both the new and old mouse location together
|
|
|
|
*/
|
|
|
|
signed int last_mouse_x;
|
|
|
|
signed int last_mouse_y;
|
|
|
|
|
|
|
|
/* List of all windows */
|
|
|
|
list_t * windows;
|
|
|
|
|
|
|
|
/* Hash of window IDs to their objects */
|
|
|
|
hashmap_t * wids_to_windows;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Window stacking information
|
|
|
|
* TODO: Support multiple top and bottom windows.
|
|
|
|
*/
|
|
|
|
yutani_server_window_t * bottom_z;
|
|
|
|
list_t * mid_zs;
|
2021-11-05 03:58:33 +03:00
|
|
|
list_t * menu_zs;
|
2021-10-31 14:16:41 +03:00
|
|
|
list_t * overlay_zs;
|
2018-09-22 13:14:46 +03:00
|
|
|
yutani_server_window_t * top_z;
|
|
|
|
|
|
|
|
/* Damage region list */
|
|
|
|
list_t * update_list;
|
|
|
|
|
|
|
|
/* Mouse cursors */
|
|
|
|
sprite_t mouse_sprite;
|
|
|
|
sprite_t mouse_sprite_drag;
|
|
|
|
sprite_t mouse_sprite_resize_v;
|
|
|
|
sprite_t mouse_sprite_resize_h;
|
|
|
|
sprite_t mouse_sprite_resize_da;
|
|
|
|
sprite_t mouse_sprite_resize_db;
|
2021-06-24 13:49:24 +03:00
|
|
|
sprite_t mouse_sprite_point;
|
2021-09-16 10:55:43 +03:00
|
|
|
sprite_t mouse_sprite_ibeam;
|
2018-09-22 13:14:46 +03:00
|
|
|
int current_cursor;
|
|
|
|
|
|
|
|
/* Server backend communication identifier */
|
|
|
|
char * server_ident;
|
|
|
|
FILE * server;
|
|
|
|
|
|
|
|
/* Pointer to focused window */
|
|
|
|
yutani_server_window_t * focused_window;
|
|
|
|
|
|
|
|
/* Mouse movement state */
|
|
|
|
int mouse_state;
|
|
|
|
|
|
|
|
/* Pointer to window being manipulated by mouse actions */
|
|
|
|
yutani_server_window_t * mouse_window;
|
|
|
|
|
|
|
|
/* Buffered information on mouse-moved window */
|
|
|
|
int mouse_win_x;
|
|
|
|
int mouse_win_y;
|
|
|
|
int mouse_init_x;
|
|
|
|
int mouse_init_y;
|
|
|
|
int mouse_init_r;
|
|
|
|
|
|
|
|
int32_t mouse_click_x_orig;
|
|
|
|
int32_t mouse_click_y_orig;
|
|
|
|
|
|
|
|
int mouse_drag_button;
|
|
|
|
int mouse_moved;
|
|
|
|
|
|
|
|
int32_t mouse_click_x;
|
|
|
|
int32_t mouse_click_y;
|
|
|
|
|
|
|
|
/* Pointer to window being resized */
|
|
|
|
yutani_server_window_t * resizing_window;
|
|
|
|
int32_t resizing_w;
|
|
|
|
int32_t resizing_h;
|
|
|
|
yutani_scale_direction_t resizing_direction;
|
|
|
|
int32_t resizing_offset_x;
|
|
|
|
int32_t resizing_offset_y;
|
|
|
|
int resizing_button;
|
|
|
|
|
|
|
|
/* List of clients subscribing to window information events */
|
|
|
|
list_t * window_subscribers;
|
|
|
|
|
|
|
|
/* When the server started, used for timing functions */
|
|
|
|
time_t start_time;
|
|
|
|
suseconds_t start_subtime;
|
|
|
|
|
|
|
|
/* Pointer to last hovered window to allow exit events */
|
|
|
|
yutani_server_window_t * old_hover_window;
|
|
|
|
|
2021-08-19 02:52:23 +03:00
|
|
|
/* Key bindings */
|
2018-09-22 13:14:46 +03:00
|
|
|
hashmap_t * key_binds;
|
|
|
|
|
|
|
|
/* Windows to remove after the end of the rendering pass */
|
|
|
|
list_t * windows_to_remove;
|
|
|
|
|
|
|
|
/* For nested mode, the host Yutani context and window */
|
|
|
|
yutani_t * host_context;
|
|
|
|
yutani_window_t * host_window;
|
|
|
|
|
|
|
|
/* Map of clients to their windows */
|
|
|
|
hashmap_t * clients_to_windows;
|
|
|
|
|
|
|
|
/* Toggles for debugging window locations */
|
|
|
|
int debug_bounds;
|
|
|
|
int debug_shapes;
|
|
|
|
|
|
|
|
/* If the next rendered frame should be saved as a screenshot */
|
|
|
|
int screenshot_frame;
|
|
|
|
|
|
|
|
/* Next frame should resize host context */
|
|
|
|
int resize_on_next;
|
|
|
|
|
|
|
|
/* Last mouse buttons - used for some specialized mouse drivers */
|
|
|
|
uint32_t last_mouse_buttons;
|
|
|
|
|
|
|
|
/* Clipboard buffer */
|
|
|
|
char clipboard[512];
|
|
|
|
int clipboard_size;
|
|
|
|
|
|
|
|
/* VirtualBox Seamless mode support information */
|
|
|
|
int vbox_rects;
|
|
|
|
int vbox_pointer;
|
|
|
|
|
|
|
|
/* Renderer plugin context */
|
|
|
|
void * renderer_ctx;
|
2018-10-02 12:58:03 +03:00
|
|
|
|
|
|
|
int reload_renderer;
|
2018-12-07 05:05:21 +03:00
|
|
|
uint8_t active_modifiers;
|
2018-09-22 13:14:46 +03:00
|
|
|
} yutani_globals_t;
|
|
|
|
|
|
|
|
struct key_bind {
|
2021-05-31 04:47:02 +03:00
|
|
|
uintptr_t owner;
|
2018-09-22 13:14:46 +03:00
|
|
|
int response;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Exported functions for plugins */
|
|
|
|
extern int yutani_window_is_top(yutani_globals_t * yg, yutani_server_window_t * window);
|
|
|
|
extern int yutani_window_is_bottom(yutani_globals_t * yg, yutani_server_window_t * window);
|
2021-05-31 04:47:02 +03:00
|
|
|
extern uint64_t yutani_time_since(yutani_globals_t * yg, uint64_t start_time);
|
2018-09-22 13:14:46 +03:00
|
|
|
extern void yutani_window_to_device(yutani_server_window_t * window, int32_t x, int32_t y, int32_t * out_x, int32_t * out_y);
|
|
|
|
extern void yutani_device_to_window(yutani_server_window_t * window, int32_t x, int32_t y, int32_t * out_x, int32_t * out_y);
|
|
|
|
extern uint32_t yutani_color_for_wid(yutani_wid_t wid);
|
2018-10-12 05:15:40 +03:00
|
|
|
|
|
|
|
_End_C_Header
|