diff options
author | David Robillard <d@drobilla.net> | 2019-08-04 17:40:07 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-09-03 08:34:39 +0200 |
commit | e4446d0939156cf542f4c6455bdef36cff69c00d (patch) | |
tree | 098a5f741179fda61e8746851d8cbc0f7b4e1f02 /pugl/detail/x11.c | |
parent | 1c585b574df224e44c5063474e4577a3e749be05 (diff) | |
download | pugl-e4446d0939156cf542f4c6455bdef36cff69c00d.tar.gz pugl-e4446d0939156cf542f4c6455bdef36cff69c00d.tar.bz2 pugl-e4446d0939156cf542f4c6455bdef36cff69c00d.zip |
X11: Factor out size hints calculation
Diffstat (limited to 'pugl/detail/x11.c')
-rw-r--r-- | pugl/detail/x11.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/pugl/detail/x11.c b/pugl/detail/x11.c index dd54644..1e1f96f 100644 --- a/pugl/detail/x11.c +++ b/pugl/detail/x11.c @@ -139,6 +139,35 @@ puglFindView(PuglWorld* world, const Window window) return NULL; } +static XSizeHints +getSizeHints(const PuglView* view) +{ + XSizeHints sizeHints = {0}; + + if (!view->hints[PUGL_RESIZABLE]) { + sizeHints.flags = PMinSize|PMaxSize; + sizeHints.min_width = (int)view->frame.width; + sizeHints.min_height = (int)view->frame.height; + sizeHints.max_width = (int)view->frame.width; + sizeHints.max_height = (int)view->frame.height; + } else { + if (view->minWidth || view->minHeight) { + sizeHints.flags = PMinSize; + sizeHints.min_width = view->minWidth; + sizeHints.min_height = view->minHeight; + } + if (view->minAspectX) { + sizeHints.flags |= PAspect; + sizeHints.min_aspect.x = view->minAspectX; + sizeHints.min_aspect.y = view->minAspectY; + sizeHints.max_aspect.x = view->maxAspectX; + sizeHints.max_aspect.y = view->maxAspectY; + } + } + + return sizeHints; +} + int puglCreateWindow(PuglView* view, const char* title) { @@ -179,27 +208,7 @@ puglCreateWindow(PuglView* view, const char* title) return 3; } - XSizeHints sizeHints = {0}; - if (!view->hints[PUGL_RESIZABLE]) { - sizeHints.flags = PMinSize|PMaxSize; - sizeHints.min_width = width; - sizeHints.min_height = height; - sizeHints.max_width = width; - sizeHints.max_height = height; - } else { - if (view->minWidth || view->minHeight) { - sizeHints.flags = PMinSize; - sizeHints.min_width = view->minWidth; - sizeHints.min_height = view->minHeight; - } - if (view->minAspectX) { - sizeHints.flags |= PAspect; - sizeHints.min_aspect.x = view->minAspectX; - sizeHints.min_aspect.y = view->minAspectY; - sizeHints.max_aspect.x = view->maxAspectX; - sizeHints.max_aspect.y = view->maxAspectY; - } - } + XSizeHints sizeHints = getSizeHints(view); XSetNormalHints(display, win, &sizeHints); if (title) { |