From f45f83f0f5798f430735b17476c5ef671f6610f7 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 14 Sep 2023 08:55:11 +0100 Subject: [PATCH] Improve edge cases around macOS drag handles (#1219) * Allow dragging macOS window by area around mx_UserMenu Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix context menus overlapping drag regions being unclickable Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix captcha overlapping drag region being unclickable Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Expand drag handle on top left user menu surround Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/macos-titlebar.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/macos-titlebar.ts b/src/macos-titlebar.ts index 830953f..65f17d2 100644 --- a/src/macos-titlebar.ts +++ b/src/macos-titlebar.ts @@ -25,7 +25,17 @@ export function setupMacosTitleBar(window: BrowserWindow): void { cssKey = await window.webContents.insertCSS(` /* Create margin of space for the traffic light buttons */ .mx_UserMenu { - margin-top: 32px !important; + /* We zero the margin and use padding as we want to use it as a drag handle */ + margin-top: 0 !important; + margin-left: 0 !important; + padding-top: 32px !important; + padding-left: 20px !important; + -webkit-app-region: drag; + -webkit-user-select: none; + } + /* Exclude the button from being a drag handle and not working */ + .mx_UserMenu > * { + -webkit-app-region: no-drag; } /* Maintain alignment of the toggle space panel button */ .mx_SpacePanel_toggleCollapse { @@ -112,6 +122,14 @@ export function setupMacosTitleBar(window: BrowserWindow): void { .mx_RoomPreviewCard { -webkit-app-region: no-drag; } + /* Exclude context menus and their backgrounds */ + .mx_ContextualMenu, .mx_ContextualMenu_background { + -webkit-app-region: no-drag; + } + /* Exclude iframes, such as recaptcha */ + iframe { + -webkit-app-region: no-drag; + } `); }