From f052a66c5dd4e16160449263f05b4137e11b76f3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 2 May 2021 14:01:04 +0200 Subject: [PATCH] WindowServer+Base: Show alternate close button for "modified" windows Windows that are marked as modified will now have another (themable) close button. This gives an additional visual clue that some action will be required by the user before the window gets closed. The default window-close-modified icon is an "X" with "..." underneath, building on the established use of "..." in menus to signify that additional user input will be required before an action is completed. --- Base/res/icons/16x16/window-close-modified-2x.png | Bin 0 -> 167 bytes Base/res/icons/16x16/window-close-modified.png | Bin 0 -> 111 bytes .../themes/Coffee/16x16/window-close-modified.png | Bin 0 -> 831 bytes .../Redmond/16x16/window-close-modified.png | Bin 0 -> 99 bytes .../Sunshine/16x16/window-close-modified.png | Bin 0 -> 253 bytes Userland/Services/WindowServer/Window.cpp | 1 + Userland/Services/WindowServer/Window.h | 2 +- Userland/Services/WindowServer/WindowFrame.cpp | 12 +++++++++++- 8 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 Base/res/icons/16x16/window-close-modified-2x.png create mode 100644 Base/res/icons/16x16/window-close-modified.png create mode 100644 Base/res/icons/themes/Coffee/16x16/window-close-modified.png create mode 100644 Base/res/icons/themes/Redmond/16x16/window-close-modified.png create mode 100644 Base/res/icons/themes/Sunshine/16x16/window-close-modified.png diff --git a/Base/res/icons/16x16/window-close-modified-2x.png b/Base/res/icons/16x16/window-close-modified-2x.png new file mode 100644 index 0000000000000000000000000000000000000000..f714d1a2e63d85f30077bdf6e1b91b87a5586b7e GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJJWm(Lkch)?r#SL4C~`0#{r`Vw z_4fs>46|~cd$34H%Q$mq+oB#j- literal 0 HcmV?d00001 diff --git a/Base/res/icons/16x16/window-close-modified.png b/Base/res/icons/16x16/window-close-modified.png new file mode 100644 index 0000000000000000000000000000000000000000..95657d3e4c462c662fee201ec2edd51d611b3378 GIT binary patch literal 111 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`W}YsNAr_~T6C_x79H`egcC?*Y zOo`_Zw}j_~o={!krFE$)7hm=)+0`(y!8}vGb;pe>+(&@=CS>ul9Gaaa4>W;M1& literal 0 HcmV?d00001 diff --git a/Base/res/icons/themes/Coffee/16x16/window-close-modified.png b/Base/res/icons/themes/Coffee/16x16/window-close-modified.png new file mode 100644 index 0000000000000000000000000000000000000000..aa16575f3566c540a3499df6d67ac6caf11b943a GIT binary patch literal 831 zcmV-F1Hk-=P)b4C|XI8hZ_} zo5YA8Q@rI71Y-{N282U{F@hMySV2TFMiEuc!x8)S*YtW9tdu>vz2At<7ZP~0ahiui zqR3#3#as#23St#w1S^7ALBuj1U2*ihho5p;EcwJ1OCB#d9?(?w5(X z4(^o0=MO79{`wB8f+B=rMC;^?)p8a$Ur17W79jTK8T{RiD6ji`cyAd6);4?&4+f}O zLx5(*qQXszDL@{R`6R1TM%# z*`kvntc{~GDHK!%D+X)Lq}SjeC=fdfBK$cAD_4lV!Os0Pwzf0WYdz|<*KBQP`Q$+r zRf83SiXoMmA_y*UJDre1F-f;Oyjh`8NOI8V@xyn!pvtEYw<#>l-jGEN#bTaztB>>L z7vJb+HOH^N9CL9#=KrCpD2j?fRS-3JUYvK|udrKtLG1XiSM>WKt7|@vV=!hkLG%W8 zgtZaIjjFc`EA*+zwLk$1`002ov JPDHLkV1frqdIJCe literal 0 HcmV?d00001 diff --git a/Base/res/icons/themes/Redmond/16x16/window-close-modified.png b/Base/res/icons/themes/Redmond/16x16/window-close-modified.png new file mode 100644 index 0000000000000000000000000000000000000000..7eaaf706770e890d5e42bf90575a17d57f17a247 GIT binary patch literal 99 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`TAnVBAr_~T6C_wonEx-F5mC5^ w=isWD6FHnc0{thIXS`=xbf{t3MgyScIqt$A+oLMffw~wxUHx3vIVCg!0KSAA(*OVf literal 0 HcmV?d00001 diff --git a/Base/res/icons/themes/Sunshine/16x16/window-close-modified.png b/Base/res/icons/themes/Sunshine/16x16/window-close-modified.png new file mode 100644 index 0000000000000000000000000000000000000000..4e79eba6d36c402d86801b4b4b31c3a51fbd91b4 GIT binary patch literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPVk1Qjner#}U08psQ)5S5w;&gI?1Z&R=rt){TfBBPF zYj_$bO?DPbKa}=rsrGjXz1W@YNjK(J`~N?DBw5(#|Kk$IO-XD(U@NP-V<8U^yuPlR z9I+?CN;!`C0&gQ@$=M2C2XmI$X}5MV+)V>2Y&)<(V@=zJ2@l@*0pI>7&JbtNF3OrH+a_xQbQOcAtDnm{r-UW|L%mbq literal 0 HcmV?d00001 diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index 1d7a6687419..8ffc784d5e9 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -998,6 +998,7 @@ void Window::set_modified(bool modified) return; m_modified = modified; + frame().set_button_icons(); frame().invalidate_titlebar(); } diff --git a/Userland/Services/WindowServer/Window.h b/Userland/Services/WindowServer/Window.h index c2db7b8bb3b..a1785bf6482 100644 --- a/Userland/Services/WindowServer/Window.h +++ b/Userland/Services/WindowServer/Window.h @@ -371,6 +371,7 @@ private: bool m_invalidated_all { true }; bool m_invalidated_frame { true }; bool m_hit_testing_enabled { true }; + bool m_modified { false }; WindowTileType m_tiled { WindowTileType::None }; Gfx::IntRect m_untiled_rect; bool m_occluded { false }; @@ -400,7 +401,6 @@ private: int m_minimize_animation_step { -1 }; Optional m_progress; bool m_should_show_menubar { true }; - bool m_modified { false }; }; } diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp index 21e4136b1fa..167890fef20 100644 --- a/Userland/Services/WindowServer/WindowFrame.cpp +++ b/Userland/Services/WindowServer/WindowFrame.cpp @@ -38,6 +38,7 @@ static Gfx::Bitmap* s_minimize_icon; static Gfx::Bitmap* s_maximize_icon; static Gfx::Bitmap* s_restore_icon; static Gfx::Bitmap* s_close_icon; +static Gfx::Bitmap* s_close_modified_icon; static String s_last_title_button_icons_path; static int s_last_title_button_icons_scale; @@ -102,7 +103,7 @@ void WindowFrame::set_button_icons() if (m_window.is_frameless()) return; - m_close_button->set_icon(*s_close_icon); + m_close_button->set_icon(m_window.is_modified() ? *s_close_modified_icon : *s_close_icon); if (m_window.is_minimizable()) m_minimize_button->set_icon(*s_minimize_icon); if (m_window.is_resizable()) @@ -151,6 +152,15 @@ void WindowFrame::reload_config() s_close_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window-close.png", icons_scale).leak_ref(); full_path.clear(); } + if (!s_close_modified_icon || s_last_title_button_icons_path != icons_path || s_last_title_button_icons_scale != icons_scale) { + full_path.append(icons_path); + full_path.append("window-close-modified.png"); + if (s_close_modified_icon) + s_close_modified_icon->unref(); + if (!(s_close_modified_icon = Gfx::Bitmap::load_from_file(full_path.to_string(), icons_scale).leak_ref())) + s_close_modified_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/window-close-modified.png", icons_scale).leak_ref(); + full_path.clear(); + } s_last_title_button_icons_path = icons_path; s_last_title_button_icons_scale = icons_scale;