mirror of
https://github.com/dylanaraps/sowm.git
synced 2026-11-28 21:08:41 +00:00
sowm: cut the fat
This commit is contained in:
1 parent
4d6bb33353
commit
e53f49cc2d
1 file changed
+11
-27
@@ -6,10 +6,8 @@
|
|||||||
#include <X11/XF86keysym.h>
|
#include <X11/XF86keysym.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/wait.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
@@ -46,8 +44,6 @@ static void map_request(XEvent *e);
|
|||||||
|
|
||||||
static void run(const Arg arg);
|
static void run(const Arg arg);
|
||||||
|
|
||||||
static void sig_child(int unused);
|
|
||||||
|
|
||||||
static void key_grab();
|
static void key_grab();
|
||||||
static void key_press(XEvent *e);
|
static void key_press(XEvent *e);
|
||||||
|
|
||||||
@@ -374,7 +370,7 @@ void ws_sel(int i) {
|
|||||||
void wm_setup() {
|
void wm_setup() {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sig_child(0);
|
signal(SIGCHLD, SIG_IGN);
|
||||||
|
|
||||||
screen = DefaultScreen(dis);
|
screen = DefaultScreen(dis);
|
||||||
root = RootWindow(dis,screen);
|
root = RootWindow(dis,screen);
|
||||||
@@ -400,24 +396,12 @@ void wm_setup() {
|
|||||||
XSelectInput(dis, root, SubstructureNotifyMask|SubstructureRedirectMask);
|
XSelectInput(dis, root, SubstructureNotifyMask|SubstructureRedirectMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sig_child(int unused) {
|
|
||||||
if (signal(SIGCHLD, sig_child) == SIG_ERR)
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
while(0 < waitpid(-1, NULL, WNOHANG));
|
|
||||||
}
|
|
||||||
|
|
||||||
void run(const Arg arg) {
|
void run(const Arg arg) {
|
||||||
if (fork() == 0) {
|
if (fork()) return;
|
||||||
if (fork() == 0) {
|
if (dis) close(ConnectionNumber(dis));
|
||||||
if (dis) close(ConnectionNumber(dis));
|
|
||||||
|
|
||||||
setsid();
|
setsid();
|
||||||
execvp((char*)arg.com[0],(char**)arg.com);
|
execvp((char*)arg.com[0], (char**)arg.com);
|
||||||
}
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wm_init() {
|
void wm_init() {
|
||||||
@@ -439,13 +423,13 @@ void wm_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if (!(dis = XOpenDisplay(NULL)))
|
if ((dis = XOpenDisplay(NULL))) {
|
||||||
exit(1);
|
wm_setup();
|
||||||
|
wm_init();
|
||||||
|
|
||||||
wm_setup();
|
XCloseDisplay(dis);
|
||||||
wm_init();
|
}
|
||||||
|
|
||||||
XCloseDisplay(dis);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user