Line data Source code
1 :
2 : /* Copyright (c) 2014-2017, Daniel Nachbaur <danielnachbaur@gmail.com>
3 : * Juan Hernando <jhernando@fi.upm.es>
4 : * Stefan.Eilemann@epfl.ch
5 : *
6 : * This library is free software; you can redistribute it and/or modify it under
7 : * the terms of the GNU Lesser General Public License version 2.1 as published
8 : * by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful, but WITHOUT
11 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 : * details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public License
16 : * along with this library; if not, write to the Free Software Foundation, Inc.,
17 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 : */
19 :
20 : #define NOMINMAX // no min/max from windows.h
21 : #pragma warning(disable : 4407) // see lunchbox/commandFunc.h
22 : #include <eq/window.h> // be first to avoid max/min name clashes on Win32
23 :
24 : #include "windowSystem.h"
25 :
26 : #include "messagePump.h"
27 : #include "pipe.h"
28 : #include "shareContextWindow.h"
29 : #include "window.h"
30 : #include "windowFactory.h"
31 :
32 : #include <QApplication>
33 : #include <QThread>
34 : #include <eq/client.h>
35 :
36 : namespace eq
37 : {
38 : namespace qt
39 : {
40 0 : WindowSystem::WindowSystem()
41 0 : : _factory(new WindowFactory)
42 : {
43 0 : qRegisterMetaType<WindowSettings>("WindowSettings");
44 0 : QCoreApplication* app = QApplication::instance();
45 0 : if (!app)
46 0 : return;
47 :
48 0 : _factory->moveToThread(app->thread());
49 : app->connect(this, SIGNAL(createImpl(eq::Window&, const WindowSettings&,
50 : QThread*)),
51 0 : _factory, SLOT(onCreateImpl(eq::Window&, const WindowSettings&,
52 : QThread*)),
53 0 : Qt::BlockingQueuedConnection);
54 : }
55 :
56 0 : WindowSystem::~WindowSystem()
57 : {
58 0 : delete _factory;
59 0 : }
60 :
61 0 : std::string WindowSystem::getName() const
62 : {
63 0 : return QApplication::instance() ? "Qt" : "";
64 : }
65 :
66 0 : eq::SystemWindow* WindowSystem::createWindow(eq::Window* window,
67 : const WindowSettings& settings)
68 : {
69 : // QWindow creation/destruction must happen in the app thread; unblock main
70 : // thread to give QApplication the chance to process the createImpl signal.
71 : // Note that even a QOffscreenSurface is backed by a QWindow on some
72 : // platforms.
73 0 : window->getClient()->interruptMainThread();
74 : qt::Window* qtWindow =
75 0 : createImpl(*window, settings, QThread::currentThread());
76 0 : LBASSERT(qtWindow);
77 0 : qtWindow->connect(qtWindow, SIGNAL(destroyImpl(detail::Window*)), _factory,
78 0 : SLOT(onDestroyImpl(detail::Window*)));
79 0 : return qtWindow;
80 : }
81 :
82 0 : eq::SystemPipe* WindowSystem::createPipe(eq::Pipe* pipe)
83 : {
84 0 : return new Pipe(pipe);
85 : }
86 :
87 0 : eq::MessagePump* WindowSystem::createMessagePump()
88 : {
89 0 : return new MessagePump;
90 : }
91 :
92 0 : bool WindowSystem::setupFont(util::ObjectManager& gl LB_UNUSED,
93 : const void* key LB_UNUSED,
94 : const std::string& name LB_UNUSED,
95 : const uint32_t size LB_UNUSED) const
96 : {
97 0 : return false;
98 : }
99 : }
100 30 : }
|