From fc8be13d242c6206254c1cf922aa315e364161b7 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 23 May 2019 22:10:03 -0400 Subject: [PATCH] removed even yet more stuff --- events.c | 55 +------------------------------------- main.c | 76 ++++++----------------------------------------------- manage.c | 30 ++------------------- new.c | 2 +- windowlab.h | 38 --------------------------- 5 files changed, 12 insertions(+), 189 deletions(-) diff --git a/events.c b/events.c index e65098f..a1f4b19 100644 --- a/events.c +++ b/events.c @@ -33,8 +33,6 @@ static void handle_property_change(XPropertyEvent *); static void handle_enter_event(XCrossingEvent *); static void handle_expose_event(XExposeEvent *); -static int interruptible_XNextEvent(XEvent *event); - /* We may want to put in some sort of check for unknown events at some * point. TWM has an interesting and different way of doing this... */ @@ -43,7 +41,7 @@ void do_event_loop(void) XEvent ev; for (;;) { - interruptible_XNextEvent(&ev); + XNextEvent(dsply, &ev); switch (ev.type) { case ButtonPress: @@ -101,20 +99,6 @@ static void handle_button_press(XButtonEvent *e) static void handle_windowbar_click(XButtonEvent *e, Client *c) { - static Client * first_click_c; - static Time first_click_time; - XEvent ev; - - if (first_click_c == c && (e->time - first_click_time) < DEF_DBLCLKTIME) - { - raise_lower(c); - first_click_c = NULL; // prevent 3rd clicks counting as double clicks - } - else - { - first_click_c = c; - } - first_click_time = e->time; move(c); } @@ -302,40 +286,3 @@ static void handle_expose_event(XExposeEvent *e) } } -/* interruptibleXNextEvent() was originally taken from Blender's source code - * and came with the following copyright notice: */ - -/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996. */ - -/* This program is freely distributable without licensing fees - * and is provided without guarantee or warrantee expressed or - * implied. This program is -not- in the public domain. */ - -/* Unlike XNextEvent, if a signal arrives, interruptibleXNextEvent will - * return zero. */ - -static int interruptible_XNextEvent(XEvent *event) -{ - fd_set fds; - int rc; - int dsply_fd = ConnectionNumber(dsply); - for (;;) - { - if (XPending(dsply)) - { - XNextEvent(dsply, event); - return 1; - } - FD_ZERO(&fds); - FD_SET(dsply_fd, &fds); - rc = select(dsply_fd + 1, &fds, NULL, NULL, NULL); - if (rc < 0) - { - if (errno == EINTR) - { - return 0; - } - return 1; - } - } -} diff --git a/main.c b/main.c index 58c44d3..7a4111e 100644 --- a/main.c +++ b/main.c @@ -28,22 +28,11 @@ Window root; int screen; XftFont *xftfont = NULL; XftColor xft_detail; -GC string_gc, border_gc, text_gc, active_gc, depressed_gc, inactive_gc, selected_gc, empty_gc; -XColor border_col, text_col, active_col, depressed_col, inactive_col, selected_col, empty_col; -Cursor resize_curs; +GC border_gc, active_gc; +XColor border_col, text_col, active_col; Atom wm_state, wm_change_state, wm_protos, wm_delete, wm_cmapwins; Client *head_client = NULL, *focused_client = NULL, *topmost_client = NULL; unsigned int focus_count = 0; -Rect fs_prevdims; -char *opt_font = DEF_FONT; -char *opt_border = DEF_BORDER; -char *opt_text = DEF_TEXT; -char *opt_active = DEF_ACTIVE; -char *opt_inactive = DEF_INACTIVE; -char *opt_selected = DEF_SELECTED; -char *opt_empty = DEF_EMPTY; -char *opt_display = NULL; -unsigned int numlockmask = 0; static void scan_wins(void); static void setup_display(void); @@ -79,10 +68,8 @@ static void setup_display(void) XColor dummyc; XGCValues gv; XSetWindowAttributes sattr; - XModifierKeymap *modmap; - int i, j; - dsply = XOpenDisplay(opt_display); + dsply = XOpenDisplay(NULL); if (dsply == NULL) { err("can't open display! check your DISPLAY variable."); @@ -99,21 +86,9 @@ static void setup_display(void) wm_delete = XInternAtom(dsply, "WM_DELETE_WINDOW", False); wm_cmapwins = XInternAtom(dsply, "WM_COLORMAP_WINDOWS", False); - XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_border, &border_col, &dummyc); - XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_text, &text_col, &dummyc); - XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_active, &active_col, &dummyc); - XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_inactive, &inactive_col, &dummyc); - XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_selected, &selected_col, &dummyc); - XAllocNamedColor(dsply, DefaultColormap(dsply, screen), opt_empty, &empty_col, &dummyc); - - depressed_col.pixel = active_col.pixel; - depressed_col.red = active_col.red - ACTIVE_SHADOW; - depressed_col.green = active_col.green - ACTIVE_SHADOW; - depressed_col.blue = active_col.blue - ACTIVE_SHADOW; - depressed_col.red = depressed_col.red <= (USHRT_MAX - ACTIVE_SHADOW) ? depressed_col.red : 0; - depressed_col.green = depressed_col.green <= (USHRT_MAX - ACTIVE_SHADOW) ? depressed_col.green : 0; - depressed_col.blue = depressed_col.blue <= (USHRT_MAX - ACTIVE_SHADOW) ? depressed_col.blue : 0; - XAllocColor(dsply, DefaultColormap(dsply, screen), &depressed_col); + XAllocNamedColor(dsply, DefaultColormap(dsply, screen), DEF_BORDER, &border_col, &dummyc); + XAllocNamedColor(dsply, DefaultColormap(dsply, screen), DEF_TEXT, &text_col, &dummyc); + XAllocNamedColor(dsply, DefaultColormap(dsply, screen), DEF_ACTIVE, &active_col, &dummyc); xft_detail.color.red = text_col.red; xft_detail.color.green = text_col.green; @@ -121,29 +96,13 @@ static void setup_display(void) xft_detail.color.alpha = 0xffff; xft_detail.pixel = text_col.pixel; - xftfont = XftFontOpenXlfd(dsply, DefaultScreen(dsply), opt_font); + xftfont = XftFontOpenXlfd(dsply, DefaultScreen(dsply), DEF_FONT); if (xftfont == NULL) { - err("font '%s' not found", opt_font); + err("font '%s' not found", DEF_FONT); exit(1); } - resize_curs = XCreateFontCursor(dsply, XC_fleur); - - /* find out which modifier is NumLock - we'll use this when grabbing every combination of modifiers we can think of */ - modmap = XGetModifierMapping(dsply); - for (i = 0; i < 8; i++) - { - for (j = 0; j < modmap->max_keypermod; j++) - { - if (modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(dsply, XK_Num_Lock)) - { - numlockmask = (1 << i); - } - } - } - XFree(modmap); - gv.function = GXcopy; gv.foreground = border_col.pixel; @@ -153,28 +112,9 @@ static void setup_display(void) gv.foreground = text_col.pixel; gv.line_width = 1; - text_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv); - gv.foreground = active_col.pixel; active_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv); - gv.foreground = depressed_col.pixel; - depressed_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv); - - gv.foreground = inactive_col.pixel; - inactive_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv); - - gv.foreground = selected_col.pixel; - selected_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv); - - gv.foreground = empty_col.pixel; - empty_gc = XCreateGC(dsply, root, GCFunction|GCForeground, &gv); - sattr.event_mask = ChildMask|ColormapChangeMask|ButtonMask; XChangeWindowAttributes(dsply, root, CWEventMask, &sattr); - - grab_keysym(root, MODIFIER, KEY_CYCLEPREV); - grab_keysym(root, MODIFIER, KEY_CYCLENEXT); - grab_keysym(root, MODIFIER, KEY_FULLSCREEN); - grab_keysym(root, MODIFIER, KEY_TOGGLEZ); } diff --git a/manage.c b/manage.c index ad22862..78cf822 100644 --- a/manage.c +++ b/manage.c @@ -20,23 +20,6 @@ #include "windowlab.h" -void raise_lower(Client *c) -{ - if (c != NULL) - { - if (c == topmost_client) - { - lower_win(c); - topmost_client = NULL; // lazy but amiwm does similar - } - else - { - raise_win(c); - topmost_client = c; - } - } -} - /* The name of this function is a bit misleading: if the client * doesn't listen to WM_DELETE then we just terminate it with extreme * prejudice. */ @@ -86,8 +69,8 @@ void move(Client *c) bounddims.width = (dw - bounddims.x - (c->width - bounddims.x)) + 1; bounddims.y = mousey - c->y; bounddims.height = (dh - bounddims.y - (c->height - bounddims.y)) + 1; - bounddims.y += (BARHEIGHT() * 2) - BORDERWIDTH(c); - bounddims.height += c->height - ((BARHEIGHT() * 2) - DEF_BORDERWIDTH); + bounddims.y += BARHEIGHT() - BORDERWIDTH(c); + bounddims.height += c->height - (BARHEIGHT() - DEF_BORDERWIDTH); constraint_win = XCreateWindow(dsply, root, bounddims.x, bounddims.y, bounddims.width, bounddims.height, 0, CopyFromParent, InputOnly, CopyFromParent, 0, &pattr); XMapWindow(dsply, constraint_win); @@ -123,12 +106,3 @@ void move(Client *c) ungrab(); XDestroyWindow(dsply, constraint_win); } - -void write_titletext(Client *c, Window bar_win) -{ - if (!c->trans && c->name != NULL) - { - (void) bar_win; // fixes a warning - XftDrawString8(c->xftdraw, &xft_detail, xftfont, SPACE, SPACE + xftfont->ascent, (unsigned char *)c->name, strlen(c->name)); - } -} diff --git a/new.c b/new.c index 3382878..d0b87f7 100644 --- a/new.c +++ b/new.c @@ -166,7 +166,7 @@ static void reparent(Client *c) XSetWindowAttributes pattr; pattr.override_redirect = True; - pattr.background_pixel = empty_col.pixel; +// pattr.background_pixel = empty_col.pixel; pattr.border_pixel = border_col.pixel; pattr.event_mask = ChildMask|ButtonPressMask|ExposureMask|EnterWindowMask; c->frame = XCreateWindow(dsply, root, c->x, c->y - BARHEIGHT(), c->width, c->height + BARHEIGHT(), BORDERWIDTH(c), DefaultDepth(dsply, screen), CopyFromParent, DefaultVisual(dsply, screen), CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &pattr); diff --git a/windowlab.h b/windowlab.h index b6499f4..3e36a58 100644 --- a/windowlab.h +++ b/windowlab.h @@ -21,9 +21,6 @@ #ifndef WINDOWLAB_H #define WINDOWLAB_H -#define VERSION "1.40" -#define RELEASEDATE "2010-04-04" - #include #include #include @@ -38,10 +35,6 @@ #include #include -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - // here are the default settings - change to suit your taste // if you aren't sure about DEF_FONT, change it to "fixed"; almost all X installations will have that available @@ -59,19 +52,6 @@ #define ACTIVE_SHADOW 0x2000 // eg #fff becomes #ddd #define SPACE 3 -// change MODIFIER to None to remove the need to hold down a modifier key -// the Windows key should be Mod4Mask and the Alt key is Mod1Mask -#define MODIFIER Mod4Mask - -// keys may be used by other apps, so change them here -#define KEY_CYCLEPREV XK_Tab -#define KEY_CYCLENEXT XK_q -#define KEY_FULLSCREEN XK_F11 -#define KEY_TOGGLEZ XK_F12 - -// max time between clicks in double click -#define DEF_DBLCLKTIME 400 - // a few useful masks made up out of X's basic ones. `ChildMask' is a silly name, but oh well. #define ChildMask (SubstructureRedirectMask|SubstructureNotifyMask) #define ButtonMask (ButtonPressMask|ButtonReleaseMask) @@ -124,13 +104,6 @@ #define WITHDRAW 0 #define REMAP 1 -// stuff for the menu file -#define MAX_MENUITEMS 24 -#define MAX_MENUITEMS_SIZE (sizeof(MenuItem) * MAX_MENUITEMS) -#define STR_SIZE 128 -#define NO_MENU_LABEL "xterm" -#define NO_MENU_COMMAND "xterm" - /* This structure keeps track of top-level windows (hereinafter * 'clients'). The clients we know about (i.e. all that don't set * override-redirect) are kept track of in linked list starting at the @@ -208,27 +181,16 @@ extern void redraw(Client *); extern void gravitate(Client *, int); extern void check_focus(Client *); extern Client *get_prev_focused(void); -extern void draw_hide_button(Client *, GC *, GC *); -extern void draw_toggledepth_button(Client *, GC *, GC *); -extern void draw_close_button(Client *, GC *, GC *); // new.c extern void make_new_client(Window); // manage.c extern void move(Client *); -extern void raise_lower(Client *); -extern void resize(Client *, int, int); -extern void hide(Client *); -extern void unhide(Client *); -extern void toggle_fullscreen(Client *); extern void send_wm_delete(Client *); -extern void write_titletext(Client *, Window); // misc.c extern void err(const char *, ...); -extern void fork_exec(char *); -extern void sig_handler(int); extern int handle_xerror(Display *, XErrorEvent *); extern int ignore_xerror(Display *, XErrorEvent *); extern int send_xmessage(Window, Atom, long); -- 2.54.0