# This is a BitKeeper generated patch for the following project: # Project Name: Lightweight Window Manager # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet lwm-1.01 -> lwm-1.01-jc1 # client.c 1.1 -> 1.4 # disp.c 1.1 -> 1.4 # lwm.c 1.1 -> 1.2 # lwm.h 1.1 -> 1.4 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/02/10 divert@adonix.(none) 1.2 # Import changeset # -------------------------------------------- # 02/02/10 jcopenha@marco.(none) 1.3 # Add LAUNCH and MENU button defines. # -------------------------------------------- # 02/02/11 jcopenha@marco.(none) 1.4 # close doesn't happen until releasing the mouse button # -------------------------------------------- # 02/02/11 jcopenha@marco.(none) 1.5 # oneliner to use DEFAULT_TERMINAL #define # -------------------------------------------- # 02/02/11 jcopenha@marco.(none) 1.6 # display current x,y pos when doing move/resize on windows # -------------------------------------------- # 02/02/11 jcopenha@marco.(none) 1.7 # changed the close square to a close X # -------------------------------------------- # 02/02/11 jcopenha@marco.(none) 1.8 # shrink the default border # -------------------------------------------- # diff -Nru a/client.c b/client.c --- a/client.c Mon Feb 11 14:53:51 2002 +++ b/client.c Mon Feb 11 14:53:51 2002 @@ -60,8 +60,15 @@ /* Draw the ``box''. */ if (active) { +#ifdef CLOSE_SQR XDrawRectangle(dpy, c->parent, c->screen->gc, quarter + 2, quarter, 2 * quarter, 2 * quarter); +#else + XDrawLine(dpy, c->parent, c->screen->gc, + quarter+2, quarter, (quarter+2)+(2*quarter), quarter+(2*quarter)); + XDrawLine(dpy, c->parent, c->screen->gc, + quarter+2, quarter+(2*quarter), (quarter+2)+(2*quarter), quarter); +#endif } /* Draw window title. */ @@ -115,6 +122,7 @@ c->wmcmaps = 0; c->accepts_focus = 1; c->next = clients; + c->needclose = False; /* Add to head of list of clients. */ return (clients = c); @@ -281,17 +289,20 @@ void Client_SizeFeedback(void) { int x, y; - char buf[4*2 + 3 + 1]; + char buf[4*4 + 3 + 5 + 1]; /* Make the popup 10% wider than the widest string it needs to show. */ - sprintf(buf, "%i x %i", current_screen->display_width, - current_screen->display_height); + sprintf(buf, "%i x %i (%i x %i)", current_screen->display_width, + current_screen->display_height, current->size.x, current->size.y); popup_width = XTextWidth(popup_font, buf, strlen(buf)); popup_width += popup_width/10; /* Put the popup in the right place to report on the window's size. */ - getMousePosition(&x, &y); - XMoveResizeWindow(dpy, current_screen->popup, x + 8, y + 8, + y = current->size.height / 2; + x = current->size.width / 2; + x = x - (popup_width / 2); + + XMoveResizeWindow(dpy, current_screen->popup, x+current->size.x, y+current->size.y, popup_width, popup_font->ascent + popup_font->descent + 1); XMapRaised(dpy, current_screen->popup); @@ -304,8 +315,8 @@ void size_expose(void) { - int width, height; - char buf[4*2 + 3 + 1]; + int width, height,x,y; + char buf[4*4 + 3 + 1 + 5]; width = current->size.width - 2*border; height = current->size.height - 2*border; @@ -327,10 +338,18 @@ if (current->size.height_inc != 0) height /= current->size.height_inc; - sprintf(buf, "%i x %i", width, height); + sprintf(buf, "%i x %i (%i x %i)", width, height, current->size.x, current->size.y); + y = current->size.height / 2; + x = current->size.width / 2; + x = x - (popup_width / 2); + + XMoveResizeWindow(dpy, current_screen->popup, x+current->size.x, y+current->size.y, + popup_width, popup_font->ascent + popup_font->descent + 1); + XDrawString(dpy, current_screen->popup, current_screen->size_gc, (popup_width - XTextWidth(popup_font, buf, strlen(buf))) / 2, popup_font->ascent + 1, buf, strlen(buf)); + } static void diff -Nru a/disp.c b/disp.c --- a/disp.c Mon Feb 11 14:53:51 2002 +++ b/disp.c Mon Feb 11 14:53:51 2002 @@ -126,7 +126,7 @@ /* The ``box''. */ quarter = (border + titleHeight()) / 4; if (e->x > (quarter + 2) && e->x < (3 + 3*quarter) && e->y > quarter && e->y <= 3*quarter) { - Client_Close(c); + c->needclose = True; return; } @@ -174,22 +174,36 @@ /* Deal with root window button presses. */ if (e->window == e->root) { - if (e->button == Button3) { + /* Make the menuhit and shell/launch buttons #defines */ + if(e->button == LAUNCH_BUTTON) { + shell(getScreenFromRoot(e->root), e->button, e->x, e->y); + } else if (e->button == MENU_BUTTON) { cmapfocus(0); menuhit(e); - } else { - shell(getScreenFromRoot(e->root), e->button, e->x, e->y); } } } static void buttonrelease(XEvent *ev) { + Client *c = NULL; + int quarter; + XButtonEvent *e = &ev->xbutton; + quarter = (border + titleHeight()) / 4; + c = Client_Get(e->window); + if (mode == wm_menu_up) menu_buttonrelease(ev); else if (mode == wm_reshaping) XUnmapWindow(dpy, current_screen->popup); + if(c && c->needclose) + if (e->x > (quarter + 2) && e->x < (3 + 3*quarter) && e->y > quarter && e->y <= 3*quarter) + Client_Close(c); + else + c->needclose = False; + + mode = wm_idle; } @@ -475,6 +489,10 @@ if (mode != wm_reshaping) return; getMousePosition(&pointer_x, &pointer_y); + + if(interacting_edge == ENone) { + Client_SizeFeedback(); + } if (interacting_edge != ENone) { nx = ox = current->size.x; diff -Nru a/lwm.c b/lwm.c --- a/lwm.c Mon Feb 11 14:53:51 2002 +++ b/lwm.c Mon Feb 11 14:53:51 2002 @@ -203,7 +203,8 @@ execl(sh, sh, "-c", command, 0); fprintf(stderr, "%s: can't exec \"%s -c %s\"\n", argv0, sh, command); - execlp("xterm", "xterm", 0); + /* we have it defined in lwm.h we might as well use it */ + execlp(DEFAULT_TERMINAL,DEFAULT_TERMINAL,0); exit(EXIT_FAILURE); case -1: /* Error. */ fprintf(stderr, "%s: couldn't fork\n", argv0); diff -Nru a/lwm.h b/lwm.h --- a/lwm.h Mon Feb 11 14:53:51 2002 +++ b/lwm.h Mon Feb 11 14:53:51 2002 @@ -10,11 +10,13 @@ #define DEFAULT_TITLE_FONT "-*-lucida-bold-r-normal-sans-14-*-*-*-p-*-iso8859-1" #define DEFAULT_POPUP_FONT "-*-lucida-medium-r-normal-sans-12-*-*-*-p-*-iso8859-1" #define DEFAULT_TERMINAL "xterm" -#define DEFAULT_BORDER 6 +#define DEFAULT_BORDER 3 -#define HIDE_BUTTON Button3 -#define MOVE_BUTTON Button2 -#define RESHAPE_BUTTON Button1 +#define HIDE_BUTTON Button3 +#define MOVE_BUTTON Button2 +#define RESHAPE_BUTTON Button1 +#define LAUNCH_BUTTON Button2 +#define MENU_BUTTON Button3 /* --- End of administrator-configurable defaults. --- */ @@ -104,6 +106,8 @@ int ncmapwins; Window * cmapwins; Colormap * wmcmaps; + + Bool needclose; };