From: Michael D. Lowis Date: Thu, 23 May 2019 02:01:30 +0000 (-0400) Subject: remove taskbar X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=7575608e8bd966a4a7e61da07372cc89d555264c;p=proto%2Fwindowlab.git remove taskbar --- diff --git a/Makefile b/Makefile index 6d7054e..71c7e6d 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ LIBS = -lX11 -lXft PROG = windowlab MANPAGE = windowlab.1x -OBJS = main.o events.o client.o new.o manage.o misc.o taskbar.o +OBJS = main.o events.o client.o new.o manage.o misc.o HEADERS = windowlab.h all: $(PROG) diff --git a/client.c b/client.c index 3ef5cc6..b31e274 100644 --- a/client.c +++ b/client.c @@ -177,8 +177,6 @@ void remove_client(Client *c, int mode) XSync(dsply, False); XSetErrorHandler(handle_xerror); XUngrabServer(dsply); - - redraw_taskbar(); } void redraw(Client *c) @@ -272,7 +270,6 @@ void check_focus(Client *c) { redraw(old_focused); } - redraw_taskbar(); } } diff --git a/events.c b/events.c index 88dfbd4..ece3144 100644 --- a/events.c +++ b/events.c @@ -95,12 +95,6 @@ static void handle_key_press(XKeyEvent *e) KeySym key = XKeycodeToKeysym(dsply, e->keycode, 0); switch (key) { - case KEY_CYCLEPREV: - cycle_previous(); - break; - case KEY_CYCLENEXT: - cycle_next(); - break; case KEY_FULLSCREEN: toggle_fullscreen(focused_client); break; @@ -137,21 +131,6 @@ static void handle_button_press(XButtonEvent *e) dump_clients(); #endif } - else if (e->window == taskbar) - { - switch (e->button) - { - case Button1: // left mouse button - lclick_taskbar(e->x); - break; - case Button4: // mouse wheel up - cycle_previous(); - break; - case Button5: // mouse wheel down - cycle_next(); - break; - } - } else { // pass event on @@ -472,7 +451,6 @@ static void handle_property_change(XPropertyEvent *e) } XFetchName(dsply, c->window, &c->name); redraw(c); - redraw_taskbar(); break; case XA_WM_NORMAL_HINTS: XGetWMNormalHints(dsply, c->window, c->size, &dummy); @@ -494,41 +472,12 @@ static void handle_property_change(XPropertyEvent *e) static void handle_enter_event(XCrossingEvent *e) { Client *c = NULL; - if (e->window == taskbar) - { - in_taskbar = 1; - if (showing_taskbar == 0) - { - showing_taskbar = 1; - redraw_taskbar(); - } - } - else - { - in_taskbar = 0; - if (fullscreen_client != NULL) - { - if (showing_taskbar == 1) - { - showing_taskbar = 0; - redraw_taskbar(); - } - } - else // no fullscreen client - { - if (showing_taskbar == 0) - { - showing_taskbar = 1; - redraw_taskbar(); - } - } c = find_client(e->window, FRAME); if (c != NULL) { XGrabButton(dsply, AnyButton, AnyModifier, c->frame, False, ButtonMask, GrabModeSync, GrabModeSync, None, None); } - } } /* Here's part 2 of our colormap policy: when a client installs a new @@ -557,21 +506,11 @@ static void handle_colormap_change(XColormapEvent *e) static void handle_expose_event(XExposeEvent *e) { - if (e->window == taskbar) - { - if (e->count == 0) - { - redraw_taskbar(); - } - } - else - { Client *c = find_client(e->window, FRAME); if (c != NULL && e->count == 0) { redraw(c); } - } } /* interruptibleXNextEvent() was originally taken from Blender's source code diff --git a/main.c b/main.c index 5cd35ca..6c69094 100644 --- a/main.c +++ b/main.c @@ -62,7 +62,6 @@ int main(int argc, char **argv) sigaction(SIGCHLD, &act, NULL); setup_display(); - make_taskbar(); scan_wins(); do_event_loop(); return 1; diff --git a/manage.c b/manage.c index 2ae1a1d..f5dc746 100644 --- a/manage.c +++ b/manage.c @@ -145,7 +145,6 @@ void toggle_fullscreen(Client *c) fullscreen_client = c; showing_taskbar = in_taskbar; } - redraw_taskbar(); } } @@ -321,135 +320,6 @@ void resize(Client *c, int x, int y) } } break; - case MotionNotify: - { - unsigned int in_taskbar = 1, leftedge_changed = 0, rightedge_changed = 0, topedge_changed = 0, bottomedge_changed = 0; - int newwidth, newheight; - // warping the pointer is wrong - wait until it leaves the taskbar - if (ev.xmotion.y < BARHEIGHT()) - { - in_taskbar = 1; - } - else - { - if (in_taskbar == 1) // first time outside taskbar - { - in_taskbar = 0; - bounddims.x = 0; - bounddims.width = dw; - bounddims.y = BARHEIGHT(); - bounddims.height = dh - BARHEIGHT(); - XMoveResizeWindow(dsply, constraint_win, bounddims.x, bounddims.y, bounddims.width, bounddims.height); - in_taskbar = 0; - } - // inside the window, dragging outwards - if (dragging_outwards) - { - if (ev.xmotion.x < newdims.x + BORDERWIDTH(c)) - { - newdims.width += newdims.x + BORDERWIDTH(c) - ev.xmotion.x; - newdims.x = ev.xmotion.x - BORDERWIDTH(c); - leftedge_changed = 1; - } - else if (ev.xmotion.x > newdims.x + newdims.width + BORDERWIDTH(c)) - { - newdims.width = (ev.xmotion.x - newdims.x - BORDERWIDTH(c)) + 1; // add 1 to allow window to be flush with edge of screen - rightedge_changed = 1; - } - if (ev.xmotion.y < newdims.y + BORDERWIDTH(c)) - { - newdims.height += newdims.y + BORDERWIDTH(c) - ev.xmotion.y; - newdims.y = ev.xmotion.y - BORDERWIDTH(c); - topedge_changed = 1; - } - else if (ev.xmotion.y > newdims.y + newdims.height + BORDERWIDTH(c)) - { - newdims.height = (ev.xmotion.y - newdims.y - BORDERWIDTH(c)) + 1; // add 1 to allow window to be flush with edge of screen - bottomedge_changed = 1; - } - } - // outside the window, dragging inwards - else - { - unsigned int above_win, below_win, leftof_win, rightof_win; - unsigned int in_win; - - above_win = (ev.xmotion.y < newdims.y + BORDERWIDTH(c)); - below_win = (ev.xmotion.y > newdims.y + newdims.height + BORDERWIDTH(c)); - leftof_win = (ev.xmotion.x < newdims.x + BORDERWIDTH(c)); - rightof_win = (ev.xmotion.x > newdims.x + newdims.width + BORDERWIDTH(c)); - - in_win = ((!above_win) && (!below_win) && (!leftof_win) && (!rightof_win)); - - if (in_win) - { - unsigned int from_left, from_right, from_top, from_bottom; - from_left = ev.xmotion.x - newdims.x - BORDERWIDTH(c); - from_right = newdims.x + newdims.width + BORDERWIDTH(c) - ev.xmotion.x; - from_top = ev.xmotion.y - newdims.y - BORDERWIDTH(c); - from_bottom = newdims.y + newdims.height + BORDERWIDTH(c) - ev.xmotion.y; - if (from_left < from_right && from_left < from_top && from_left < from_bottom) - { - newdims.width -= ev.xmotion.x - newdims.x - BORDERWIDTH(c); - newdims.x = ev.xmotion.x - BORDERWIDTH(c); - leftedge_changed = 1; - } - else if (from_right < from_top && from_right < from_bottom) - { - newdims.width = ev.xmotion.x - newdims.x - BORDERWIDTH(c); - rightedge_changed = 1; - } - else if (from_top < from_bottom) - { - newdims.height -= ev.xmotion.y - newdims.y - BORDERWIDTH(c); - newdims.y = ev.xmotion.y - BORDERWIDTH(c); - topedge_changed = 1; - } - else - { - newdims.height = ev.xmotion.y - newdims.y - BORDERWIDTH(c); - bottomedge_changed = 1; - } - } - } - // coords have changed - if (leftedge_changed || rightedge_changed || topedge_changed || bottomedge_changed) - { - copy_dims(&newdims, &recalceddims); - recalceddims.height -= BARHEIGHT(); - - if (get_incsize(c, (unsigned int *)&newwidth, (unsigned int *)&newheight, &recalceddims, PIXELS)) - { - if (leftedge_changed) - { - recalceddims.x = (recalceddims.x + recalceddims.width) - newwidth; - recalceddims.width = newwidth; - } - else if (rightedge_changed) - { - recalceddims.width = newwidth; - } - - if (topedge_changed) - { - recalceddims.y = (recalceddims.y + recalceddims.height) - newheight; - recalceddims.height = newheight; - } - else if (bottomedge_changed) - { - recalceddims.height = newheight; - } - } - - recalceddims.height += BARHEIGHT(); - limit_size(c, &recalceddims); - - XMoveResizeWindow(dsply, resize_win, recalceddims.x, recalceddims.y, recalceddims.width, recalceddims.height); - XResizeWindow(dsply, resizebar_win, recalceddims.width, BARHEIGHT() - DEF_BORDERWIDTH); - } - } - } - break; } } while (ev.type != ButtonRelease); diff --git a/new.c b/new.c index 6f98c96..3382878 100644 --- a/new.c +++ b/new.c @@ -120,8 +120,6 @@ void make_new_client(Window w) XSync(dsply, False); XUngrabServer(dsply); - - redraw_taskbar(); } diff --git a/taskbar.c b/taskbar.c deleted file mode 100644 index 7338ff2..0000000 --- a/taskbar.c +++ /dev/null @@ -1,267 +0,0 @@ -/* WindowLab - an X11 window manager - * Copyright (c) 2001-2010 Nick Gravgaard - * me at nickgravgaard.com - * http://nickgravgaard.com/windowlab/ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "windowlab.h" - -Window taskbar; -XftDraw *tbxftdraw; - -void make_taskbar(void) -{ - XSetWindowAttributes pattr; - - pattr.override_redirect = True; - pattr.background_pixel = empty_col.pixel; - pattr.border_pixel = border_col.pixel; - pattr.event_mask = ChildMask|ButtonPressMask|ExposureMask|EnterWindowMask; - taskbar = XCreateWindow(dsply, root, 0 - DEF_BORDERWIDTH, 0 - DEF_BORDERWIDTH, DisplayWidth(dsply, screen), BARHEIGHT() - DEF_BORDERWIDTH, DEF_BORDERWIDTH, DefaultDepth(dsply, screen), CopyFromParent, DefaultVisual(dsply, screen), CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &pattr); - - XMapWindow(dsply, taskbar); - - tbxftdraw = XftDrawCreate(dsply, (Drawable) taskbar, DefaultVisual(dsply, DefaultScreen(dsply)), DefaultColormap(dsply, DefaultScreen(dsply))); -} - -void remember_hidden(void) -{ - Client *c; - for (c = head_client; c != NULL; c = c->next) - { - c->was_hidden = c->hidden; - } -} - -void forget_hidden(void) -{ - Client *c; - for (c = head_client; c != NULL; c = c->next) - { - if (c == focused_client) - { - c->was_hidden = c->hidden; - } - else - { - c->was_hidden = 0; - } - } -} - -void lclick_taskbutton(Client *old_c, Client *c) -{ - if (old_c != NULL) - { - if (old_c->was_hidden) - { - hide(old_c); - } - } - - if (c->hidden) - { - unhide(c); - } - else - { - if (c->was_hidden) - { - hide(c); - } - else - { - raise_lower(c); - } - } - check_focus(c); -} - -void lclick_taskbar(int x) -{ - XEvent ev; - int mousex, mousey; - Rect bounddims; - Window constraint_win; - XSetWindowAttributes pattr; - - float button_width; - unsigned int button_clicked, old_button_clicked, i; - Client *c, *exposed_c, *old_c; - if (head_client != NULL) - { - remember_hidden(); - - get_mouse_position(&mousex, &mousey); - - bounddims.x = 0; - bounddims.y = 0; - bounddims.width = DisplayWidth(dsply, screen); - bounddims.height = BARHEIGHT(); - - constraint_win = XCreateWindow(dsply, root, bounddims.x, bounddims.y, bounddims.width, bounddims.height, 0, CopyFromParent, InputOnly, CopyFromParent, 0, &pattr); - XMapWindow(dsply, constraint_win); - - if (!(XGrabPointer(dsply, root, False, MouseMask, GrabModeAsync, GrabModeAsync, constraint_win, None, CurrentTime) == GrabSuccess)) - { - XDestroyWindow(dsply, constraint_win); - return; - } - - button_width = get_button_width(); - - button_clicked = (unsigned int)(x / button_width); - for (i = 0, c = head_client; i < button_clicked; i++) - { - c = c->next; - } - - lclick_taskbutton(NULL, c); - - do - { - XMaskEvent(dsply, ExposureMask|MouseMask|KeyMask, &ev); - switch (ev.type) - { - case Expose: - exposed_c = find_client(ev.xexpose.window, FRAME); - if (exposed_c) - { - redraw(exposed_c); - } - break; - case MotionNotify: - old_button_clicked = button_clicked; - button_clicked = (unsigned int)(ev.xmotion.x / button_width); - if (button_clicked != old_button_clicked) - { - old_c = c; - for (i = 0, c = head_client; i < button_clicked; i++) - { - c = c->next; - } - lclick_taskbutton(old_c, c); - } - break; - case KeyPress: - XPutBackEvent(dsply, &ev); - break; - } - } - while (ev.type != ButtonPress && ev.type != ButtonRelease && ev.type != KeyPress); - - XUnmapWindow(dsply, constraint_win); - XDestroyWindow(dsply, constraint_win); - ungrab(); - - forget_hidden(); - } -} - -void redraw_taskbar(void) -{ - unsigned int i; - int button_startx, button_iwidth; - float button_width; - Client *c; - - button_width = get_button_width(); - XClearWindow(dsply, taskbar); - - if (showing_taskbar == 0) - { - return; - } - - for (c = head_client, i = 0; c != NULL; c = c->next, i++) - { - button_startx = (int)(i * button_width); - button_iwidth = (unsigned int)(((i + 1) * button_width) - button_startx); - if (button_startx != 0) - { - XDrawLine(dsply, taskbar, border_gc, button_startx - 1, 0, button_startx - 1, BARHEIGHT() - DEF_BORDERWIDTH); - } - if (c == focused_client) - { - XFillRectangle(dsply, taskbar, active_gc, button_startx, 0, button_iwidth, BARHEIGHT() - DEF_BORDERWIDTH); - } - else - { - XFillRectangle(dsply, taskbar, inactive_gc, button_startx, 0, button_iwidth, BARHEIGHT() - DEF_BORDERWIDTH); - } - if (!c->trans && c->name != NULL) - { - XftDrawString8(tbxftdraw, &xft_detail, xftfont, button_startx + SPACE, SPACE + xftfont->ascent, (unsigned char *)c->name, strlen(c->name)); - } - } -} - -float get_button_width(void) -{ - unsigned int nwins = 0; - Client *c = head_client; - while (c != NULL) - { - nwins++; - c = c->next; - } - return ((float)(DisplayWidth(dsply, screen) + DEF_BORDERWIDTH)) / nwins; -} - -void cycle_previous(void) -{ - Client *c = focused_client; - Client *original_c = c; - if (head_client != NULL && head_client->next != NULL) // at least 2 windows exist - { - if (c == NULL) - { - c = head_client; - } - if (c == head_client) - { - original_c = NULL; - } - do - { - if (c->next == NULL) - { - c = head_client; - } - else - { - c = c->next; - } - } - while (c->next != original_c); - lclick_taskbutton(NULL, c); - } -} - -void cycle_next(void) -{ - Client *c = focused_client; - if (head_client != NULL && head_client->next != NULL) // at least 2 windows exist - { - if (c == NULL || c->next == NULL) - { - c = head_client; - } - else c = c->next; - lclick_taskbutton(NULL, c); - } -}