Menu popup: visibility, zoom sync, and tab fixes
Track menu popup visibility and propagate zoom level to the popup. Add menu_popup_visible_ flag, SendMenuPopupZoom(), and call it when creating/showing the popup and when adjusting zoom. Make CreateNewTab accept an optional URL and route popup/new-tab flows to it. Prevent per-tab child closes from triggering app shutdown by tracking closing_tab_browsers_ and adding ForgetClosingTabBrowser(). Treat MenuPopup role specially when enabling frame hit-testing. Platform: remove usage of ApplyRoundedBrowserRegion and switch menu popup sizing to use resized client_size helpers (consolidate calculations across Win/Mac/Linux). UI: update menu-popup CSS/JS (new styling, font, zoom formatting API via NebulaMenuPopup.setZoomLevel), wire settings to use nebulaNative.postMessage for new-tab, and remove the static menu-popup.html. Misc: small chrome CSS/JS tweaks and ensure chrome state includes zoomLevel.
This commit is contained in:
@@ -14,7 +14,6 @@ void ResizeBrowserWindow(NativeWindow browser_window, const Rect& rect);
|
||||
void SetBrowserVisible(NativeWindow browser_window, bool visible);
|
||||
void RaiseBrowserWindow(NativeWindow browser_window);
|
||||
Rect MenuPopupRect(NativeWindow parent, const BrowserLayout& layout);
|
||||
void ApplyRoundedBrowserRegion(NativeWindow browser_window, int corner_radius);
|
||||
std::string CacheBusterToken();
|
||||
void DestroyTopLevelWindow(NativeWindow window);
|
||||
int ScaleForParentWindow(NativeWindow parent, int value);
|
||||
|
||||
@@ -45,26 +45,21 @@ std::pair<int, int> ParentClientSize(NativeWindow parent) {
|
||||
}
|
||||
|
||||
Rect MenuPopupRect(NativeWindow parent, const BrowserLayout& layout) {
|
||||
const auto [client_right, client_bottom] = ParentClientSize(parent);
|
||||
const auto client_size = ParentClientSize(parent);
|
||||
const int width = 260;
|
||||
const int height = 258;
|
||||
const int margin = 12;
|
||||
const int overlap = 2;
|
||||
const int x = std::max(0, client_right - width - margin);
|
||||
const int x = std::max(0, client_size.first - width - margin);
|
||||
const int y = std::max(0, layout.chrome.y + layout.chrome.height - overlap);
|
||||
return {
|
||||
x,
|
||||
y,
|
||||
std::min(client_right, x + width) - x,
|
||||
std::min(client_bottom, y + height) - y,
|
||||
std::min(client_size.first, x + width) - x,
|
||||
std::min(client_size.second, y + height) - y,
|
||||
};
|
||||
}
|
||||
|
||||
void ApplyRoundedBrowserRegion(NativeWindow browser_window, int corner_radius) {
|
||||
UNREFERENCED_PARAMETER(browser_window);
|
||||
UNREFERENCED_PARAMETER(corner_radius);
|
||||
}
|
||||
|
||||
std::string CacheBusterToken() {
|
||||
return "0";
|
||||
}
|
||||
|
||||
@@ -43,26 +43,21 @@ std::pair<int, int> ParentClientSize(NativeWindow parent) {
|
||||
}
|
||||
|
||||
Rect MenuPopupRect(NativeWindow parent, const BrowserLayout& layout) {
|
||||
const auto [client_right, client_bottom] = ParentClientSize(parent);
|
||||
const auto client_size = ParentClientSize(parent);
|
||||
const int width = 260;
|
||||
const int height = 258;
|
||||
const int margin = 12;
|
||||
const int overlap = 2;
|
||||
const int x = std::max(0, client_right - width - margin);
|
||||
const int x = std::max(0, client_size.first - width - margin);
|
||||
const int y = std::max(0, layout.chrome.y + layout.chrome.height - overlap);
|
||||
return {
|
||||
x,
|
||||
y,
|
||||
std::min(client_right, x + width) - x,
|
||||
std::min(client_bottom, y + height) - y,
|
||||
std::min(client_size.first, x + width) - x,
|
||||
std::min(client_size.second, y + height) - y,
|
||||
};
|
||||
}
|
||||
|
||||
void ApplyRoundedBrowserRegion(NativeWindow browser_window, int corner_radius) {
|
||||
UNREFERENCED_PARAMETER(browser_window);
|
||||
UNREFERENCED_PARAMETER(corner_radius);
|
||||
}
|
||||
|
||||
std::string CacheBusterToken() {
|
||||
return "0";
|
||||
}
|
||||
|
||||
@@ -95,42 +95,22 @@ std::pair<int, int> ParentClientSize(NativeWindow parent) {
|
||||
}
|
||||
|
||||
Rect MenuPopupRect(NativeWindow parent, const BrowserLayout& layout) {
|
||||
const auto [client_right, client_bottom] = ParentClientSize(parent);
|
||||
|
||||
const auto client_size = ParentClientSize(parent);
|
||||
const int width = ScaleForParentWindow(parent, 260);
|
||||
const int height = ScaleForParentWindow(parent, 258);
|
||||
const int margin = ScaleForParentWindow(parent, 12);
|
||||
const int overlap = ScaleForParentWindow(parent, 2);
|
||||
|
||||
const int x = std::max(0, client_right - width - margin);
|
||||
const int x = std::max(0, client_size.first - width - margin);
|
||||
const int y = std::max(0, layout.chrome.y + layout.chrome.height - overlap);
|
||||
return {
|
||||
x,
|
||||
y,
|
||||
std::min(client_right, x + width) - x,
|
||||
std::min(client_bottom, y + height) - y,
|
||||
std::min(client_size.first, x + width) - x,
|
||||
std::min(client_size.second, y + height) - y,
|
||||
};
|
||||
}
|
||||
|
||||
void ApplyRoundedBrowserRegion(NativeWindow browser_window, int corner_radius) {
|
||||
const HWND hwnd = AsHwnd(browser_window);
|
||||
if (!hwnd) {
|
||||
return;
|
||||
}
|
||||
|
||||
RECT rect = {};
|
||||
if (!GetClientRect(hwnd, &rect)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int width = std::max<LONG>(1, rect.right - rect.left);
|
||||
const int height = std::max<LONG>(1, rect.bottom - rect.top);
|
||||
HRGN region = CreateRoundRectRgn(0, 0, width + 1, height + 1, corner_radius, corner_radius);
|
||||
if (region && !SetWindowRgn(hwnd, region, TRUE)) {
|
||||
DeleteObject(region);
|
||||
}
|
||||
}
|
||||
|
||||
std::string CacheBusterToken() {
|
||||
return std::to_string(GetTickCount64());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user