summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-11-01 00:48:15 +0100
committerDavid Robillard <d@drobilla.net>2014-12-16 18:31:22 -0500
commit3d27fe91f5c25405df0d332f17a7c6fc97d7da27 (patch)
tree6cc51b46304e526fc86f4082eb387e003e3ca059
parent715d42eeb66c771628c21a60fbcf3893e1896101 (diff)
Add support for transient child windows.
No Windows support currently. Conflicts: pugl/pugl.h pugl/pugl_osx.m pugl/pugl_win.cpp pugl/pugl_x11.c
-rw-r--r--pugl/pugl.h9
-rw-r--r--pugl/pugl_internal.h7
-rw-r--r--pugl/pugl_osx.m30
-rw-r--r--pugl/pugl_x11.c5
4 files changed, 39 insertions, 12 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h
index 54b4c78..53115ff 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -177,6 +177,15 @@ PUGL_API void
puglInitResizable(PuglView* view, bool resizable);
/**
+ Set transient parent before creating a window.
+
+ On X11, parent_id must be a Window.
+ On OSX, parent_id must be an NSView*.
+*/
+PUGL_API void
+puglInitTransientFor(PuglView* view, uintptr_t parent);
+
+/**
Set the context type before creating a window.
*/
PUGL_API void
diff --git a/pugl/pugl_internal.h b/pugl/pugl_internal.h
index 8a193d6..5b2b1c7 100644
--- a/pugl/pugl_internal.h
+++ b/pugl/pugl_internal.h
@@ -49,6 +49,7 @@ struct PuglViewImpl {
PuglNativeWindow parent;
PuglContextType ctx_type;
+ uintptr_t transient_parent;
int width;
int height;
@@ -111,6 +112,12 @@ puglInitResizable(PuglView* view, bool resizable)
}
void
+puglInitTransientFor(PuglView* view, uintptr_t parent)
+{
+ view->transient_parent = parent;
+}
+
+void
puglInitContextType(PuglView* view, PuglContextType type)
{
view->ctx_type = type;
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index 6139837..8735a6d 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -59,7 +59,6 @@
}
[self setAcceptsMouseMovedEvents:YES];
- [self setLevel: CGShieldingWindowLevel() + 1];
return (PuglWindow*)self;
}
@@ -445,17 +444,24 @@ puglCreateWindow(PuglView* view, const char* title)
[NSAutoreleasePool new];
impl->app = [NSApplication sharedApplication];
- NSString* titleString = [[NSString alloc]
- initWithBytes:title
- length:strlen(title)
- encoding:NSUTF8StringEncoding];
-
- id window = [[PuglWindow new] retain];
-
- [window setPuglview:view];
- [window setTitle:titleString];
- if (view->min_width || view->min_height) {
- [window setContentMinSize:NSMakeSize(view->min_width, view->min_height)];
+ if (view->transient_parent) {
+ NSView* pview = (NSView*)view->transient_parent;
+ [pview addSubview:impl->glview];
+ [impl->glview setHidden:NO];
+ [impl->glview setLevel: CGShieldingWindowLevel() + 1];
+ } else {
+ NSString* titleString = [[NSString alloc]
+ initWithBytes:title
+ length:strlen(title)
+ encoding:NSUTF8StringEncoding];
+
+ id window = [[RobTKPuglWindow new] retain];
+ [window setPuglview:view];
+ [window setTitle:titleString];
+ if (view->min_width || view->min_height) {
+ [window setContentMinSize:NSMakeSize(min_width, min_height)];
+ }
+ impl->window = window;
}
impl->glview = [PuglOpenGLView new];
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index e3325cd..4bf1f65 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -226,6 +226,11 @@ puglCreateWindow(PuglView* view, const char* title)
XSetWMProtocols(impl->display, impl->win, &wmDelete, 1);
}
+ if (view->transient_parent) {
+ XSetTransientForHint(impl->display, impl->win,
+ (Window)(view->transient_parent));
+ }
+
XFree(vi);
return 0;