aboutsummaryrefslogtreecommitdiffstats
path: root/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-29 03:27:05 +0000
committerDavid Robillard <d@drobilla.net>2012-04-29 03:27:05 +0000
commit94b9e452ebd9438a917b825d8d01137ddaa9e398 (patch)
treeace1acc489c42311d94f91346ff289127ed339b6 /pugl
parent4e6368d019e2543e6bf792f182486732d6f5a3f5 (diff)
downloadpugl-94b9e452ebd9438a917b825d8d01137ddaa9e398.tar.gz
pugl-94b9e452ebd9438a917b825d8d01137ddaa9e398.tar.bz2
pugl-94b9e452ebd9438a917b825d8d01137ddaa9e398.zip
Implement resizable and non-resizable windows.
Diffstat (limited to 'pugl')
-rw-r--r--pugl/pugl.h7
-rw-r--r--pugl/pugl_win.cpp6
-rw-r--r--pugl/pugl_x11.c19
3 files changed, 29 insertions, 3 deletions
diff --git a/pugl/pugl.h b/pugl/pugl.h
index 6a6fbe7..a764620 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -62,9 +62,14 @@ typedef void (*PuglReshapeFunc)(PuglWindow* handle, int width, int height);
@param title Window title, or NULL.
@param width Window width in pixels.
@param height Window height in pixels.
+ @param resizable Whether window should be user resizable.
*/
PuglWindow*
-puglCreate(PuglNativeWindow parent, const char* title, int width, int height);
+puglCreate(PuglNativeWindow parent,
+ const char* title,
+ int width,
+ int height,
+ bool resizable);
/**
Set the handle to be passed to all callbacks.
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index 50f42f0..63c6051 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -29,7 +29,11 @@ struct PuglPlatformDataImpl {
};
PuglWindow*
-puglCreate(PuglNativeWindow parent, const char* title, int width, int height)
+puglCreate(PuglNativeWindow parent,
+ const char* title,
+ int width,
+ int height,
+ bool resizable)
{
PuglWindow* win = (PuglWindow*)calloc(1, sizeof(PuglWindow));
diff --git a/pugl/pugl_x11.c b/pugl/pugl_x11.c
index 5844f2d..f85e18b 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/pugl_x11.c
@@ -62,7 +62,11 @@ static int attrListDbl[] = {
};
PuglWindow*
-puglCreate(PuglNativeWindow parent, const char* title, int width, int height)
+puglCreate(PuglNativeWindow parent,
+ const char* title,
+ int width,
+ int height,
+ bool resizable)
{
PuglWindow* win = (PuglWindow*)calloc(1, sizeof(PuglWindow));
@@ -112,6 +116,17 @@ puglCreate(PuglNativeWindow parent, const char* title, int width, int height)
0, 0, win->width, win->height, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask, &attr);
+ XSizeHints sizeHints;
+ memset(&sizeHints, 0, sizeof(sizeHints));
+ if (!resizable) {
+ sizeHints.flags = PMinSize|PMaxSize;
+ sizeHints.min_width = width;
+ sizeHints.min_height = height;
+ sizeHints.max_width = width;
+ sizeHints.max_height = height;
+ XSetNormalHints(impl->display, impl->win, &sizeHints);
+ }
+
if (title) {
XStoreName(impl->display, impl->win, title);
}
@@ -187,6 +202,8 @@ puglProcessEvents(PuglWindow* win)
event.xconfigure.width,
event.xconfigure.height);
}
+ win->width = event.xconfigure.width;
+ win->height = event.xconfigure.height;
}
break;
case MotionNotify: