2023-07-28 13:51:33 +02:00
|
|
|
/*
|
|
|
|
Copyright 2023 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { BrowserWindow } from "electron";
|
|
|
|
|
|
|
|
export function setupMacosTitleBar(window: BrowserWindow): void {
|
|
|
|
if (process.platform !== "darwin") return;
|
|
|
|
|
2023-07-31 10:33:38 +02:00
|
|
|
let cssKey: string | undefined;
|
2023-07-28 13:51:33 +02:00
|
|
|
|
2023-07-31 10:33:38 +02:00
|
|
|
async function applyStyling(): Promise<void> {
|
|
|
|
cssKey = await window.webContents.insertCSS(`
|
2023-07-28 13:51:33 +02:00
|
|
|
/* Create margin of space for the traffic light buttons */
|
|
|
|
.mx_UserMenu {
|
2023-09-14 09:55:11 +02:00
|
|
|
/* 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;
|
2023-07-28 13:51:33 +02:00
|
|
|
}
|
|
|
|
/* Maintain alignment of the toggle space panel button */
|
|
|
|
.mx_SpacePanel_toggleCollapse {
|
|
|
|
/* 19px original top value, 32px margin-top above, 12px original margin-top value */
|
|
|
|
top: calc(19px + 32px - 12px) !important;
|
|
|
|
}
|
2023-08-03 15:38:00 +02:00
|
|
|
/* Prevent the media lightbox sender info from clipping into the traffic light buttons */
|
|
|
|
.mx_ImageView_info_wrapper {
|
|
|
|
margin-top: 32px;
|
|
|
|
}
|
2023-07-31 10:33:38 +02:00
|
|
|
|
2023-07-28 13:51:33 +02:00
|
|
|
/* Mark the splash screen as a drag handle */
|
|
|
|
.mx_MatrixChat_splash {
|
|
|
|
-webkit-app-region: drag;
|
|
|
|
}
|
|
|
|
/* Exclude the splash buttons from being drag handles */
|
|
|
|
.mx_MatrixChat_splashButtons {
|
|
|
|
-webkit-app-region: no-drag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the background as a drag handle */
|
|
|
|
.mx_AuthPage {
|
|
|
|
-webkit-app-region: drag;
|
|
|
|
}
|
|
|
|
/* Exclude the main content elements from being drag handles */
|
|
|
|
.mx_AuthPage .mx_AuthPage_modalBlur,
|
|
|
|
.mx_AuthPage .mx_AuthFooter > * {
|
|
|
|
-webkit-app-region: no-drag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the header as a drag handle */
|
|
|
|
.mx_LeftPanel .mx_LeftPanel_filterContainer {
|
|
|
|
-webkit-app-region: drag;
|
|
|
|
}
|
|
|
|
/* Exclude header interactive elements from being drag handles */
|
|
|
|
.mx_LeftPanel .mx_LeftPanel_filterContainer .mx_AccessibleButton {
|
|
|
|
-webkit-app-region: no-drag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the home page background as a drag handle */
|
|
|
|
.mx_HomePage {
|
|
|
|
-webkit-app-region: drag;
|
|
|
|
}
|
|
|
|
/* Exclude interactive elements from being drag handles */
|
|
|
|
.mx_HomePage .mx_HomePage_body,
|
|
|
|
.mx_HomePage .mx_HomePage_default_wrapper > * {
|
|
|
|
-webkit-app-region: no-drag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mark the header as a drag handle */
|
2023-08-02 09:05:13 +02:00
|
|
|
.mx_LegacyRoomHeader,
|
2023-07-28 13:51:33 +02:00
|
|
|
.mx_RoomHeader {
|
|
|
|
-webkit-app-region: drag;
|
|
|
|
-webkit-user-select: none;
|
|
|
|
}
|
2023-08-17 06:20:58 +02:00
|
|
|
.mx_ImageView_panel {
|
|
|
|
-webkit-app-region: drag;
|
|
|
|
}
|
2023-07-28 13:51:33 +02:00
|
|
|
/* Exclude header interactive elements from being drag handles */
|
2023-08-31 22:14:38 +02:00
|
|
|
.mx_RoomHeader .mx_BaseAvatar,
|
|
|
|
.mx_RoomHeader_heading,
|
|
|
|
.mx_RoomHeader button,
|
|
|
|
.mx_RoomHeader .mx_FacePile,
|
2023-08-02 09:05:13 +02:00
|
|
|
.mx_LegacyRoomHeader .mx_LegacyRoomHeader_avatar,
|
|
|
|
.mx_LegacyRoomHeader .mx_E2EIcon,
|
|
|
|
.mx_LegacyRoomHeader .mx_RoomTopic,
|
2023-08-17 06:20:58 +02:00
|
|
|
.mx_LegacyRoomHeader .mx_AccessibleButton,
|
|
|
|
.mx_ImageView_panel > .mx_ImageView_info_wrapper,
|
|
|
|
.mx_ImageView_panel > .mx_ImageView_title,
|
|
|
|
.mx_ImageView_panel > .mx_ImageView_toolbar > * {
|
2023-07-28 13:51:33 +02:00
|
|
|
-webkit-app-region: no-drag;
|
|
|
|
}
|
|
|
|
|
2023-08-17 06:20:58 +02:00
|
|
|
/* Mark the background as a drag handle only if no modal is open */
|
|
|
|
.mx_MatrixChat_wrapper[aria-hidden="false"] .mx_RoomView_wrapper {
|
2023-07-28 13:51:33 +02:00
|
|
|
-webkit-app-region: drag;
|
|
|
|
}
|
|
|
|
/* Exclude content elements from being drag handles */
|
|
|
|
.mx_SpaceRoomView_landing > *,
|
|
|
|
.mx_RoomPreviewBar,
|
|
|
|
.mx_RoomView_body,
|
2023-07-29 07:47:10 +02:00
|
|
|
.mx_AutoHideScrollbar,
|
|
|
|
.mx_RightPanel_ResizeWrapper,
|
2023-07-28 13:51:33 +02:00
|
|
|
.mx_RoomPreviewCard {
|
|
|
|
-webkit-app-region: no-drag;
|
|
|
|
}
|
2023-09-14 09:55:11 +02:00
|
|
|
/* 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;
|
|
|
|
}
|
2023-07-28 13:51:33 +02:00
|
|
|
`);
|
2023-07-31 10:33:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
window.on("enter-full-screen", () => {
|
|
|
|
if (cssKey !== undefined) {
|
|
|
|
window.webContents.removeInsertedCSS(cssKey);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
window.on("leave-full-screen", () => {
|
|
|
|
applyStyling();
|
|
|
|
});
|
|
|
|
window.webContents.on("did-finish-load", () => {
|
|
|
|
if (!window.isFullScreen()) {
|
|
|
|
applyStyling();
|
|
|
|
}
|
2023-07-28 13:51:33 +02:00
|
|
|
});
|
|
|
|
}
|