UI/Qt: Don't save size and location of popup windows on exit

This commit is contained in:
Tim Ledbetter 2024-07-27 11:38:39 +01:00 committed by Tim Ledbetter
parent 9624e0d2a2
commit 2d95cc01dc
Notes: github-actions[bot] 2024-07-27 23:55:43 +00:00
4 changed files with 18 additions and 9 deletions

View file

@ -96,9 +96,9 @@ void Application::close_task_manager_window()
}
}
BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab, Optional<u64> page_index)
BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, BrowserWindow::IsPopupWindow is_popup_window, Tab* parent_tab, Optional<u64> page_index)
{
auto* window = new BrowserWindow(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups, parent_tab, move(page_index));
auto* window = new BrowserWindow(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups, is_popup_window, parent_tab, move(page_index));
set_active_window(*window);
window->show();
if (initial_urls.is_empty()) {

View file

@ -31,7 +31,7 @@ public:
NonnullRefPtr<ImageDecoderClient::Client> image_decoder_client() const { return *m_image_decoder_client; }
ErrorOr<void> initialize_image_decoder();
BrowserWindow& new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
BrowserWindow& new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, BrowserWindow::IsPopupWindow is_popup_window = BrowserWindow::IsPopupWindow::No, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
void show_task_manager_window(WebContentOptions const&);
void close_task_manager_window();

View file

@ -70,13 +70,14 @@ public:
}
};
BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab, Optional<u64> page_index)
BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, IsPopupWindow is_popup_window, Tab* parent_tab, Optional<u64> page_index)
: m_tabs_container(new TabWidget(this))
, m_new_tab_button_toolbar(new QToolBar("New Tab", m_tabs_container))
, m_cookie_jar(cookie_jar)
, m_web_content_options(web_content_options)
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
, m_allow_popups(allow_popups)
, m_is_popup_window(is_popup_window)
{
setWindowIcon(app_icon());
@ -786,7 +787,7 @@ void BrowserWindow::initialize_tab(Tab* tab)
tab->view().on_new_web_view = [this, tab](auto activate_tab, Web::HTML::WebViewHints hints, Optional<u64> page_index) {
if (hints.popup) {
auto& window = static_cast<Ladybird::Application*>(QApplication::instance())->new_window({}, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, m_allow_popups, tab, AK::move(page_index));
auto& window = static_cast<Ladybird::Application*>(QApplication::instance())->new_window({}, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, m_allow_popups, IsPopupWindow::Yes, tab, AK::move(page_index));
window.set_window_rect(hints.screen_x, hints.screen_y, hints.width, hints.height);
return window.current_tab()->view().handle();
}
@ -1238,9 +1239,11 @@ bool BrowserWindow::eventFilter(QObject* obj, QEvent* event)
void BrowserWindow::closeEvent(QCloseEvent* event)
{
Settings::the()->set_last_position(pos());
Settings::the()->set_last_size(size());
Settings::the()->set_is_maximized(isMaximized());
if (m_is_popup_window == IsPopupWindow::No) {
Settings::the()->set_last_position(pos());
Settings::the()->set_last_size(size());
Settings::the()->set_is_maximized(isMaximized());
}
QObject::deleteLater();

View file

@ -31,7 +31,12 @@ class BrowserWindow : public QMainWindow {
Q_OBJECT
public:
BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
enum class IsPopupWindow {
No,
Yes,
};
BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, IsPopupWindow is_popup_window = IsPopupWindow::No, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
WebContentView& view() const { return m_current_tab->view(); }
@ -216,6 +221,7 @@ private:
StringView m_webdriver_content_ipc_path;
bool m_allow_popups { false };
IsPopupWindow m_is_popup_window { IsPopupWindow::No };
};
}