mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
X11: Restore windows on correct virtual desktops
- this will not be used for first application window, to prevent starting application and no window being opened on current desktop = applies only for other restored windows (2nd, 3rd, ...)
This commit is contained in:
parent
11244acc6e
commit
55845ab4df
|
@ -19,6 +19,7 @@ Version 1.3.5
|
|||
* new option to show loading progress in address bar
|
||||
* new option to hide close button on tabs
|
||||
* new option to start new instance with --no-remote option
|
||||
* X11: restore windows on correct virtual desktops
|
||||
* fixed visibility of navigation bar in fullscreen
|
||||
* fixed bad position of add tab button when there is a lot of tabs
|
||||
* fixed gui with RTL languages
|
||||
|
|
|
@ -233,7 +233,6 @@ MainApplication::MainApplication(int &argc, char** argv)
|
|||
translateApp();
|
||||
|
||||
QupZilla* qupzilla = new QupZilla(Qz::BW_FirstAppWindow, startUrl);
|
||||
qupzilla->show();
|
||||
m_mainWindows.append(qupzilla);
|
||||
|
||||
connect(qupzilla, SIGNAL(message(Qz::AppMessageType, bool)), this, SLOT(sendMessages(Qz::AppMessageType, bool)));
|
||||
|
@ -542,7 +541,6 @@ QupZilla* MainApplication::makeNewWindow(Qz::BrowserWindow type, const QUrl &sta
|
|||
|
||||
QupZilla* newWindow = new QupZilla(type, startUrl);
|
||||
m_mainWindows.append(newWindow);
|
||||
newWindow->show();
|
||||
|
||||
return newWindow;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,12 @@
|
|||
#include <QWebHistory>
|
||||
#include <QMessageBox>
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <QX11Info>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#endif
|
||||
|
||||
const QString QupZilla::VERSION = "1.3.1";
|
||||
const QString QupZilla::BUILDTIME = __DATE__" "__TIME__;
|
||||
const QString QupZilla::AUTHOR = "David Rosca";
|
||||
|
@ -181,6 +187,8 @@ void QupZilla::postLaunch()
|
|||
break;
|
||||
}
|
||||
|
||||
show();
|
||||
|
||||
if (!m_startingUrl.isEmpty()) {
|
||||
startUrl = QUrl::fromUserInput(m_startingUrl.toString());
|
||||
addTab = true;
|
||||
|
@ -1382,7 +1390,7 @@ void QupZilla::addDeleteOnCloseWidget(QWidget* widget)
|
|||
|
||||
void QupZilla::restoreWindowState(const RestoreManager::WindowData &d)
|
||||
{
|
||||
QMainWindow::restoreState(d.windowState);
|
||||
restoreState(d.windowState);
|
||||
m_tabWidget->restoreState(d.tabsState, d.currentTab);
|
||||
}
|
||||
|
||||
|
@ -1827,10 +1835,91 @@ bool QupZilla::quitApp()
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
QTimer::singleShot(0, mApp, SLOT(quitApplication()));
|
||||
mApp->quitApplication();
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray QupZilla::saveState(int version) const
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
QByteArray data;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
|
||||
stream << QMainWindow::saveState(version);
|
||||
stream << getCurrentVirtualDesktop();
|
||||
|
||||
return data;
|
||||
#else
|
||||
return QMainWindow::saveState(version);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool QupZilla::restoreState(const QByteArray &state, int version)
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
QByteArray windowState;
|
||||
int desktopId = -1;
|
||||
|
||||
QDataStream stream(state);
|
||||
stream >> windowState;
|
||||
stream >> desktopId;
|
||||
|
||||
moveToVirtualDesktop(desktopId);
|
||||
|
||||
return QMainWindow::restoreState(windowState, version);
|
||||
#else
|
||||
return QMainWindow::saveState(version);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
int QupZilla::getCurrentVirtualDesktop() const
|
||||
{
|
||||
Display* display = QX11Info::display();
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems;
|
||||
unsigned long bytes;
|
||||
unsigned long* data;
|
||||
|
||||
Atom net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
||||
if (net_wm_desktop == None) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int status = XGetWindowProperty(display, winId(), net_wm_desktop, 0, 1,
|
||||
False, XA_CARDINAL, &actual_type, &actual_format,
|
||||
&nitems, &bytes, (unsigned char**) &data);
|
||||
|
||||
if (status != Success || data == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int desktop = *data;
|
||||
XFree(data);
|
||||
|
||||
return desktop;
|
||||
}
|
||||
|
||||
void QupZilla::moveToVirtualDesktop(int desktopId)
|
||||
{
|
||||
// Don't move when window is already visible or it is first app window
|
||||
if (desktopId < 0 || isVisible() || m_startBehaviour == Qz::BW_FirstAppWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
Display* display = QX11Info::display();
|
||||
|
||||
Atom net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False);
|
||||
if (net_wm_desktop == None) {
|
||||
return;
|
||||
}
|
||||
|
||||
XChangeProperty(display, winId(), net_wm_desktop, XA_CARDINAL,
|
||||
32, PropModeReplace, (unsigned char*) &desktopId, 1L);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool QupZilla::winEvent(MSG* message, long* result)
|
||||
{
|
||||
|
|
|
@ -81,9 +81,13 @@ public:
|
|||
SideBar* addSideBar();
|
||||
virtual QMenuBar* menuBar() const;
|
||||
|
||||
QByteArray saveState(int version = 0) const;
|
||||
bool restoreState(const QByteArray &state, int version = 0);
|
||||
|
||||
TabbedWebView* weView() const;
|
||||
TabbedWebView* weView(int index) const;
|
||||
LocationBar* locationBar() const;
|
||||
|
||||
inline TabWidget* tabWidget() { return m_tabWidget; }
|
||||
inline BookmarksToolbar* bookmarksToolbar() { return m_bookmarksToolbar; }
|
||||
inline StatusBarMessage* statusBarMessage() { return m_statusBarMessage; }
|
||||
|
@ -201,11 +205,17 @@ private:
|
|||
void setupMenu();
|
||||
|
||||
void disconnectObjects();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool winEvent(MSG* message, long* result);
|
||||
bool eventFilter(QObject* object, QEvent* event);
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
int getCurrentVirtualDesktop() const;
|
||||
void moveToVirtualDesktop(int desktopId);
|
||||
#endif
|
||||
|
||||
bool m_historyMenuChanged;
|
||||
bool m_bookmarksMenuChanged;
|
||||
bool m_isClosing;
|
||||
|
|
Loading…
Reference in New Issue
Block a user