Commit 4374ed31 authored by Aleksi Suomalainen's avatar Aleksi Suomalainen

[desktop] Bring the open application to front if there is a window id for it.

parent fcf6bafe
...@@ -4,11 +4,26 @@ GlacierWindowModel::GlacierWindowModel(): WindowModel() ...@@ -4,11 +4,26 @@ GlacierWindowModel::GlacierWindowModel(): WindowModel()
{ {
} }
GlacierWindowModel::~GlacierWindowModel() { int GlacierWindowModel::getWindowIdForTitle(QString title)
{
return m_titles.value(title,0);
} }
bool GlacierWindowModel::approveWindow(LipstickCompositorWindow *window) bool GlacierWindowModel::approveWindow(LipstickCompositorWindow *window)
{ {
return window->isInProcess() == false && window->category() != QLatin1String("overlay") && window->category() != QLatin1String("cover"); bool accepted = window->isInProcess() == false && window->category() != QLatin1String("overlay") && window->category() != QLatin1String("cover");
if (accepted) {
m_titles.insert(window->title(), window->windowId());
}
return accepted;
} }
void GlacierWindowModel::removeWindowForTitle(QString title)
{
qDebug() << "Removing window: " + title;
m_titles.remove(title);
}
#include "moc_glacierwindowmodel.cpp"
...@@ -7,12 +7,16 @@ class LipstickCompositorWindow; ...@@ -7,12 +7,16 @@ class LipstickCompositorWindow;
class QWaylandSurfaceItem; class QWaylandSurfaceItem;
class GlacierWindowModel : public WindowModel class Q_DECL_EXPORT GlacierWindowModel : public WindowModel
{ {
Q_OBJECT
public: public:
explicit GlacierWindowModel(); explicit GlacierWindowModel();
~GlacierWindowModel();
bool approveWindow(LipstickCompositorWindow *window); bool approveWindow(LipstickCompositorWindow *window);
Q_INVOKABLE int getWindowIdForTitle(QString title);
Q_INVOKABLE void removeWindowForTitle(QString title);
private:
QHash<QString, int> m_titles;
}; };
#endif // GLACIERWINDOWMODEL_H #endif // GLACIERWINDOWMODEL_H
...@@ -108,7 +108,12 @@ Item { ...@@ -108,7 +108,12 @@ Item {
onClicked: { onClicked: {
// TODO: disallow if close mode enabled // TODO: disallow if close mode enabled
if (model.object.type !== LauncherModel.Folder) { if (model.object.type !== LauncherModel.Folder) {
model.object.launchApplication() var winId = switcher.switchModel.getWindowIdForTitle(model.object.title)
console.log("Window id found: " + winId)
if (winId == 0)
model.object.launchApplication()
else
Lipstick.compositor.windowToFront(winId)
} else { } else {
if (!folderLoader.visible) { if (!folderLoader.visible) {
folderLoader.visible = true folderLoader.visible = true
......
...@@ -54,6 +54,7 @@ Page { ...@@ -54,6 +54,7 @@ Page {
} }
id: desktop id: desktop
property alias lockscreen: lockScreen property alias lockscreen: lockScreen
property alias switcher: switcher
// Implements back key navigation // Implements back key navigation
Keys.onReleased: { Keys.onReleased: {
if (event.key === Qt.Key_Back) { if (event.key === Qt.Key_Back) {
......
...@@ -346,7 +346,7 @@ Compositor { ...@@ -346,7 +346,7 @@ Compositor {
onWindowRemoved: { onWindowRemoved: {
console.log("Compositor: Window removed \"" + window.title + "\"" + " category: " + window.category) console.log("Compositor: Window removed \"" + window.title + "\"" + " category: " + window.category)
Desktop.instance.switcher.switchModel.removeWindowForTitle(window.title)
var w = window.userData; var w = window.userData;
if (window.category == "alarm") { if (window.category == "alarm") {
root.topmostAlarmWindow = null root.topmostAlarmWindow = null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment