blob: c0710bbcb02667004b5508e7b81a7a3d8b4060dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
//===========================================
// Lumina-desktop source code
// Copyright (c) 2017, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
#include "RootWindow.h"
RootWindow::RootWindow(){
root_win = QWindow::fromWinId( QX11Info::appRootWindow() ); //
root_view = new QQuickView(root_win); //make it a child of the root window
root_obj = RootDesktopObject::instance();
syncRootSize();
connect(root_win, SIGNAL(widthChanged(int)), this, SLOT(syncRootSize()) );
connect(root_win, SIGNAL(heightChanged(int)),this, SLOT(syncRootSize()) );
//Now setup the QQuickView
root_view->setResizeMode(QQuickView::SizeRootObjectToView);
root_view->engine()->rootContext()->setContextProperty("RootObject", root_obj);
root_view->setSource(QUrl("qrc:///qml/RootDesktop"));
root_view->show();
}
RootWindow::~RootWindow(){
root_view->deleteLater();
root_obj->deleteLater();
}
void RootWindow::syncRootSize(){
if(root_win->width() != root_view->width() || root_win->height() != root_view->height()){
root_view->setGeometry(0, 0, root_win->width(), root_win->height() );
emit RootResized(root_view->geometry());
}
}
|