显示窗口

This commit is contained in:
2025-08-22 15:47:58 +08:00
parent 2a7ab324be
commit c3bcb7ddd2
9 changed files with 274 additions and 14 deletions

View File

@@ -2,6 +2,8 @@
#include <stdint.h>
#include "types.h"
typedef enum event_type_t {
EVENT_TYPE_MAPPING_NOTIFY,
EVENT_TYPE_KEY_PRESS,
@@ -35,6 +37,13 @@ typedef struct button_press_event_t {
typedef struct configure_request_event_t {
event_type_t type;
xcb_window_t window;
xcb_window_t parent;
xcb_window_t sibling;
int32_t x, y;
uint32_t width, height, border_width;
uint32_t value_mask;
uint8_t stack_mode;
} configure_request_event_t;
typedef struct configure_notify_event_t {
@@ -43,6 +52,8 @@ typedef struct configure_notify_event_t {
typedef struct map_request_event_t {
event_type_t type;
xcb_window_t window;
xcb_window_t parent;
} map_request_event_t;
typedef struct unmap_notify_event_t {

View File

@@ -38,11 +38,12 @@ struct monitor_t {
struct client_t {
char name[256];
int32_t x, y;
uint32_t width, height, border_width;
int32_t x, y, old_x, old_y;
uint32_t width, height, border_width, old_width, old_height, old_border_width;
uint32_t tags;
bool fullscreen;
bool floating;
bool maximize;
monitor_t *monitor;
client_t *next;

View File

@@ -5,8 +5,11 @@
#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);
@@ -17,7 +20,27 @@ typedef enum cursor_t {
cursor_move = XC_fleur,
} cursor_t;
void change_window_cursor(xcb_window_t window, cursor_t cursor);
void set_root_cursor(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_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;
@@ -32,6 +55,8 @@ 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 {