From bf5ab45f2ea859fd988386431a3cd21bb4371087 Mon Sep 17 00:00:00 2001 From: Nishi Date: Thu, 7 May 2026 18:51:42 +0900 Subject: [PATCH] wayland --- examples/basic/tab.c | 39 +++++++++++++++++++++++++++++++++++ include/Mw/LowLevel/Wayland.h | 3 +++ pl/rules.pl | 1 + src/backend/wayland/wayland.c | 13 ++++++++++-- src/default.c | 2 +- src/draw.c | 4 ++-- 6 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 examples/basic/tab.c diff --git a/examples/basic/tab.c b/examples/basic/tab.c new file mode 100644 index 0000000..8b0ad4a --- /dev/null +++ b/examples/basic/tab.c @@ -0,0 +1,39 @@ +#include + +MwWidget tab; + +static void MWAPI resize(MwWidget handle, void* user, void* client) { + MwVaApply(tab, + MwNwidth, MwGetInteger(handle, MwNwidth), + MwNheight, MwGetInteger(handle, MwNheight), + NULL); +} + +int main() { + MwWidget w; + int i; + MwLLPixmap px[6]; + + MwLibraryInit(); + + w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 800, 600, + MwNtitle, "subwindow", + NULL); + + tab = MwCreateWidget(MwTabClass, "tab", w, 0, 0, 800, 600); + + for(i = 0; i < 16; i++) { + char buf[32]; + MwWidget sw, f, img; + + sprintf(buf, "Tab %d", i); + + MwTabAdd(tab, buf); + } + + MwAddUserHandler(w, MwNresizeHandler, resize, NULL); + + resize(w, NULL, NULL); + + MwLoop(w); +} diff --git a/include/Mw/LowLevel/Wayland.h b/include/Mw/LowLevel/Wayland.h index 3babbaf..2de34d2 100644 --- a/include/Mw/LowLevel/Wayland.h +++ b/include/Mw/LowLevel/Wayland.h @@ -446,6 +446,9 @@ struct _MwLLWayland { MwBool is_toplevel; + MwBool is_clipping; + MwRect clip; + /* Map of Wayland interfaces to their relevant setup functions. */ struct { char* key; diff --git a/pl/rules.pl b/pl/rules.pl index ef96374..0c5ae4a 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -201,6 +201,7 @@ new_example("examples/basic/calculator"); new_example("examples/basic/filechooser"); new_example("examples/basic/periodic"); new_example("examples/basic/subwindow"); +new_example("examples/basic/tab"); if (param_get("opengl")) { new_example("examples/gldemos/boing", $gl_libs); diff --git a/src/backend/wayland/wayland.c b/src/backend/wayland/wayland.c index e6d6c69..1db2c15 100644 --- a/src/backend/wayland/wayland.c +++ b/src/backend/wayland/wayland.c @@ -591,6 +591,11 @@ static void clip(MwLL handle) { cairo_rectangle(handle->wayland.front_cairo, cx - x, cy - y, mx - cx, my - cy); cairo_clip(handle->wayland.front_cairo); } + + if(handle->wayland.is_clipping){ + cairo_rectangle(handle->wayland.front_cairo, handle->wayland.clip.x, handle->wayland.clip.y, handle->wayland.clip.width, handle->wayland.clip.height); + cairo_clip(handle->wayland.front_cairo); + } } } @@ -700,6 +705,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { } r->wayland.is_toplevel = parent == NULL; + r->wayland.is_clipping = 0; widget_setup(r, parent, x, y, width, height, MwLL_WAYLAND_UNKNOWN); @@ -1597,8 +1603,11 @@ static void MwLLRaiseImpl(MwLL handle) { } static void MwLLClipImpl(MwLL handle, MwRect* rect) { - (void)handle; - (void)rect; + if(rect == NULL){ + handle->wayland.is_clipping = MwFALSE; + }else{ + handle->wayland.clip = *rect; + } } static int MwLLWaylandCallInitImpl(void) { diff --git a/src/default.c b/src/default.c index a1acbd0..8b8cf58 100644 --- a/src/default.c +++ b/src/default.c @@ -22,7 +22,7 @@ int MwDefaultBorderWidth(MwWidget handle) { if(bw != MwDEFAULT) return bw; if(MwGetInteger(handle, MwNmodernLook)) { - return 1; + return 2; } else { return 2; } diff --git a/src/draw.c b/src/draw.c index 32c2cd3..8145df8 100644 --- a/src/draw.c +++ b/src/draw.c @@ -359,13 +359,13 @@ static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff); MwRect r = *rect; - frame_border_complex(handle, rect, lighter, darker, invert, border, diff, same); + frame_border_complex(handle, rect, lighter, darker, invert, border / 2, diff, same); r.x += 1; r.y += 1; r.width -= 2; r.height -= 2; - frame_border_complex(handle, &r, lighter, darker, !invert, border, diff, same); + frame_border_complex(handle, &r, lighter, darker, !invert, border / 2, diff, same); MwLLFreeColor(lighter); MwLLFreeColor(darker);