From 6bb0b331d61f247f56de22c63145dee561df2a21 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 10 Sep 2014 20:47:46 +0000 Subject: split code --- Makefile | 4 ++-- Makefile.linux | 3 +-- aux.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ aux.h | 26 +++++++++++++++++++++++++ spectrogram.c | 44 ++---------------------------------------- 5 files changed, 92 insertions(+), 46 deletions(-) create mode 100644 aux.c create mode 100644 aux.h diff --git a/Makefile b/Makefile index d49feb4..6f9ec6c 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,9 @@ VERSION=2.0 PROG= spectrogram -SRCS= spectrogram.c sio.c fft.c cms.c +SRCS= spectrogram.c sio.c fft.c cms.c aux.c BINDIR= /usr/local/bin -HEADERS=sio.h fft.h cms.h +HEADERS=sio.h fft.h cms.h aux.h LIBS= fftw3 x11 PCCF!= pkg-config --cflags ${LIBS} PCLA!= pkg-config --libs ${LIBS} diff --git a/Makefile.linux b/Makefile.linux index 159ec60..76eed82 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,9 +1,8 @@ # $Id$ PROG= spectrogram -SRCS= spectrogram.c alsa.c fft.c cms.c +SRCS= spectrogram.c alsa.c fft.c cms.c aux.c BINDIR= /usr/local/bin -HEADERS=fft.h cms.h LIBS= fftw3 x11 alsa PCCF!= pkg-config --cflags ${LIBS} PCLA!= pkg-config --libs ${LIBS} diff --git a/aux.c b/aux.c new file mode 100644 index 0000000..f2f2b2c --- /dev/null +++ b/aux.c @@ -0,0 +1,61 @@ +/* $Id$ */ +/* + * Copyright (c) 2010 Dimitri Sokolyuk + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include + +void +fullscreen(Display *d, Window win) +{ + XClientMessageEvent cm; + + bzero(&cm, sizeof(cm)); + cm.type = ClientMessage; + cm.send_event = True; + cm.message_type = XInternAtom(d, "_NET_WM_STATE", False); + cm.window = win; + cm.format = 32; + cm.data.l[0] = 1; /* _NET_WM_STATE_ADD */ + cm.data.l[1] = XInternAtom(d, "_NET_WM_STATE_FULLSCREEN", False); + cm.data.l[2] = 0; /* no secondary property */ + cm.data.l[3] = 1; /* normal application */ + + XSendEvent(d, DefaultRootWindow(d), False, NoEventMask, (XEvent *)&cm); + XMoveWindow(d, win, 0, 0); +} + +void +hide_ptr(Display *d, Window win) +{ + Pixmap bm; + Cursor ptr; + Colormap cmap; + XColor black, dummy; + static char empty[] = {0, 0, 0, 0, 0, 0, 0, 0}; + + cmap = DefaultColormap(d, DefaultScreen(d)); + XAllocNamedColor(d, cmap, "black", &black, &dummy); + bm = XCreateBitmapFromData(d, win, empty, 8, 8); + ptr = XCreatePixmapCursor(d, bm, bm, &black, &black, 0, 0); + + XDefineCursor(d, win, ptr); + XFreeCursor(d, ptr); + if (bm != None) + XFreePixmap(d, bm); + XFreeColors(d, cmap, &black.pixel, 1, 0); +} diff --git a/aux.h b/aux.h new file mode 100644 index 0000000..ecd378a --- /dev/null +++ b/aux.h @@ -0,0 +1,26 @@ +/* $Id$ */ +/* + * Copyright (c) 2010 Dimitri Sokolyuk + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _AUX_H +#define _AUX_H + +__BEGIN_DECLS +void fullscreen(Display *, Window); +void hide_ptr(Display *, Window); +__END_DECLS + +#endif diff --git a/spectrogram.c b/spectrogram.c index e896ab6..9886152 100644 --- a/spectrogram.c +++ b/spectrogram.c @@ -32,6 +32,7 @@ #include #include +#include "aux.h" #include "cms.h" #include "fft.h" #include "sio.h" @@ -394,47 +395,6 @@ move(Display *dsp, Window win, Window container) return 0; } -void -gofullscreen(Display *d, Window win) -{ - XClientMessageEvent cm; - - bzero(&cm, sizeof(cm)); - cm.type = ClientMessage; - cm.send_event = True; - cm.message_type = XInternAtom(d, "_NET_WM_STATE", False); - cm.window = win; - cm.format = 32; - cm.data.l[0] = 1; /* _NET_WM_STATE_ADD */ - cm.data.l[1] = XInternAtom(d, "_NET_WM_STATE_FULLSCREEN", False); - cm.data.l[2] = 0; /* no secondary property */ - cm.data.l[3] = 1; /* normal application */ - - XSendEvent(d, DefaultRootWindow(d), False, NoEventMask, (XEvent *)&cm); - XMoveWindow(d, win, 0, 0); -} - -void -hide_ptr(Display *d, Window win) -{ - Pixmap bm; - Cursor ptr; - Colormap cmap; - XColor black, dummy; - static char empty[] = {0, 0, 0, 0, 0, 0, 0, 0}; - - cmap = DefaultColormap(d, DefaultScreen(d)); - XAllocNamedColor(d, cmap, "black", &black, &dummy); - bm = XCreateBitmapFromData(d, win, empty, 8, 8); - ptr = XCreatePixmapCursor(d, bm, bm, &black, &black, 0, 0); - - XDefineCursor(d, win, ptr); - XFreeCursor(d, ptr); - if (bm != None) - XFreePixmap(d, bm); - XFreeColors(d, cmap, &black.pixel, 1, 0); -} - int main(int argc, char **argv) { @@ -564,7 +524,7 @@ main(int argc, char **argv) XMapRaised(dsp, win); /* XMapWindow */ if (fflag) { - gofullscreen(dsp, win); + fullscreen(dsp, win); if (pflag) hide_ptr(dsp, win); } -- cgit v1.2.3