From dc659e2fa47d20bc374ecf98c186d9713a0b1289 Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sat, 23 Mar 2013 21:07:58 +0430 Subject: [PATCH 1/2] [Windows] Fixed issues about window positioning -Fixed #821 and also position of new window --- src/lib/app/mainapplication.cpp | 4 ++-- src/lib/app/qupzilla.cpp | 34 +++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 0e2826551..b1866afb1 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -266,7 +266,7 @@ MainApplication::MainApplication(int &argc, char** argv) translateApp(); QupZilla* qupzilla = new QupZilla(Qz::BW_FirstAppWindow, startUrl); - m_mainWindows.append(qupzilla); + m_mainWindows.prepend(qupzilla); connect(qupzilla, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(sendMessages(Qz::AppMessageType,bool))); connect(qupzilla, SIGNAL(startingCompleted()), this, SLOT(restoreCursor())); @@ -636,7 +636,7 @@ QupZilla* MainApplication::makeNewWindow(Qz::BrowserWindow type, const QUrl &sta } QupZilla* newWindow = new QupZilla(type, startUrl); - m_mainWindows.append(newWindow); + m_mainWindows.prepend(newWindow); return newWindow; } diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index e66743f77..1d2ccd95c 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -84,6 +84,7 @@ #include #include #include +#include #if QT_VERSION < 0x050000 #include "qwebkitversion.h" @@ -266,17 +267,30 @@ void QupZilla::setupUi() setWindowState(Qt::WindowMaximized); } else { - if (!restoreGeometry(settings.value("WindowGeometry").toByteArray())) { - setGeometry(QRect(20, 20, 800, 550)); + // Let the WM decides where to put new browser window + if (m_windowType == Qz::BW_NewWindow && mApp->getWindow()) { +#ifdef Q_WS_WIN + // Windows WM places every new window in the middle of screen .. for some reason + QPoint p = mApp->getWindow()->geometry().topLeft(); + p.setX(p.x() + 30); + p.setY(p.y() + 30); + + if (!mApp->desktop()->availableGeometry(this).contains(p)) { + p.setX(mApp->desktop()->availableGeometry(this).x() + 30); + p.setY(mApp->desktop()->availableGeometry(this).y() + 30); + } + setGeometry(QRect(p, mApp->getWindow()->size())); +#else + resize(mApp->getWindow()->size()); +#endif } - - if (m_windowType == Qz::BW_NewWindow) { - // Moving window +40 x,y to be visible that this is new window - QPoint p = pos(); - p.setX(p.x() + 40); - p.setY(p.y() + 40); - - move(p); + else if (!restoreGeometry(settings.value("WindowGeometry").toByteArray())) { +#ifdef Q_WS_WIN + setGeometry(QRect(mApp->desktop()->availableGeometry(this).x() + 30, + mApp->desktop()->availableGeometry(this).y() + 30, 800, 550)); +#else + resize(800, 550); +#endif } } From 334f90b12b367a2ec12f2d61cdb639bdb02a72dd Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sun, 24 Mar 2013 00:09:55 +0430 Subject: [PATCH 2/2] [Windows] Fixed first moment black background of new tab. --- src/lib/app/qupzilla.cpp | 20 +++++++++++++++----- src/lib/app/qupzilla.h | 2 ++ src/lib/webview/tabwidget.cpp | 10 ++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 1d2ccd95c..43577e5df 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -836,8 +836,7 @@ void QupZilla::loadSettings() m_usingTransparentBackground = true; QtWin::enableBlurBehindWindow(m_tabWidget->getTabBar(), true); - applyBlurToMainWindow(); - update(); + QtWin::extendFrameIntoClientArea(this); //install event filter menuBar()->installEventFilter(this); @@ -909,6 +908,11 @@ void QupZilla::popupToolbarsMenu(const QPoint &pos) aboutToHideViewMenu(); } +bool QupZilla::isTransparentBackgroundAllowed() +{ + return m_usingTransparentBackground && !isFullScreen(); +} + void QupZilla::setWindowTitle(const QString &t) { QString title = t; @@ -1561,7 +1565,6 @@ SideBar* QupZilla::addSideBar() #ifdef Q_OS_WIN if (QtWin::isCompositionEnabled()) { - applyBlurToMainWindow(); m_sideBar.data()->installEventFilter(this); } #endif @@ -1657,6 +1660,13 @@ void QupZilla::triggerTabsOnTop(bool enable) Settings settings; settings.setValue("Browser-Tabs-Settings/TabsOnTop", enable); qzSettings->tabsOnTop = enable; + +#ifdef Q_OS_WIN + // workaround for changing TabsOnTop state when sidebar is visible + // TODO: we need a solution that changing TabsOnTop state + // doesn't call applyBlurToMainWindow() from eventFilter() + QTimer::singleShot(0, this, SLOT(applyBlurToMainWindow())); +#endif } void QupZilla::refreshHistory() @@ -2459,11 +2469,11 @@ void QupZilla::paintEvent(QPaintEvent* event) void QupZilla::applyBlurToMainWindow(bool force) { - if (isClosing()) { + if (isClosing() || m_isStarting) { return; } - if (!force && (m_actionShowFullScreen->isChecked() || !m_usingTransparentBackground)) { + if (!force && !isTransparentBackgroundAllowed()) { return; } int topMargin = 0; diff --git a/src/lib/app/qupzilla.h b/src/lib/app/qupzilla.h index 35bb2ba02..46acea8cf 100644 --- a/src/lib/app/qupzilla.h +++ b/src/lib/app/qupzilla.h @@ -111,6 +111,8 @@ public: bool isClosing() { return m_isClosing; } QUrl homepageUrl() { return m_homepage; } + bool isTransparentBackgroundAllowed(); + signals: void startingCompleted(); void message(Qz::AppMessageType mes, bool state); diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index b16ad57f0..e7d5024ef 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -31,7 +31,9 @@ #include "websearchbar.h" #include "settings.h" #include "qzsettings.h" +#include "qtwin.h" +#include #include #include #include @@ -282,6 +284,11 @@ int TabWidget::addView(const QUrl &url, const QString &title, const Qz::NewTabPo int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position) { +#ifdef Q_OS_WIN + if (p_QupZilla->isTransparentBackgroundAllowed()) { + QtWin::extendFrameIntoClientArea(p_QupZilla); + } +#endif QUrl url = req.url(); m_lastTabIndex = currentIndex(); @@ -358,6 +365,9 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT } } +#ifdef Q_OS_WIN + QTimer::singleShot(0, p_QupZilla, SLOT(applyBlurToMainWindow())); +#endif return index; }