forked from pyrite-dev/milsko
fix resizing
This commit is contained in:
parent
c796ed617d
commit
cb09986053
2 changed files with 37 additions and 29 deletions
|
|
@ -87,7 +87,10 @@ struct _MwLLWayland {
|
||||||
|
|
||||||
MwBool egl_setup;
|
MwBool egl_setup;
|
||||||
MwBool has_set_xy;
|
MwBool has_set_xy;
|
||||||
MwU32 x, y, ww, wh;
|
int resize_counter;
|
||||||
|
MwU32 x, y;
|
||||||
|
MwU32 ww, wh;
|
||||||
|
MwU32 lw, lh;
|
||||||
MwPoint cur_mouse_pos;
|
MwPoint cur_mouse_pos;
|
||||||
|
|
||||||
struct timeval timer;
|
struct timeval timer;
|
||||||
|
|
@ -95,7 +98,9 @@ struct _MwLLWayland {
|
||||||
MwU64 cooldown_timer;
|
MwU64 cooldown_timer;
|
||||||
MwU64 cooldown_timer_epoch;
|
MwU64 cooldown_timer_epoch;
|
||||||
|
|
||||||
MwLL parent;
|
MwLL parent;
|
||||||
|
MwLL topmost_parent;
|
||||||
|
MwBool draw_recursively;
|
||||||
|
|
||||||
GLuint fbo;
|
GLuint fbo;
|
||||||
unsigned int fbo_texture;
|
unsigned int fbo_texture;
|
||||||
|
|
|
||||||
|
|
@ -428,6 +428,16 @@ static int event_loop(MwLL handle) {
|
||||||
printf("error\n");
|
printf("error\n");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
/* HACK: If the last known size is different, force a redraw */
|
||||||
|
if(wayland->lw != wayland->ww || wayland->lh != wayland->wh) {
|
||||||
|
MwLLDispatch(handle, draw, 0);
|
||||||
|
wayland->resize_counter++;
|
||||||
|
if(wayland->resize_counter >= 5) {
|
||||||
|
wayland->lw = wayland->ww;
|
||||||
|
wayland->lh = wayland->wh;
|
||||||
|
wayland->resize_counter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -544,10 +554,13 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) {
|
||||||
struct wl_subcompositor* subcompositor = parent->wayland.subcompositor;
|
struct wl_subcompositor* subcompositor = parent->wayland.subcompositor;
|
||||||
struct wl_surface* parent_surface = parent->wayland.surface;
|
struct wl_surface* parent_surface = parent->wayland.surface;
|
||||||
struct wl_region* region;
|
struct wl_region* region;
|
||||||
MwLL topmost_parent = parent;
|
{
|
||||||
|
MwLL topmost_parent = parent;
|
||||||
|
|
||||||
while(topmost_parent->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
while(topmost_parent->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
||||||
topmost_parent = topmost_parent->wayland.parent;
|
topmost_parent = topmost_parent->wayland.parent;
|
||||||
|
}
|
||||||
|
r->wayland.topmost_parent = topmost_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->wayland.type = MWLL_WAYLAND_SUBLEVEL;
|
r->wayland.type = MWLL_WAYLAND_SUBLEVEL;
|
||||||
|
|
@ -571,8 +584,8 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) {
|
||||||
|
|
||||||
setup_callbacks(&r->wayland);
|
setup_callbacks(&r->wayland);
|
||||||
|
|
||||||
r->wayland.registry = wl_display_get_registry(topmost_parent->wayland.display);
|
r->wayland.registry = wl_display_get_registry(r->wayland.topmost_parent->wayland.display);
|
||||||
r->wayland.display = topmost_parent->wayland.display;
|
r->wayland.display = r->wayland.topmost_parent->wayland.display;
|
||||||
|
|
||||||
wl_registry_add_listener(r->wayland.registry, &r->wayland.registry_listener, r);
|
wl_registry_add_listener(r->wayland.registry, &r->wayland.registry_listener, r);
|
||||||
if(wl_display_roundtrip(r->wayland.display) == -1) {
|
if(wl_display_roundtrip(r->wayland.display) == -1) {
|
||||||
|
|
@ -597,9 +610,9 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) {
|
||||||
|
|
||||||
wl_surface_damage(parent->wayland.surface, 0, 0, parent->wayland.ww, parent->wayland.wh);
|
wl_surface_damage(parent->wayland.surface, 0, 0, parent->wayland.ww, parent->wayland.wh);
|
||||||
|
|
||||||
egl_resetup(topmost_parent);
|
egl_resetup(r->wayland.topmost_parent);
|
||||||
MwLLDispatch(topmost_parent, draw, NULL);
|
MwLLDispatch(r->wayland.topmost_parent, draw, NULL);
|
||||||
recursive_draw(topmost_parent);
|
recursive_draw(r->wayland.topmost_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
|
|
@ -628,6 +641,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
|
|
||||||
r->wayland.cooldown_timer = 0;
|
r->wayland.cooldown_timer = 0;
|
||||||
r->wayland.has_set_xy = MwFALSE;
|
r->wayland.has_set_xy = MwFALSE;
|
||||||
|
r->wayland.resize_counter = 0;
|
||||||
|
|
||||||
r->wayland.force_redraw = MwFALSE;
|
r->wayland.force_redraw = MwFALSE;
|
||||||
r->wayland.subwidgets = NULL;
|
r->wayland.subwidgets = NULL;
|
||||||
|
|
@ -656,17 +670,11 @@ static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsign
|
||||||
|
|
||||||
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
||||||
if(handle->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
if(handle->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
||||||
MwLL topmost_parent = handle->wayland.parent;
|
|
||||||
|
|
||||||
while(topmost_parent->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
|
||||||
topmost_parent = topmost_parent->wayland.parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle->wayland.x = x;
|
handle->wayland.x = x;
|
||||||
handle->wayland.y = y;
|
handle->wayland.y = y;
|
||||||
if(handle->wayland.has_set_xy) {
|
if(handle->wayland.has_set_xy) {
|
||||||
timed_redraw_by_epoch(topmost_parent, 25);
|
timed_redraw_by_epoch(handle->wayland.topmost_parent, 25);
|
||||||
recursive_draw(topmost_parent);
|
recursive_draw(handle->wayland.topmost_parent);
|
||||||
} else if(x != 0 && y != 0) {
|
} else if(x != 0 && y != 0) {
|
||||||
handle->wayland.has_set_xy = MwTRUE;
|
handle->wayland.has_set_xy = MwTRUE;
|
||||||
}
|
}
|
||||||
|
|
@ -676,23 +684,18 @@ static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
||||||
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
||||||
/* Prevent an integer underflow when the w/h is too low */
|
/* Prevent an integer underflow when the w/h is too low */
|
||||||
if((w < 10 || h < 10)) {
|
if((w < 10 || h < 10)) {
|
||||||
handle->wayland.ww = 10;
|
handle->wayland.ww = handle->wayland.lw = 10;
|
||||||
handle->wayland.wh = 10;
|
handle->wayland.wh = handle->wayland.lh = 10;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handle->wayland.ww = w;
|
handle->wayland.ww = handle->wayland.lw = w;
|
||||||
handle->wayland.wh = h;
|
handle->wayland.wh = handle->wayland.lh = h;
|
||||||
|
|
||||||
if(handle->wayland.type == MWLL_WAYLAND_TOPLEVEL) {
|
if(handle->wayland.type == MWLL_WAYLAND_TOPLEVEL) {
|
||||||
xdg_surface_set_window_geometry(handle->wayland.toplevel->xdg_surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
|
xdg_surface_set_window_geometry(handle->wayland.toplevel->xdg_surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
|
||||||
} else {
|
} else {
|
||||||
MwLL topmost_parent = handle->wayland.parent;
|
timed_redraw_by_epoch(handle->wayland.topmost_parent, 25);
|
||||||
|
recursive_draw(handle->wayland.topmost_parent);
|
||||||
while(topmost_parent->wayland.type != MWLL_WAYLAND_TOPLEVEL) {
|
|
||||||
topmost_parent = topmost_parent->wayland.parent;
|
|
||||||
}
|
|
||||||
timed_redraw_by_epoch(topmost_parent, 25);
|
|
||||||
recursive_draw(topmost_parent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue