[digesting_libdecor] simplify a little, eliminate dead code
parent
b54c919670
commit
ecf7d9254d
|
|
@ -560,11 +560,8 @@ const struct wl_registry_listener wl_registry_listener = {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdg_surface_configure(void *user_data, struct xdg_surface *xdg_surface, uint32_t serial){
|
xdg_surface_configure(void *user_data, struct xdg_surface *xdg_surface, uint32_t serial){
|
||||||
struct libdecor_configuration *configuration;
|
struct libdecor_configuration *configuration = ctx.pending_configuration;
|
||||||
|
|
||||||
configuration = ctx.pending_configuration;
|
|
||||||
ctx.pending_configuration = 0;
|
ctx.pending_configuration = 0;
|
||||||
|
|
||||||
if (configuration == 0){
|
if (configuration == 0){
|
||||||
configuration = calloc(1, sizeof *configuration);
|
configuration = calloc(1, sizeof *configuration);
|
||||||
}
|
}
|
||||||
|
|
@ -576,8 +573,7 @@ xdg_surface_configure(void *user_data, struct xdg_surface *xdg_surface, uint32_t
|
||||||
int h = ctx.h;
|
int h = ctx.h;
|
||||||
|
|
||||||
bool got_size = false;
|
bool got_size = false;
|
||||||
if (configuration->has_window_state &&
|
if (configuration->initialized &&
|
||||||
configuration->has_size &&
|
|
||||||
configuration->window_width != 0 &&
|
configuration->window_width != 0 &&
|
||||||
configuration->window_height != 0){
|
configuration->window_height != 0){
|
||||||
|
|
||||||
|
|
@ -587,13 +583,11 @@ xdg_surface_configure(void *user_data, struct xdg_surface *xdg_surface, uint32_t
|
||||||
if (ctx.visible && ctx.decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE){
|
if (ctx.visible && ctx.decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE){
|
||||||
ctx.frame_window_state = configuration->window_state;
|
ctx.frame_window_state = configuration->window_state;
|
||||||
Sides2D border_size = border_size_from_window_state(configuration->window_state);
|
Sides2D border_size = border_size_from_window_state(configuration->window_state);
|
||||||
w -= border_size.x[0] + border_size.x[1];
|
w -= border_size.x[0] + border_size.x[1];
|
||||||
h -= border_size.y[0] + border_size.y[1];
|
h -= border_size.y[0] + border_size.y[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* constrain content dimensions manually */
|
if (!(configuration->window_state & LIBDECOR_WINDOW_STATE_NON_FLOATING)){
|
||||||
if (!(configuration->window_state & LIBDECOR_WINDOW_STATE_NON_FLOATING)) {
|
|
||||||
// TODO(allen):
|
|
||||||
if (ctx.size_bounds.x[0] > 0){
|
if (ctx.size_bounds.x[0] > 0){
|
||||||
w = MAX(ctx.size_bounds.x[0], w);
|
w = MAX(ctx.size_bounds.x[0], w);
|
||||||
}
|
}
|
||||||
|
|
@ -608,15 +602,17 @@ xdg_surface_configure(void *user_data, struct xdg_surface *xdg_surface, uint32_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
got_size = true;
|
|
||||||
}
|
|
||||||
if (got_size){
|
|
||||||
ctx.w = w;
|
ctx.w = w;
|
||||||
ctx.h = h;
|
ctx.h = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx.configured){
|
if (!ctx.configured){
|
||||||
ctx.configured = 1;
|
ctx.configured = 1;
|
||||||
libdecor_frame_commit(w, h, configuration);
|
if (configuration->initialized){
|
||||||
|
ctx.frame_window_state = configuration->window_state;
|
||||||
|
}
|
||||||
|
libdecor_frame_commit(w, h);
|
||||||
|
xdg_surface_ack_configure(ctx.xdg_surface, configuration->serial);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ctx.has_cached_config = 1;
|
ctx.has_cached_config = 1;
|
||||||
|
|
@ -662,10 +658,9 @@ xdg_toplevel_configure(void *user_data, struct xdg_toplevel *xdg_toplevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.pending_configuration = calloc(1, sizeof *ctx.pending_configuration);
|
ctx.pending_configuration = calloc(1, sizeof *ctx.pending_configuration);
|
||||||
ctx.pending_configuration->has_size = true;
|
ctx.pending_configuration->initialized = true;
|
||||||
ctx.pending_configuration->window_width = width;
|
ctx.pending_configuration->window_width = width;
|
||||||
ctx.pending_configuration->window_height = height;
|
ctx.pending_configuration->window_height = height;
|
||||||
ctx.pending_configuration->has_window_state = true;
|
|
||||||
ctx.pending_configuration->window_state = window_state;
|
ctx.pending_configuration->window_state = window_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1097,7 +1092,11 @@ int main(){
|
||||||
|
|
||||||
if (ctx.has_cached_config){
|
if (ctx.has_cached_config){
|
||||||
ctx.has_cached_config = 0;
|
ctx.has_cached_config = 0;
|
||||||
libdecor_frame_commit(ctx.w, ctx.h, &ctx.cached_config);
|
if (ctx.cached_config.initialized){
|
||||||
|
ctx.frame_window_state = ctx.cached_config.window_state;
|
||||||
|
}
|
||||||
|
libdecor_frame_commit(ctx.w, ctx.h);
|
||||||
|
xdg_surface_ack_configure(ctx.xdg_surface, ctx.cached_config.serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (nodocs-wl_egl) */
|
/* (nodocs-wl_egl) */
|
||||||
|
|
@ -1275,27 +1274,6 @@ update_client_side_rendering_state(void){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
libdecor_frame_set_visibility(bool visible){
|
|
||||||
ctx.visible = visible;
|
|
||||||
if (ctx.decoration_manager != 0 &&
|
|
||||||
ctx.toplevel_decoration != 0 &&
|
|
||||||
ctx.has_decoration_mode &&
|
|
||||||
ctx.decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE){
|
|
||||||
zxdg_toplevel_decoration_v1_set_mode(ctx.toplevel_decoration,
|
|
||||||
ctx.visible ?
|
|
||||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE :
|
|
||||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx.frame_content_width > 0 &&
|
|
||||||
ctx.frame_content_height > 0){
|
|
||||||
update_client_side_rendering_state();
|
|
||||||
|
|
||||||
wl_surface_commit(ctx.wl_surface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum xdg_toplevel_resize_edge
|
static enum xdg_toplevel_resize_edge
|
||||||
xdg_edge_from_edge(enum libdecor_resize_edge edge){
|
xdg_edge_from_edge(enum libdecor_resize_edge edge){
|
||||||
enum xdg_toplevel_resize_edge result = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
|
enum xdg_toplevel_resize_edge result = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
|
||||||
|
|
@ -1324,14 +1302,14 @@ libdecor_frame_unset_fullscreen(void){
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
libdecor_frame_commit(int w, int h, struct libdecor_configuration *configuration){
|
libdecor_frame_commit(int w, int h){
|
||||||
if (configuration != 0 && configuration->has_window_state){
|
|
||||||
ctx.frame_window_state = configuration->window_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sides2D border_size = border_size_from_window_state(ctx.frame_window_state);
|
Sides2D border_size = border_size_from_window_state(ctx.frame_window_state);
|
||||||
int border_added_w = border_size.x[0] + border_size.x[1];
|
int border_added_w = 0;
|
||||||
int border_added_h = border_size.y[0] + border_size.y[1];
|
int border_added_h = 0;
|
||||||
|
if (ctx.visible && ctx.decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE){
|
||||||
|
border_added_w = border_size.x[0] + border_size.x[1];
|
||||||
|
border_added_h = border_size.y[0] + border_size.y[1];
|
||||||
|
}
|
||||||
|
|
||||||
struct libdecor_state state = {0};
|
struct libdecor_state state = {0};
|
||||||
state.content_width = w;
|
state.content_width = w;
|
||||||
|
|
@ -1349,30 +1327,22 @@ libdecor_frame_commit(int w, int h, struct libdecor_configuration *configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 2; i += 1){
|
for (int i = 0; i < 2; i += 1){
|
||||||
int w = 0;
|
int mw = 0;
|
||||||
int h = 0;
|
int mh = 0;
|
||||||
if (ctx.size_bounds.x[i] > 0 && ctx.size_bounds.y[i] > 0){
|
if (ctx.size_bounds.x[i] > 0 && ctx.size_bounds.y[i] > 0){
|
||||||
w = ctx.size_bounds.x[i];
|
mw = ctx.size_bounds.x[i] + border_added_w;
|
||||||
h = ctx.size_bounds.y[i];
|
mh = ctx.size_bounds.y[i] + border_added_h;
|
||||||
if (ctx.visible && ctx.decoration_mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE){
|
|
||||||
w += border_added_w;
|
|
||||||
h += border_added_h;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (i == 0){
|
if (i == 0){
|
||||||
xdg_toplevel_set_min_size(ctx.xdg_toplevel, w, h);
|
xdg_toplevel_set_min_size(ctx.xdg_toplevel, mw, mh);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
xdg_toplevel_set_max_size(ctx.xdg_toplevel, w, h);
|
xdg_toplevel_set_max_size(ctx.xdg_toplevel, mw, mh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_client_side_rendering_state();
|
update_client_side_rendering_state();
|
||||||
|
|
||||||
if (configuration != 0){
|
|
||||||
xdg_surface_ack_configure(ctx.xdg_surface, configuration->serial);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -2304,7 +2274,7 @@ draw_title_bar(void){
|
||||||
H = ctx.frame_content_height;
|
H = ctx.frame_content_height;
|
||||||
if (W < ctx.size_bounds.x[0]){
|
if (W < ctx.size_bounds.x[0]){
|
||||||
W = ctx.size_bounds.x[0];
|
W = ctx.size_bounds.x[0];
|
||||||
libdecor_frame_commit(W, H, NULL);
|
libdecor_frame_commit(W, H);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* set default height */
|
/* set default height */
|
||||||
|
|
|
||||||
|
|
@ -184,13 +184,10 @@ struct libdecor_state {
|
||||||
int content_height;
|
int content_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct libdecor_configuration {
|
struct libdecor_configuration{
|
||||||
|
bool initialized;
|
||||||
uint32_t serial;
|
uint32_t serial;
|
||||||
|
|
||||||
bool has_window_state;
|
|
||||||
enum libdecor_window_state window_state;
|
enum libdecor_window_state window_state;
|
||||||
|
|
||||||
bool has_size;
|
|
||||||
int window_width;
|
int window_width;
|
||||||
int window_height;
|
int window_height;
|
||||||
};
|
};
|
||||||
|
|
@ -250,10 +247,9 @@ enum titlebar_gesture {
|
||||||
|
|
||||||
|
|
||||||
// libdecor.h
|
// libdecor.h
|
||||||
void libdecor_frame_set_visibility(bool visible);
|
|
||||||
void libdecor_frame_show_window_menu(struct wl_seat *wl_seat, uint32_t serial, int x, int y);
|
void libdecor_frame_show_window_menu(struct wl_seat *wl_seat, uint32_t serial, int x, int y);
|
||||||
|
|
||||||
void libdecor_frame_commit(int w, int h, struct libdecor_configuration *configuration);
|
void libdecor_frame_commit(int w, int h);
|
||||||
void libdecor_frame_set_fullscreen(struct wl_output *output);
|
void libdecor_frame_set_fullscreen(struct wl_output *output);
|
||||||
void libdecor_frame_unset_fullscreen(void);
|
void libdecor_frame_unset_fullscreen(void);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue