summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/nativewindow.h3
-rw-r--r--plugingui/nativewindow_win32.cc5
-rw-r--r--plugingui/nativewindow_win32.h1
-rw-r--r--plugingui/nativewindow_x11.cc5
-rw-r--r--plugingui/nativewindow_x11.h1
-rw-r--r--plugingui/testmain.cc19
-rw-r--r--plugingui/window.cc5
-rw-r--r--plugingui/window.h3
8 files changed, 39 insertions, 3 deletions
diff --git a/plugingui/nativewindow.h b/plugingui/nativewindow.h
index c6ca7c8..b4429af 100644
--- a/plugingui/nativewindow.h
+++ b/plugingui/nativewindow.h
@@ -80,6 +80,9 @@ public:
//! Reads all currently enqueued events from the native window system.
//! \return A queue of shared pointers to events.
virtual EventQueue getEvents() = 0;
+
+ // \returns the native window handle, it HWND on Win32 or Window id on X11
+ virtual void* getNativeWindowHandle() const = 0;
};
} // GUI::
diff --git a/plugingui/nativewindow_win32.cc b/plugingui/nativewindow_win32.cc
index 75d523d..6297b23 100644
--- a/plugingui/nativewindow_win32.cc
+++ b/plugingui/nativewindow_win32.cc
@@ -445,4 +445,9 @@ EventQueue NativeWindowWin32::getEvents()
return events;
}
+void* NativeWindowWin32::getNativeWindowHandle() const
+{
+ return (void*)m_hwnd;
+}
+
} // GUI::
diff --git a/plugingui/nativewindow_win32.h b/plugingui/nativewindow_win32.h
index 630d853..2299189 100644
--- a/plugingui/nativewindow_win32.h
+++ b/plugingui/nativewindow_win32.h
@@ -55,6 +55,7 @@ public:
void redraw(const Rect& dirty_rect) override;
void grabMouse(bool grab) override;
EventQueue getEvents() override;
+ void* getNativeWindowHandle() const override;
private:
static LRESULT CALLBACK dialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
diff --git a/plugingui/nativewindow_x11.cc b/plugingui/nativewindow_x11.cc
index de2f1d1..989da4e 100644
--- a/plugingui/nativewindow_x11.cc
+++ b/plugingui/nativewindow_x11.cc
@@ -275,6 +275,11 @@ EventQueue NativeWindowX11::getEvents()
return events;
}
+void* NativeWindowX11::getNativeWindowHandle() const
+{
+ return (void*)xwindow;
+}
+
void NativeWindowX11::translateXMessage(XEvent& xevent)
{
switch(xevent.type)
diff --git a/plugingui/nativewindow_x11.h b/plugingui/nativewindow_x11.h
index dd2010e..c850318 100644
--- a/plugingui/nativewindow_x11.h
+++ b/plugingui/nativewindow_x11.h
@@ -57,6 +57,7 @@ public:
void redraw(const Rect& dirty_rect) override;
void grabMouse(bool grab) override;
EventQueue getEvents() override;
+ void* getNativeWindowHandle() const override;
private:
void translateXMessage(XEvent& xevent);
diff --git a/plugingui/testmain.cc b/plugingui/testmain.cc
index b1697eb..0bbd21f 100644
--- a/plugingui/testmain.cc
+++ b/plugingui/testmain.cc
@@ -35,19 +35,32 @@
#include <hugin.hpp>
#include <settings.h>
+#include "window.h"
#include "mainwindow.h"
int main()
{
INFO(example, "We are up and running");
+ GUI::Window parent{nullptr};
+ parent.setCaption("PluginGui Test Application");
+
Settings settings;
- GUI::MainWindow main_window(settings, nullptr);
+ GUI::MainWindow main_window(settings, parent.getNativeWindowHandle());
+
+ parent.show();
main_window.show();
- main_window.resize(370, 330);
- while(main_window.processEvents())
+ parent.resize(370, 330);
+
+ while(true)
{
+ parent.eventHandler()->processEvents();
+ if(!main_window.processEvents())
+ {
+ break;
+ }
+
#if DG_PLATFORM == DG_PLATFORM_WINDOWS
SleepEx(50, FALSE);
#else
diff --git a/plugingui/window.cc b/plugingui/window.cc
index 8bc5c62..66b7337 100644
--- a/plugingui/window.cc
+++ b/plugingui/window.cc
@@ -181,6 +181,11 @@ void Window::needsRedraw()
needs_redraw = true;
}
+void* Window::getNativeWindowHandle() const
+{
+ return native->getNativeWindowHandle();
+}
+
std::size_t Window::translateToWindowX()
{
return 0;
diff --git a/plugingui/window.h b/plugingui/window.h
index cfb004d..218beec 100644
--- a/plugingui/window.h
+++ b/plugingui/window.h
@@ -70,6 +70,9 @@ public:
//! Tag the window buffer dirty to be rendered.
void needsRedraw();
+ // \returns the native window handle, it HWND on Win32 or Window id on X11
+ void* getNativeWindowHandle() const;
+
protected:
// For the EventHandler
friend class EventHandler;