From 3a58aacee4eb5720e239d737b29b443c07534d8c Mon Sep 17 00:00:00 2001 From: "info@petervanderperk.nl" Date: Sun, 15 Jan 2023 20:46:25 +0100 Subject: [PATCH] Modify Weston server decoration to look better in WSLg --- clients/window.c | 57 +++++++++++++++++++++++++++++++---------- data/sign_close.png | Bin 104 -> 1932 bytes data/sign_maximize.png | Bin 85 -> 2081 bytes data/sign_minimize.png | Bin 79 -> 1831 bytes shared/cairo-util.c | 6 ++--- shared/frame.c | 47 +++++++++++++++------------------ 6 files changed, 66 insertions(+), 44 deletions(-) diff --git a/clients/window.c b/clients/window.c index ca7e62d07..e3c37b91c 100644 --- a/clients/window.c +++ b/clients/window.c @@ -1613,18 +1613,12 @@ window_destroy(struct window *window) } static struct widget * -widget_find_widget(struct widget *widget, int32_t x, int32_t y) +widget_find_widget(struct widget *widget, int32_t x, int32_t y, bool get_parent) { struct widget *child, *target; int alloc_x, alloc_y, width, height; double scale; - wl_list_for_each(child, &widget->child_list, link) { - target = widget_find_widget(child, x, y); - if (target) - return target; - } - alloc_x = widget->allocation.x; alloc_y = widget->allocation.y; width = widget->allocation.width; @@ -1641,6 +1635,15 @@ widget_find_widget(struct widget *widget, int32_t x, int32_t y) height = widget->viewport_dest_height; } + wl_list_for_each(child, &widget->child_list, link) { + target = widget_find_widget(child, x, y, get_parent); + if (target && get_parent) { + return widget; + } else if(target) { + return target; + } + } + if (alloc_x <= x && x < alloc_x + width && alloc_y <= y && y < alloc_y + height) { return widget; @@ -1650,13 +1653,13 @@ widget_find_widget(struct widget *widget, int32_t x, int32_t y) } static struct widget * -window_find_widget(struct window *window, int32_t x, int32_t y) +window_find_widget(struct window *window, int32_t x, int32_t y, bool get_parent) { struct surface *surface; struct widget *widget; wl_list_for_each(surface, &window->subsurface_list, link) { - widget = widget_find_widget(surface->widget, x, y); + widget = widget_find_widget(surface->widget, x, y, get_parent); if (widget) return widget; } @@ -2711,7 +2714,7 @@ input_ungrab(struct input *input) input->grab = NULL; if (input->pointer_focus) { widget = window_find_widget(input->pointer_focus, - input->sx, input->sy); + input->sx, input->sy, false); input_set_focus_widget(input, widget, input->sx, input->sy); } } @@ -2777,8 +2780,19 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, input->sx = sx; input->sy = sy; - widget = window_find_widget(window, sx, sy); + widget = window_find_widget(window, sx, sy, false); input_set_focus_widget(input, widget, sx, sy); + widget = window_find_widget(window, sx, sy, true); + + if (widget) { + if (widget->motion_handler) { + if(widget->motion_handler(input->focus_widget, + input, time, sx, sy, + widget->user_data) != CURSOR_LEFT_PTR) { + input_set_focus_widget(input, widget, sx, sy); + } + } + } } static void @@ -2798,7 +2812,7 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer, struct input *input = data; struct window *window = input->pointer_focus; struct widget *widget; - int cursor; + int cursor, parent_cursor; float sx = wl_fixed_to_double(sx_w); float sy = wl_fixed_to_double(sy_w); @@ -2820,7 +2834,7 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer, return; if (!(input->grab && input->grab_button)) { - widget = window_find_widget(window, sx, sy); + widget = window_find_widget(window, sx, sy, false); input_set_focus_widget(input, widget, sx, sy); } @@ -2838,6 +2852,21 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer, } else cursor = CURSOR_LEFT_PTR; + + widget = window_find_widget(window, sx, sy, true); + + if (widget) { + if (widget->motion_handler) { + parent_cursor = widget->motion_handler(input->focus_widget, + input, time, sx, sy, + widget->user_data); + if(parent_cursor != CURSOR_LEFT_PTR) { + input_set_focus_widget(input, widget, sx, sy); + cursor = parent_cursor; + } + } + } + input_set_pointer_image(input, cursor); } @@ -3320,7 +3349,7 @@ touch_handle_down(void *data, struct wl_touch *wl_touch, else widget = window_find_widget(input->touch_focus, wl_fixed_to_double(x_w), - wl_fixed_to_double(y_w)); + wl_fixed_to_double(y_w), false); if (widget) { struct touch_point *tp = xmalloc(sizeof *tp); if (tp) { diff --git a/data/sign_close.png b/data/sign_close.png index 56182a3c460813b04cb1b928db76b00ffed1328b..029c345713a87477ea5b17da7519b9703ad0bb77 100644 GIT binary patch literal 1932 zcma)7eM}Q)7(Y}ttyB5XIboB_Aq;ix^~%TS(SoI|QlN4ap8OU!1b&P>rcVy4W^%n>8(13`3~&P?~-6$`AggE6u6b9z>S9Oi;#U3QzOb8bc~sbC`f1-SS1z`UPN&` z!#0RV;XX2x_2FH3>!HL3f?=_YaKa(jS0g@_arzykQ;ZU*3!@z4;sXRrYTTfL)QHCA zqJXCjaJkS+utFx6g_9o<2-K25+1NWAUnuB^W2n&4k33VMQNF80!k7^N)=5=+pT$D$>B`%2!?`yT=JiNAV`95c+df#op)+&@&e#HXRxZ5qQ7dPFHRoQ+ zyFb9Vo32)LG?|MlnV~{_$Hl_Ln9C=6w|6}V#lATG$7l32SH8D9d4~CN{$N_=@0}M8 zS_^Jg)m3c!MPh$<HbyQMw*&ctpSELB(Du^fNA?NFFzo_p|c;K1CJJ1qzDCVYF> z^W31i`lqHnZNzIY%sG7l>v{j0!hHV1+!I5a`@j15Mn2S+-dbfn(l1-#(e&+0>PFJe zq+d*W`{WPv56cSgPs>8zS-V`>cRl7r^04)C$I%&|Ck(E*7uzz=eSh}3TO{}!P4N{~ za1b>8l(1r27EVtFhb;!3#$w+z@Lh?d5sqv8IcM3^{e-`H)zPzOhKDbneI2&6u{B>D zQ54k7(Z7lPiCVAjZMEI`eqym>`OZ~q>52QXGE-}HeUj?SQ2ll!;~%=e{xj(%|J8k- zc#ZB#O=wHjH_J4OlhO|jH2G4u9ZLDDr~MUKbMCT)z|K>)rM(5ky(Dt`Qs4fexeNMc h>8hi%4Obo|g=v-N7^PmE#mBG{1&t;ucLK6Uw C`XO2X diff --git a/data/sign_maximize.png b/data/sign_maximize.png index ae9e86abea358a359c42eb6a0406f1b74ab17bbb..dae700cb3138bf5b2b927c3c7690d348c9a0cae4 100644 GIT binary patch literal 2081 zcma)73rrJd94`V!tJD|M0-Ib;Kzy{<2cSJD3|a;iimZSX#6WGY<)rP^y93&~C=wrW zKBhy4E;@#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N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`GM+AuAr*|t5^)dgSI%H#o4~-f imT@uLgr0VG1_p0+lQa8Vf;EBa7(8A5T-G@yGywqJc@y&h diff --git a/data/sign_minimize.png b/data/sign_minimize.png index fd3a64aaffa6afd4117a5b13e5c7416cc6555253..6c2e450af05d64fbc6bd42b29ae6483230d76059 100644 GIT binary patch literal 1831 zcma)7eQXnD7{3A2QP_ZiqMO3y#s-MJySCe0Z@XdF&aG@6OFvxOK*rH~+n#Ih%H3^k z!5}O!qKF2O2nIiZ7>OXv2=fnOKtK{4I2RHjijg2;Q(@yn6A&|f@4B^}4a7g*yL;c? z@A-V6=ebv#o9c2k1sViFa;^0iJA6L_*Hbxk;N8Q zYpP-tR1gL-gT}%kUZP?&rs}2Ow{lEis7jIBXv}SEM$Li<&@#LXC$VY`S|zf6%5HgK zR2c4PEGWwniXfuVC>}N7f*2rlMx&7+^@Lupg$%6}=Vd0Q<)tD;MM8%KNIsE^$eh5V zicV&w&@R&$261%Evv4G-oR>zUhj}1kOoY(kB#};z1O-`;g2Dqtl5mC~h;gYH#+gx& z47$wuA3#@-3_8rU&Gzsp!r^g&NOEllOvGqX$2l|>x8#gR0AUA`&@TEwZ3p1xA~hG# z8f6v%BLfRuG^Qu@1}&-6>dKrt17&!QB1;#MI+9G1Z34^r@f143JEvvtfC# zjLiHWelp>d!cI5^OY@-~rDV)PND!fOFb0F_YznfP&CR0V=Ry#Z>~%G$wbop&GnSWY z^|(&uD)&Y;b1@KdTevXbC0JuLR;vFG=t%?h6)8})?SQQX4I~sQH%nQ=OaQcStQ<`0 zN}V?XKA-@jdQ?EUpHRC};4YqnH=3}oLhcksW5#kK&5S1lQd$PBQVWTy=OkGWpBmW81GEKT``nD@1mwBE4%-6%kEd!_jDdX7rch{co+S!Zg3O8%0ZRcxdW?eXO<*nY4&g}Vlm!{UvTK?Y7!fB2R)x*W!>pgu3T#JWV z+dNx-)wti?Q1_Utck)ur(nABzZP5*tZ?mlHZsWzhXR-k#f(JO`R*k zGdqf3s_>p%VsDtz+q>#xNBkpk?w#T{-2Syq-}5_{4{q3juG_rubk3E)x*50D{&lmT zsQm5fnudFyv&Ahl4%wggZJA^hW0rFbf9^Q2s^6!#&pJEu&yD?a=KisLf8~Vl?uMQi zrdRyj^}!zI<)@!K-KV?w{$;)6T;H4%H#ZG_{mHdzWT0eMtLw-hzAR)K*jvz#6`v_N zU-0J19~U0RYwqWk67Q^e(Kv85>qOyg*M;scrhS<|yzE}~_IZK(v(MfF@NYCZQty!v zB=3~6vbHbED};xn)nanGH{Lk+SuTQ3o%q#p_VsUrr5>cE{*txTdvF30JDwBW-*A2C eo2h*WG9n|y-xDU~?W0Y~|IJ$4WI0%~qVr$+o?_Sl literal 79 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`VxBIJAr*|t68jQFdYb;X7(8X; b(Pv=z!zTEC!o8cKKotz0u6{1-oD!Mmargin = 32; - t->width = 6; - t->titlebar_height = 27; + t->margin = 20; + t->width = 0; + t->titlebar_height = 28; t->frame_radius = 3; t->shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); cr = cairo_create(t->shadow); diff --git a/shared/frame.c b/shared/frame.c index cf58d66b7..0f318cab2 100644 --- a/shared/frame.c +++ b/shared/frame.c @@ -209,7 +209,7 @@ frame_button_cancel(struct frame_button *button) } static void -frame_button_repaint(struct frame_button *button, cairo_t *cr) +frame_button_repaint(struct frame_button *button, cairo_t *cr, uint32_t flags) { int x, y; @@ -224,24 +224,30 @@ frame_button_repaint(struct frame_button *button, cairo_t *cr) cairo_save(cr); if (button->flags & FRAME_BUTTON_DECORATED) { - cairo_set_line_width(cr, 1); + cairo_set_line_width(cr, 0); cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); - cairo_rectangle(cr, x, y, 25, 16); + cairo_rectangle(cr, x, y, 42, 28); cairo_stroke_preserve(cr); if (button->press_count) { cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); - } else if (button->hover_count) { - cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + } else if (button->hover_count) { + if(button->status_effect == FRAME_STATUS_CLOSE) { + cairo_set_source_rgb(cr, 0.768, 0.184, 0.109); + } else { + cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + } } else { - cairo_set_source_rgb(cr, 0.88, 0.88, 0.88); + if (flags & THEME_FRAME_ACTIVE) { + cairo_set_source_rgb(cr, 0.941, 0.953, 0.976); + } else { + cairo_set_source_rgb(cr, 0.7, 0.7, 0.7); + } } cairo_fill (cr); - - x += 4; } cairo_set_source_surface(cr, button->icon, x, y); @@ -357,17 +363,6 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons, icon, FRAME_STATUS_MENU, FRAME_BUTTON_CLICK_DOWN); - } else { - char *name = file_name_with_datadir("icon_window.png"); - - if (!name) - goto free_frame; - - button = frame_button_create(frame, - name, - FRAME_STATUS_MENU, - FRAME_BUTTON_CLICK_DOWN); - free(name); } if (!button) goto free_frame; @@ -585,27 +580,25 @@ frame_refresh_geometry(struct frame *frame) x_l = t->width + frame->shadow_margin; y = t->width + frame->shadow_margin; wl_list_for_each(button, &frame->buttons, link) { - const int button_padding = 4; + const int button_padding = 0; w = cairo_image_surface_get_width(button->icon); h = cairo_image_surface_get_height(button->icon); - if (button->flags & FRAME_BUTTON_DECORATED) - w += 10; if (button->flags & FRAME_BUTTON_ALIGN_RIGHT) { x_r -= w; button->allocation.x = x_r; button->allocation.y = y; - button->allocation.width = w + 1; - button->allocation.height = h + 1; + button->allocation.width = w; + button->allocation.height = h; x_r -= button_padding; } else { button->allocation.x = x_l; button->allocation.y = y; - button->allocation.width = w + 1; - button->allocation.height = h + 1; + button->allocation.width = w; + button->allocation.height = h; x_l += w; x_l += button_padding; @@ -1028,7 +1021,7 @@ frame_repaint(struct frame *frame, cairo_t *cr) cairo_restore(cr); wl_list_for_each(button, &frame->buttons, link) - frame_button_repaint(button, cr); + frame_button_repaint(button, cr, flags); frame_status_clear(frame, FRAME_STATUS_REPAINT); }