XDG-Shell: 如何改变window大小?
XDG-Shell: how to change window size?
我在应用程序中添加了 xdg-shell v5 来绘制 windows。当我发送 set_fullscreen 或 set_maximize 命令时,我在配置事件中看到正确设置 window 状态和正确大小,但没有任何反应。
我的配置事件函数:
static void
xdg_surface_handle_configure(void *data,
struct xdg_surface *xdg_surface,
int32_t width,
int32_t height,
struct wl_array *states,
uint32_t serial) {
printf("Configure event got, width: %d, height: %d\n", width, height);
VirtIOGPU *g = (VirtIOGPU*) data;
g->window_state.activated = g->window_state.fullscreen =
g->window_state.maximized = g->window_state.resizing = false;
uint32_t *state;
wl_array_for_each(state, states) {
if(*state == XDG_SURFACE_STATE_MAXIMIZED) {
printf("Surface state: XDG_SURFACE_STATE_MAXIMIZED\n");
g->window_state.maximized = true;
} else if(*state == XDG_SURFACE_STATE_FULLSCREEN) {
printf("Surface state: XDG_SURFACE_STATE_FULLSCREEN\n");
g->window_state.fullscreen = true;
} else if(*state == XDG_SURFACE_STATE_RESIZING) {
printf("Surface state: XDG_SURFACE_STATE_RESIZING\n");
g->window_state.resizing = true;
} else if(*state == XDG_SURFACE_STATE_ACTIVATED) {
printf("Surface state: XDG_SURFACE_STATE_ACTIVATED\n");
g->window_state.activated = true;
}
}
if (width > 0 && height > 0) {
g->prev_width = g->width;
g->prev_height = g->height;
g->width = width;
g->height = height;
} else {
g->width = g->prev_width;
g->height = g->prev_height;
}
xdg_surface_ack_configure(xdg_surface, serial);
wl_surface_damage(g->surface, 0, 0, g->width, g->height);
wl_surface_commit(g->surface);
wl_display_dispatch_pending(g->display);
wl_display_flush(g->display);
}
那么,发送 set_maximized 后如何看到最大化的 window?
是否可以通过编程方式取消最小化最小化 window(现在通过 Super+Tab)?
您的客户可能需要将具有正确尺寸的新缓冲区附加并提交到表面。合成器已完成它应该做的所有事情,并希望您的客户端调整大小。
我在应用程序中添加了 xdg-shell v5 来绘制 windows。当我发送 set_fullscreen 或 set_maximize 命令时,我在配置事件中看到正确设置 window 状态和正确大小,但没有任何反应。
我的配置事件函数:
static void
xdg_surface_handle_configure(void *data,
struct xdg_surface *xdg_surface,
int32_t width,
int32_t height,
struct wl_array *states,
uint32_t serial) {
printf("Configure event got, width: %d, height: %d\n", width, height);
VirtIOGPU *g = (VirtIOGPU*) data;
g->window_state.activated = g->window_state.fullscreen =
g->window_state.maximized = g->window_state.resizing = false;
uint32_t *state;
wl_array_for_each(state, states) {
if(*state == XDG_SURFACE_STATE_MAXIMIZED) {
printf("Surface state: XDG_SURFACE_STATE_MAXIMIZED\n");
g->window_state.maximized = true;
} else if(*state == XDG_SURFACE_STATE_FULLSCREEN) {
printf("Surface state: XDG_SURFACE_STATE_FULLSCREEN\n");
g->window_state.fullscreen = true;
} else if(*state == XDG_SURFACE_STATE_RESIZING) {
printf("Surface state: XDG_SURFACE_STATE_RESIZING\n");
g->window_state.resizing = true;
} else if(*state == XDG_SURFACE_STATE_ACTIVATED) {
printf("Surface state: XDG_SURFACE_STATE_ACTIVATED\n");
g->window_state.activated = true;
}
}
if (width > 0 && height > 0) {
g->prev_width = g->width;
g->prev_height = g->height;
g->width = width;
g->height = height;
} else {
g->width = g->prev_width;
g->height = g->prev_height;
}
xdg_surface_ack_configure(xdg_surface, serial);
wl_surface_damage(g->surface, 0, 0, g->width, g->height);
wl_surface_commit(g->surface);
wl_display_dispatch_pending(g->display);
wl_display_flush(g->display);
}
那么,发送 set_maximized 后如何看到最大化的 window? 是否可以通过编程方式取消最小化最小化 window(现在通过 Super+Tab)?
您的客户可能需要将具有正确尺寸的新缓冲区附加并提交到表面。合成器已完成它应该做的所有事情,并希望您的客户端调整大小。