forked from pyrite-dev/milsko
better yet broken
This commit is contained in:
parent
06645250ca
commit
dbb436f5a2
2 changed files with 16 additions and 16 deletions
|
|
@ -23,7 +23,7 @@ int main() {
|
|||
|
||||
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480, MwNtitle, "test", NULL);
|
||||
|
||||
vp = MwCreateWidget(MwViewportClass, "vp", w, 5 + 100, 5 + 100, 640 - 10 - 100, 480 - 10 - 100);
|
||||
vp = MwCreateWidget(MwViewportClass, "vp", w, 5 + 50, 5 + 50, 640 - 10 - 100, 480 - 10 - 100);
|
||||
|
||||
px = MwLoadImage(vp, "examples/picture.png");
|
||||
|
||||
|
|
@ -31,10 +31,11 @@ int main() {
|
|||
|
||||
if(px == NULL) px = MwLoadImage(vp, "picture.png");
|
||||
|
||||
MwVaCreateWidget(MwImageClass, "image", MwViewportGetViewport(vp), 0, 0, 1024, 1024,
|
||||
MwNpixmap, px,
|
||||
NULL);
|
||||
// MwVaCreateWidget(MwImageClass, "image", MwViewportGetViewport(vp), 0, 0, 1024, 1024,
|
||||
// MwNpixmap, px,
|
||||
// NULL);
|
||||
MwViewportSetSize(vp, 1024, 1024);
|
||||
MwCreateWidget(MwButtonClass, "btn", MwViewportGetViewport(vp), 256, 256, 128, 128);
|
||||
|
||||
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -1720,7 +1720,7 @@ static void destroy_popup(MwLL r) {
|
|||
|
||||
static void clip(MwLL handle) {
|
||||
int i;
|
||||
int w, h, x, y, cx, cy;
|
||||
int x, y, cx, cy, mx, my;
|
||||
MwLL toplevel = handle->wayland.parent;
|
||||
MwLL* ws = NULL;
|
||||
|
||||
|
|
@ -1735,34 +1735,33 @@ static void clip(MwLL handle) {
|
|||
if(toplevel) {
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
w = toplevel->wayland.ww;
|
||||
h = toplevel->wayland.wh;
|
||||
x = 0;
|
||||
y = 0;
|
||||
cx = 0;
|
||||
cy = 0;
|
||||
mx = toplevel->wayland.ww;
|
||||
my = toplevel->wayland.wh;
|
||||
// ws is traversed result
|
||||
// ws[ws.length - 1] is ignored bc it's toplevel
|
||||
for(i = arrlen(ws) - 2; i >= 0; i--) {
|
||||
x += ws[i]->wayland.x;
|
||||
y += ws[i]->wayland.y;
|
||||
cx += MAX(-ws[i]->wayland.x, 0);
|
||||
cy += MAX(-ws[i]->wayland.y, 0);
|
||||
w = MIN(ws[i]->wayland.ww - MAX(-x, 0), w);
|
||||
h = MIN(ws[i]->wayland.wh - MAX(-y, 0), h);
|
||||
|
||||
mx = MIN(mx, x + ws[i]->wayland.ww);
|
||||
my = MIN(my, y + ws[i]->wayland.wh);
|
||||
}
|
||||
|
||||
arrfree(ws);
|
||||
|
||||
handle->wayland.clipping_rect.x = cx;
|
||||
handle->wayland.clipping_rect.y = cy;
|
||||
handle->wayland.clipping_rect.width = w;
|
||||
handle->wayland.clipping_rect.height = h;
|
||||
handle->wayland.clipping_rect.x = cx - x;
|
||||
handle->wayland.clipping_rect.y = cy - y;
|
||||
handle->wayland.clipping_rect.width = mx - cx;
|
||||
handle->wayland.clipping_rect.height = my - cy;
|
||||
region_setup(handle);
|
||||
|
||||
cairo_reset_clip(handle->wayland.front_cairo);
|
||||
if(handle->wayland.type == MwLL_WAYLAND_SUBLEVEL) {
|
||||
cairo_rectangle(handle->wayland.front_cairo, cx, cy, w, h);
|
||||
cairo_rectangle(handle->wayland.front_cairo, cx - x, cy - y, mx - cx, my - cy);
|
||||
cairo_clip(handle->wayland.front_cairo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue