From 2334ffcbf8d621c0d4feaa6c1323efc0c130e3dc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 31 Mar 2019 22:09:10 +0200 Subject: [PATCH] WindowServer: Add a WSCursor class (a bitmap and a hotspot.) Also import a bunch of cursors I drew. Only the default ("arrow") cursor is ever used so far. --- Base/res/cursors/arrow.png | Bin 0 -> 466 bytes Base/res/cursors/disallowed.png | Bin 0 -> 500 bytes Base/res/cursors/i-beam.png | Bin 0 -> 280 bytes Base/res/cursors/resize-diagonal-bltr.png | Bin 0 -> 463 bytes Base/res/cursors/resize-diagonal-tlbr.png | Bin 0 -> 456 bytes Base/res/cursors/resize-horizontal.png | Bin 0 -> 7484 bytes Base/res/cursors/resize-vertical.png | Bin 0 -> 7461 bytes Servers/WindowServer/Makefile | 3 ++- Servers/WindowServer/WSCursor.cpp | 21 ++++++++++++++++ Servers/WindowServer/WSCursor.h | 22 +++++++++++++++++ Servers/WindowServer/WSWindowManager.cpp | 28 +++++++++++++--------- Servers/WindowServer/WSWindowManager.h | 14 ++++++++--- SharedGraphics/Point.h | 7 ++++++ 13 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 Base/res/cursors/arrow.png create mode 100644 Base/res/cursors/disallowed.png create mode 100644 Base/res/cursors/i-beam.png create mode 100644 Base/res/cursors/resize-diagonal-bltr.png create mode 100644 Base/res/cursors/resize-diagonal-tlbr.png create mode 100644 Base/res/cursors/resize-horizontal.png create mode 100644 Base/res/cursors/resize-vertical.png create mode 100644 Servers/WindowServer/WSCursor.cpp create mode 100644 Servers/WindowServer/WSCursor.h diff --git a/Base/res/cursors/arrow.png b/Base/res/cursors/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..427b92027a9c599512b1f3a1eedd01bf94c247d5 GIT binary patch literal 466 zcmV;@0WJQCP)K$BjSBz(02y>e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00BBlL_t(I%Z=1cPTW8chT*5j z<|iydg2;j>yx~_vWe8gS^YIS89T(D6C z5%___UIk6>+bqD(f)O|!6R77|C}~9C8NAe12uw!du?j}v7X-G@tOXAQ-s3ek)`kby zxQDHF9jKIr%h*QS@8gBd$yDttF5)+Mm<$IX;0cZgBH!=}Kl8kA1I~Kj7hKoaz*_vz z+PoyNgLin7h1+aC!1r2y#6RO4w{3?0F5@_j@?#pIS(1IT-(g)g|ILT^jeilG;!`Q5 zWY>cn)tzTdFYwEzGB literal 0 HcmV?d00001 diff --git a/Base/res/cursors/disallowed.png b/Base/res/cursors/disallowed.png new file mode 100644 index 0000000000000000000000000000000000000000..5d7d5f26cd40402b5225c0a04eefef501c8dbbc0 GIT binary patch literal 500 zcmVe zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00CS{L_t(I%hl99PTX)11@ND< zn=Ar^P$UEe;u5e8+=C*Bf>eltnv3KnX*dB*asz~r_|PsCY$7Q5k|~%)mOWk}I;OGw zpLx%3-u%aWmMD_<4!&Uqb2v_Leca$b?(l$Tl-UQqViwC$P-ZdCVKr)J0}H-XNIU4^ zJI>0o^onmrCHDs_f$3$n(_@7blr_}H*?M3bo-W|3s;(&B(tEha6n@n^h`KfWg>EG` zmlW<}fPZm(*k%cqGNomraub&^*`utB@mahV^+DAEd!ew6@Ssg{cfuXMk7q`>i`$Qo zPSrgO!k-x8={*}&*8I^zcoCbFb9~y;e1S7C9ji3ZVM-Y8D-Ni!s8z1 qu^6lOJK^044+o)e6!-ekr-~OjK;6I(uIftw0000_9Ba!3HF|e7-mXDYhhUcNd2LAh=-f^2tCE&H|6f zVg?31We{epSZZGe6l5>)^mS!_%q-8X!M8MT(oLX{WQl7;iF1B#Zfaf$gL6@8Vo7R> zLV0FMhJw4NZ$Nk>pEyuagQtsQh{pM+mmIm640%{DTtCxcu&Zdb`-R{0)6Xr~F)=fC zhLht5CbmQQpX==!m;7*XRB>|FjhwN;yM=fCi9SjHIR(cVie zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00B2iL_t(I%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PEEyawkwFIdR3Nz~4dg-U0$6PfiU`M`NIGzg z7L^FcQqU+k3Ztv5O(g?JEQz#)!j??~Q=90!)GIy}1*D?r>gu4#NEBR$O2WV~dKfJ@ z7K@?4wUIhlj2;T5Lq%iesrbU;jO{E9U}#O`pDlL2L@t%drW?SlXbk_rKRcXgbik2I zzaI|DNYZ;O|Th;2Oo@vV$!D&7}SZ4!@9< z+d*3+SqH0mJv2ZFDsSU>fC@nY($UoBer(8ef`bP@eo46ic0sez- z8Pk$r?4($>m6BA69F zW7cCXY-Qe|C>1a&bSr;-5oV3+B?L>kDs=F?!{yY}{>+TdCtboJfo=ZH!o!`^J=Lqn z(j$kpmAQNKnjg?*T<(Z;C@?y!AdT0{b~~`oh&=!N7ume_j^T5|lWV(K zKE5?Zl4*TokBh#PjUJ445LfD$$-E}gI%PU_uLTlDiYbu4Fm=-6W}NGdHTcrf?ob2o zP9cw|qF2AGq`$-k?dlX5VY%%H!sd4fmg=>+)GV9Qi;_qWp29U6?3~2gOuQ(k1y6f5 zrOeTmjLSSdU573Wn+}b9Wm$?w3|5>UF_Ox+F$fzM(fQUB hKL{VY?0@g8Q0un~k$5M$S};BkOEVinhRMDo{{kI*=12el literal 0 HcmV?d00001 diff --git a/Base/res/cursors/resize-vertical.png b/Base/res/cursors/resize-vertical.png new file mode 100644 index 0000000000000000000000000000000000000000..a0b493ce8ce21cab9be3f5eb5318d16997c131ad GIT binary patch literal 7461 zcmeHMc|6oz+aE+_i&9xq6R9j?X3Q977%ICgHH0M0@*9TP%nUQ6qEczGv{FgRvFdq3~}`8@Z3@tNgZ=X-t6b-w4i&hH$eH#ynJNvldj zAP_k_TT6oI6MQY5Ck4LOUap9QK&1DDxq9#jL_Uy~S0-r+IensF(ied-D7P1!>o1Z2Q~W&K+x-8tVv}YFT`I zf&Pa^dw9iwJ$?{jO#3#dI_wf&kbL8`nayZl!SS&Ph1*Kl%2%)4&Uc>ej2tiH?!*ts zW_B!CG&nhd*gZisT@*E>_l5c_XV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>k`;z?NO&I#+p#dPFb+^nWfq{CHgka*?XcobqC_CfpHDR!p`kh)gXUMp&7sbhEREX z_3o5%$S5Q(yEsGOHZJj^S+*>W^F(E1dY{Db`<*Ihg@G!ZCo<<+R@!R|Pkl8FUlWgg zaV%_E+h)l$$q}8GF`90b5p%h|QuhuftWWiNH>bMzipQ{HC}C_oNq8b~AWLh^Y>XYX zCjOiLTcgO{FN(=+mN#^AD~yiZPU!w7={KTUn;+}B#>={vB(=R|2jq0Z*yXzMhv=FM zJ4Y%7@T94%Ohx|}Ugn1%wQh6O&a*LVar&B`*VL-Et#!!5upf@<&TB)uZ9gG!Rr7q1 z66(sSH?;ZI6(Nqc58bPNS^rF78P@wrNy2@(E$7JYDT-%31lvobj1T9@Rn~hAm}QQr z4)=*&Nx9>katL;r*D{rLWLtssl$3efqM@~)_pjLK + +WSCursor::WSCursor(Retained&& bitmap, const Point& hotspot) + : m_bitmap(move(bitmap)) + , m_hotspot(hotspot) +{ +} + +WSCursor::~WSCursor() +{ +} + +Retained WSCursor::create(Retained&& bitmap) +{ + return adopt(*new WSCursor(move(bitmap), bitmap->rect().center())); +} + +Retained WSCursor::create(Retained&& bitmap, const Point& hotspot) +{ + return adopt(*new WSCursor(move(bitmap), hotspot)); +} diff --git a/Servers/WindowServer/WSCursor.h b/Servers/WindowServer/WSCursor.h new file mode 100644 index 00000000000..7125ad2a782 --- /dev/null +++ b/Servers/WindowServer/WSCursor.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +class WSCursor : public Retainable { +public: + static Retained create(Retained&&, const Point& hotspot); + static Retained create(Retained&&); + ~WSCursor(); + + Point hotspot() const { return m_hotspot; } + const GraphicsBitmap& bitmap() const { return *m_bitmap; } + + Rect rect() const { return m_bitmap->rect(); } + Size size() const { return m_bitmap->size(); } + +private: + WSCursor(Retained&&, const Point&); + + RetainPtr m_bitmap; + Point m_hotspot; +}; diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index 2de9c04b981..23a8503115e 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -16,6 +16,7 @@ #include #include #include +#include "WSCursor.h" #ifdef KERNEL #include @@ -199,8 +200,13 @@ WSWindowManager::WSWindowManager() m_highlight_window_border_color2 = Color::from_rgb(0xfabbbb); m_highlight_window_title_color = Color::White; - m_cursor_bitmap_inner = CharacterBitmap::create_from_ascii(cursor_bitmap_inner_ascii, 12, 17); - m_cursor_bitmap_outer = CharacterBitmap::create_from_ascii(cursor_bitmap_outer_ascii, 12, 17); + m_arrow_cursor = WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/arrow.png"), { 2, 2 }); + m_resize_horizontally_cursor = WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/resize-horizontal.png")); + m_resize_vertically_cursor = WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/resize-vertical.png")); + m_resize_diagonally_tlbr_cursor = WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/resize-diagonal-tlbr.png")); + m_resize_diagonally_bltr_cursor = WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/resize-diagonal-bltr.png")); + m_i_beam_cursor = WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/i-beam.png")); + m_disallowed_cursor = WSCursor::create(*GraphicsBitmap::load_from_file("/res/cursors/disallowed.png")); m_wallpaper_path = "/res/wallpapers/retro.rgb"; m_wallpaper = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, m_wallpaper_path, { 1024, 768 }); @@ -880,9 +886,8 @@ void WSWindowManager::process_mouse_event(WSMouseEvent& event, WSWindow*& event_ void WSWindowManager::compose() { auto dirty_rects = move(m_dirty_rects); - auto cursor_location = m_screen.cursor_location(); dirty_rects.add(m_last_cursor_rect); - dirty_rects.add({ cursor_location.x(), cursor_location.y(), (int)m_cursor_bitmap_inner->width(), (int)m_cursor_bitmap_inner->height() }); + dirty_rects.add(current_cursor_rect()); #ifdef DEBUG_COUNTERS dbgprintf("[WM] compose #%u (%u rects)\n", ++m_compose_count, dirty_rects.rects().size()); #endif @@ -988,11 +993,14 @@ void WSWindowManager::compose() flush(r); } +Rect WSWindowManager::current_cursor_rect() const +{ + return { m_screen.cursor_location().translated(-active_cursor().hotspot()), active_cursor().size() }; +} + void WSWindowManager::invalidate_cursor() { - auto cursor_location = m_screen.cursor_location(); - Rect cursor_rect { cursor_location.x(), cursor_location.y(), (int)m_cursor_bitmap_inner->width(), (int)m_cursor_bitmap_inner->height() }; - invalidate(cursor_rect); + invalidate(current_cursor_rect()); } Rect WSWindowManager::menubar_rect() const @@ -1073,14 +1081,12 @@ void WSWindowManager::draw_window_switcher() void WSWindowManager::draw_cursor() { - auto cursor_location = m_screen.cursor_location(); - Rect cursor_rect { cursor_location.x(), cursor_location.y(), (int)m_cursor_bitmap_inner->width(), (int)m_cursor_bitmap_inner->height() }; + Rect cursor_rect = current_cursor_rect(); Color inner_color = Color::White; Color outer_color = Color::Black; if (m_screen.mouse_button_state() & (unsigned)MouseButton::Left) swap(inner_color, outer_color); - m_back_painter->draw_bitmap(cursor_location, *m_cursor_bitmap_inner, inner_color); - m_back_painter->draw_bitmap(cursor_location, *m_cursor_bitmap_outer, outer_color); + m_back_painter->blit(cursor_rect.location(), active_cursor().bitmap(), active_cursor().rect()); m_last_cursor_rect = cursor_rect; } diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h index 62e5a2eb508..751ad94f442 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -13,6 +13,7 @@ #include #include #include +#include #include class WSAPIClientRequest; @@ -23,7 +24,6 @@ class WSClientWantsToPaintMessage; class WSWindow; class WSClientConnection; class WSWindowSwitcher; -class CharacterBitmap; class GraphicsBitmap; enum class ResizeDirection { None, Left, UpLeft, Up, UpRight, Right, DownRight, Down, DownLeft }; @@ -84,6 +84,9 @@ public: bool set_wallpaper(const String& path); String wallpaper_path() const { return m_wallpaper_path; } + const WSCursor& active_cursor() const { return *m_arrow_cursor; } + Rect current_cursor_rect() const; + private: void process_mouse_event(WSMouseEvent&, WSWindow*& event_window); bool process_ongoing_window_resize(WSMouseEvent&, WSWindow*& event_window); @@ -154,8 +157,13 @@ private: bool m_pending_compose_event { false }; - RetainPtr m_cursor_bitmap_inner; - RetainPtr m_cursor_bitmap_outer; + RetainPtr m_arrow_cursor; + RetainPtr m_resize_horizontally_cursor; + RetainPtr m_resize_vertically_cursor; + RetainPtr m_resize_diagonally_tlbr_cursor; + RetainPtr m_resize_diagonally_bltr_cursor; + RetainPtr m_i_beam_cursor; + RetainPtr m_disallowed_cursor; OwnPtr m_back_painter; OwnPtr m_front_painter; diff --git a/SharedGraphics/Point.h b/SharedGraphics/Point.h index 5a00512b7d3..87680ce22f1 100644 --- a/SharedGraphics/Point.h +++ b/SharedGraphics/Point.h @@ -28,6 +28,13 @@ public: move_by(delta.x(), delta.y()); } + Point translated(const Point& delta) const + { + Point point = *this; + point.move_by(delta); + return point; + } + Point translated(int dx, int dy) const { Point point = *this;