分离修改窗口宽高/边框宽度和移动窗口操作
This commit is contained in:
@@ -49,6 +49,7 @@ void map_window(xcb_window_t window, bool map_sub_window);
|
||||
char *get_window_name(xcb_window_t window);
|
||||
void set_window_event_mask(xcb_window_t window, bool clear);
|
||||
void change_window_border_color(xcb_window_t window, uint32_t argb);
|
||||
void change_window_border_width(xcb_window_t window, uint32_t border_width);
|
||||
void focus_window(xcb_window_t window);
|
||||
/**
|
||||
* @brief 将 window 置于堆叠顺序的顶部
|
||||
@@ -83,6 +84,8 @@ bar_cairo_params_t *create_bar_window(int16_t x, int16_t y, uint16_t width,
|
||||
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);
|
||||
void move_window(xcb_window_t window, int32_t x, int32_t y);
|
||||
void resize_window(xcb_window_t window, uint32_t width, uint32_t height);
|
||||
|
||||
typedef struct monitor_rect_t monitor_rect_t;
|
||||
struct monitor_rect_t {
|
||||
|
||||
11
src/main.c
11
src/main.c
@@ -868,8 +868,7 @@ void unmanage_client(client_t *client, bool destroyed) {
|
||||
detach_stack_client(client);
|
||||
if (!destroyed) {
|
||||
set_window_event_mask(client->window, true);
|
||||
configure_window(client->window, client->x, client->y, client->width,
|
||||
client->height, client->old_border_width);
|
||||
change_window_border_width(client->window, client->old_border_width);
|
||||
set_window_state(client->window, wm_state_withdrawn);
|
||||
flush_xcb_connection();
|
||||
}
|
||||
@@ -1086,14 +1085,15 @@ void show_hide_client(client_t *client) {
|
||||
if (CLIENT_VISIBLE(client)) {
|
||||
if (client->fullscreen) {
|
||||
fullscreen_client(client);
|
||||
resize_window(client->window, client->width, client->height);
|
||||
} else if (client->maximize) {
|
||||
maximize_client(client);
|
||||
resize_window(client->window, client->width, client->height);
|
||||
} else if (!client->monitor->layout->arrange || client->floating) {
|
||||
client->x = client->old_x;
|
||||
client->y = client->old_y;
|
||||
}
|
||||
configure_window(client->window, client->x, client->y, client->width,
|
||||
client->height, client->border_width);
|
||||
move_window(client->window, client->x, client->y);
|
||||
show_hide_client(client->stack_next);
|
||||
} else {
|
||||
if (!client->monitor->layout->arrange || client->floating) {
|
||||
@@ -1103,8 +1103,7 @@ void show_hide_client(client_t *client) {
|
||||
client->x = client->monitor->monitor_x;
|
||||
client->y = client->monitor->monitor_y + client->monitor->monitor_height;
|
||||
show_hide_client(client->stack_next);
|
||||
configure_window(client->window, client->x, client->y, client->window,
|
||||
client->height, client->border_width);
|
||||
move_window(client->window, client->x, client->y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,6 +190,22 @@ void configure_window(xcb_window_t window, int32_t x, int32_t y, uint32_t width,
|
||||
xcb_aux_configure_window(conn, window, config_mask, &window_config);
|
||||
}
|
||||
|
||||
void move_window(xcb_window_t window, int32_t x, int32_t y) {
|
||||
xcb_config_window_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
|
||||
xcb_params_configure_window_t position = {.x = x, .y = y};
|
||||
xcb_aux_configure_window(conn, window, mask, &position);
|
||||
}
|
||||
|
||||
void resize_window(xcb_window_t window, uint32_t width, uint32_t height) {
|
||||
xcb_config_window_t config_mask =
|
||||
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
|
||||
xcb_params_configure_window_t window_config = {
|
||||
.width = width,
|
||||
.height = height,
|
||||
};
|
||||
xcb_aux_configure_window(conn, window, config_mask, &window_config);
|
||||
}
|
||||
|
||||
void change_window_cursor(xcb_window_t window, cursor_t cursor) {
|
||||
xcb_change_window_attributes_value_list_t value_list = {
|
||||
.cursor = get_xcb_cursor(cursor),
|
||||
@@ -285,6 +301,12 @@ void change_window_border_color(xcb_window_t window, uint32_t argb) {
|
||||
xcb_aux_change_window_attributes(conn, window, XCB_CW_BORDER_PIXEL, ¶ms);
|
||||
}
|
||||
|
||||
void change_window_border_width(xcb_window_t window, uint32_t border_width) {
|
||||
xcb_config_window_t config_mask = XCB_CONFIG_WINDOW_BORDER_WIDTH;
|
||||
xcb_params_configure_window_t window_config = {.border_width = border_width};
|
||||
xcb_aux_configure_window(conn, window, config_mask, &window_config);
|
||||
}
|
||||
|
||||
void focus_window(xcb_window_t window) {
|
||||
xcb_window_t root = screen->root;
|
||||
if (window == WINDOW_NONE) {
|
||||
@@ -316,7 +338,6 @@ void place_window_above_sibling(xcb_window_t window, xcb_window_t sibling) {
|
||||
xcb_aux_configure_window(conn, window, mask, ¶ms);
|
||||
}
|
||||
|
||||
|
||||
void place_window_below_sibling(xcb_window_t window, xcb_window_t sibling) {
|
||||
uint16_t mask = XCB_CONFIG_WINDOW_STACK_MODE | XCB_CONFIG_WINDOW_SIBLING;
|
||||
xcb_params_configure_window_t params = {
|
||||
|
||||
Reference in New Issue
Block a user