aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;