aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2014-09-10 21:53:32 +0000
committerDimitri Sokolyuk <demon@dim13.org>2014-09-10 21:53:32 +0000
commit339f99bc2a023c4392f1b316cd2baeda6703d1b6 (patch)
treed144bde397f8399cecf0eebfb252781f5dbdd3f0
parentd27da65f2952cbfdf755cbcd8838e174ff5d5f06 (diff)
split code
-rw-r--r--aux.c18
-rw-r--r--aux.h1
-rw-r--r--spectrogram.c13
3 files changed, 20 insertions, 12 deletions
diff --git a/aux.c b/aux.c
index 5012968..736e903 100644
--- a/aux.c
+++ b/aux.c
@@ -16,6 +16,7 @@
*/
#include <X11/Xlib.h>
+#include <X11/Xutil.h>
#include <string.h>
@@ -76,3 +77,20 @@ move(Display *d, Window win, Window container)
XMoveWindow(d, container, dx, dy);
}
+
+void
+restrictsize(Display *d, Window win, int minw, int minh, int maxw, int maxh)
+{
+ Atom nhints;
+ XSizeHints *hints;
+
+ nhints = XInternAtom(d, "WM_NORMAL_HINTS", 0);
+ hints = XAllocSizeHints();
+ hints->flags = PMinSize|PMaxSize;
+ hints->min_width = minw;
+ hints->min_height = minh;
+ hints->max_width = maxw;
+ hints->max_height = maxh;
+ XSetWMSizeHints(d, win, hints, nhints);
+ XFree(hints);
+}
diff --git a/aux.h b/aux.h
index 4f731b4..c9f8075 100644
--- a/aux.h
+++ b/aux.h
@@ -22,6 +22,7 @@ __BEGIN_DECLS
void fullscreen(Display *, Window);
void hide_ptr(Display *, Window);
void move(Display *, Window, Window);
+void restrictsize(Display *, Window, int, int, int, int);
__END_DECLS
#endif
diff --git a/spectrogram.c b/spectrogram.c
index 08ddb5d..466917b 100644
--- a/spectrogram.c
+++ b/spectrogram.c
@@ -25,7 +25,6 @@
#include <unistd.h>
#include "aux.h"
-#include "cms.h"
#include "fft.h"
#include "sio.h"
#include "widget.h"
@@ -59,8 +58,6 @@ main(int argc, char **argv)
Display *dsp;
Window win, container;
Atom delwin;
- Atom nhints;
- XSizeHints *hints;
XClassHint *class;
XWindowAttributes wa;
XRectangle geo;
@@ -151,15 +148,7 @@ main(int argc, char **argv)
XSetWMProtocols(dsp, win, &delwin, 1);
/* set minimal size */
- nhints = XInternAtom(dsp, "WM_NORMAL_HINTS", 0);
- hints = XAllocSizeHints();
- hints->flags = PMinSize|PMaxSize;
- hints->min_width = width;
- hints->min_height = height;
- hints->max_width = maxwidth;
- hints->max_height = maxheight;
- XSetWMSizeHints(dsp, win, hints, nhints);
- XFree(hints);
+ restrictsize(dsp, win, width, height, maxwidth, maxheight);
container = XCreateSimpleWindow(dsp, win,
0, 0, width, height, 0, white, black);