98 lines
2.9 KiB
C
98 lines
2.9 KiB
C
#pragma once
|
|
|
|
#include <X11/cursorfont.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <xcb/xproto.h>
|
|
|
|
#include "types.h"
|
|
|
|
#define WINDOW_NONE XCB_WINDOW_NONE
|
|
|
|
bool has_other_wm_running(void);
|
|
int get_xcb_connection_fd(void);
|
|
void flush_xcb_connection(void);
|
|
|
|
typedef enum cursor_t {
|
|
cursor_normal = XC_left_ptr,
|
|
cursor_resize = XC_bottom_right_corner,
|
|
cursor_move = XC_fleur,
|
|
} cursor_t;
|
|
void change_window_cursor(xcb_window_t window, cursor_t cursor);
|
|
xcb_window_t get_root_window(void);
|
|
bool get_window_visible(xcb_window_t window);
|
|
xcb_window_t get_transient_window_for(xcb_window_t window);
|
|
|
|
typedef struct window_class_instance_t {
|
|
char class[128];
|
|
char instance[128];
|
|
} window_class_instance_t;
|
|
void get_window_class_instance(xcb_window_t window,
|
|
window_class_instance_t *class_instance);
|
|
|
|
typedef struct window_geometry_t {
|
|
int32_t x, y;
|
|
uint32_t width, height, border_width;
|
|
} window_geometry_t;
|
|
/**
|
|
* @brief 获取窗口的几何信息
|
|
* @returns 返回几何信息指针,使用完后记得使用 free 释放内存
|
|
*/
|
|
window_geometry_t *get_window_geometry(xcb_window_t window);
|
|
void map_window(xcb_window_t window);
|
|
/**
|
|
* @brief 获取窗口名
|
|
* @returns 返回窗口名字符串指针,使用完后记得使用 free 释放内存
|
|
*/
|
|
char *get_window_name(xcb_window_t window);
|
|
void init_window_event_mask(xcb_window_t window);
|
|
void change_window_border_color(xcb_window_t window, uint32_t argb);
|
|
|
|
typedef struct bar_cairo_params_t {
|
|
xcb_connection_t *conn;
|
|
xcb_window_t window;
|
|
xcb_visualtype_t *visual;
|
|
} bar_cairo_params_t;
|
|
/**
|
|
* @brief 创建每个屏幕的 bar 窗口
|
|
* @returns 返回创建 cairo surface 需要的参数,使用完记得使用 free 释放内存
|
|
*/
|
|
bar_cairo_params_t *create_bar_window(int16_t x, int16_t y, uint16_t width,
|
|
uint16_t height, uint32_t background_argb,
|
|
cursor_t cursor);
|
|
void destroy_window(xcb_window_t window);
|
|
void configure_window(xcb_window_t window, int32_t x, int32_t y, uint32_t width,
|
|
uint32_t height, uint32_t border_width);
|
|
|
|
typedef struct monitor_rect_t monitor_rect_t;
|
|
struct monitor_rect_t {
|
|
int32_t x;
|
|
int32_t y;
|
|
uint32_t width;
|
|
uint32_t height;
|
|
monitor_rect_t *next;
|
|
};
|
|
monitor_rect_t *detect_monitor_rect(void);
|
|
|
|
typedef struct rect_size_t {
|
|
uint32_t width;
|
|
uint32_t height;
|
|
} rect_size_t;
|
|
rect_size_t *get_screen_size(void);
|
|
void set_wallpaper(uint32_t *wallpaper_data);
|
|
|
|
typedef struct window_list_t {
|
|
uint32_t count;
|
|
xcb_window_t *list;
|
|
} window_list_t;
|
|
window_list_t *scan_window_list(void);
|
|
void free_window_list(window_list_t *window_list);
|
|
void clean_xcb(void);
|
|
|
|
void grab_keybindings(const keybinding_t *keys, const size_t length);
|
|
|
|
bool get_xresource_uint32(const char *name, uint32_t *value);
|
|
void get_xresource_string(const char *name, char **value, const char *fallback);
|
|
void clean_xresource(void);
|