Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!bloom-beacon!ardent.UUCP!jkh From: jkh@ardent.UUCP (Jordan K. Hubbard) Newsgroups: comp.windows.x Subject: (none) Message-ID: <8806160747.AA07003@ardent.ardent.com> Date: 16 Jun 88 07:47:25 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 1106 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'awm/Neaten.c' <<'END_OF_FILE' X#ident "%W% %G%" X X#ifndef lint static char *rcsid_Neaten_c = "$Header: Neaten.c,v 1.1 88/06/15 15:26:00 jkh Exp $"; X#endif lint X X#include "X11/copyright.h" X/* X * X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca. X * X * Copyright 1987 by Jordan Hubbard. X * X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Ardent Computer X * Corporation or Jordan Hubbard not be used in advertising or publicity X * pertaining to distribution of the software without specific, written X * prior permission. X * X */ X X/* X * MODIFICATION HISTORY X * X * 002 -- Jordan Hubbard, Ardent Computer. X * Changes to work with awm, specifically reparented windows. X */ X X#include "awm.h" X X#ifdef NEATEN X X#include "X11/Xutil.h" X#include "X11/cursorfont.h" X#include "neaten.ext.h" X static void GetIconHints(); static void GetName(); extern Boolean IsIcon(); extern int neaten_debug_level; X X#define TOP_LEVEL (awi->frame ? awi->frame : awi->client) X X/* ARGSUSED */ Boolean Neaten(window, mask, button, x, y) Window window; /* Event window. */ int mask; /* Button/key mask. */ int button; /* Button event detail. */ int x, y; /* Event mouse position. */ X{ X Window junk_window; X Window w; X Window icon_window; X Window stacktop; X Window *children; X XWindowAttributes attrs; X XSizeHints hints; X XWindowChanges wc; X Status rstatus; X char name[50]; X int junk; X int root_x, root_y; X int root_width, root_height; X int icon_x, icon_y; X int icon_width, icon_height; X int icon_border; X int window_x, window_y; X int window_width, window_height; X int rval; X int ix; X int iconic; X int tiled; X int adjustment; X int priority; X int priority_increment; X unsigned int nchildren; X unsigned int mapped_children = 0; X unsigned int opened_children = 0; X unsigned int wcmask; X Placement primary; X Placement secondary; X Boolean is_iconic; X Cursor rtlcursor; X XFontStruct *font; X GC gc; X AwmInfoPtr awi; X X Entry("Neaten") X X font = (XFontStruct *) XLoadQueryFont(dpy, "cursor"); X gc = DefaultGC(dpy, scr); X XSetFont(dpy, gc, font->fid); X X rtlcursor = XCreateFontCursor(dpy, XC_rtl_logo); X X XGrabPointer(dpy, RootWindow(dpy, scr), FALSE, (unsigned int) 0, X GrabModeAsync, GrabModeAsync, X (Window) None, rtlcursor, CurrentTime); X X if (AbsMinWidth == 0) X AbsMinWidth = DEFAULT_ABS_MIN; X if (AbsMinHeight == 0) X AbsMinHeight = DEFAULT_ABS_MIN; X X XGetGeometry(dpy, RootWindow(dpy, scr), &junk_window, X &root_x, &root_y, X &root_width, &root_height, X &junk, &junk); X X Neaten_Initialize(root_width+SEPARATION, X root_height+SEPARATION, X AbsMinWidth, AbsMinHeight); X X if (strcmp(PrimaryIconPlacement, "Closest") == 0) X primary = Place_Closest; X else if (strcmp(PrimaryIconPlacement, "Top") == 0) X primary = Place_Top; X else if (strcmp(PrimaryIconPlacement, "Bottom") == 0) X primary = Place_Bottom; X else if (strcmp(PrimaryIconPlacement, "Left") == 0) X primary = Place_Left; X else if (strcmp(PrimaryIconPlacement, "Right") == 0) X primary = Place_Right; X else X primary = Place_Top; X X if (strcmp(SecondaryIconPlacement, "Closest") == 0) X secondary = Place_Closest; X else if (strcmp(SecondaryIconPlacement, "Top") == 0) X secondary = Place_Top; X else if (strcmp(SecondaryIconPlacement, "Bottom") == 0) X secondary = Place_Bottom; X else if (strcmp(SecondaryIconPlacement, "Left") == 0) X secondary = Place_Left; X else if (strcmp(SecondaryIconPlacement, "Right") == 0) X secondary = Place_Right; X else if (strcmp(SecondaryIconPlacement, "Center") == 0) X secondary = Place_Center; X else X secondary = Place_Left; X X Neaten_Icon_Placement(primary, secondary); X X if (XQueryTree(dpy, RootWindow(dpy, scr), &junk_window, X &junk_window, &children, &nchildren)) X { X for (ix = 0; ix < nchildren; ix++) X { X XGetWindowAttributes(dpy, children[ix], &attrs); X X if ((attrs.map_state != IsUnmapped) && X (attrs.override_redirect == False) && X (awi = GetAwmInfo(children[ix]))) X { X w = children[ix]; X if (w != TOP_LEVEL && w != awi->icon) X continue; X mapped_children++; X X is_iconic = IsIcon(w, (Window *) NULL); X X if (is_iconic == TRUE) X { X window_x = window_y = X window_width = window_height = 0; X icon_x = attrs.x; X icon_y = attrs.y; X icon_width = attrs.width; X icon_height = attrs.height; X X adjustment = SEPARATION; X icon_width += adjustment; X icon_height += adjustment; X } X else X { X window_x = attrs.x; X window_y = attrs.y; X window_width = attrs.width; X window_height = attrs.height; X X window_x -= attrs.border_width; X window_y -= attrs.border_width; X X adjustment = (2 * attrs.border_width) + SEPARATION; X window_width += adjustment; X window_height += adjustment; X X GetIconHints(w, &icon_x, &icon_y, X &icon_width, &icon_height, &icon_border); X X icon_x -= icon_border; X icon_y -= icon_border; X icon_width += (2 * icon_border) + SEPARATION; X icon_height += (2 * icon_border) + SEPARATION; X X opened_children++; X stacktop = TOP_LEVEL; X } X X GetName(w, name); X if(neaten_debug_level) X { X printf("%s\ticonic = %s\n", X name, (is_iconic ? "TRUE" : "FALSE")); X printf("\ticon: x = %d y = %d width = %d height = %d\n", X icon_x, icon_y, icon_width, icon_height); X if (is_iconic != TRUE) X printf("\twindow: x = %d y = %d width = %d height = %d\n", X window_x, window_y, window_width, X window_height); X } X X Neaten_Identify((int) w, is_iconic, X NEATEN_TRUE, NEATEN_FALSE, X window_x, window_y, X window_width, window_height, X NEATEN_TRUE, NEATEN_FALSE, X icon_x, icon_y, X icon_width, icon_height, X (unsigned long) adjustment); X X rstatus = XGetNormalHints(dpy, w, &hints); X if (rstatus != (Status) 0 && is_iconic != TRUE) X { X if (hints.flags & PMinSize) X { X rval = Neaten_Set_Min((int) w, X hints.min_width+adjustment, X hints.min_height+adjustment); X if(neaten_debug_level) X printf("\tmin: width = %d height = %d status = %s\n", X hints.min_width, hints.min_height, X (rval ? "SUCCESS" : "FAILURE")); X } X if (hints.flags & PMaxSize) X { X rval = Neaten_Set_Max((int) w, X hints.max_width+adjustment, X hints.max_height+adjustment); X if(neaten_debug_level) X printf("\tmax: width = %d height = %d status = %s\n", X hints.max_width, hints.max_height, X (rval ? "SUCCESS" : "FAILURE")); X } X if (hints.flags & (USSize | PSize)) X { X rval = Neaten_Set_Desired((int) w, X hints.width+adjustment, X hints.height+adjustment); X if(neaten_debug_level) X printf("\tdes: width = %d height = %d status = %s\n", X hints.width, hints.height, X (rval ? "SUCCESS" : "FAILURE")); X } X X /* if no max hints are given, set the max to the X max of the desired and current size X */ X if (!(hints.flags & PMaxSize)) X { X int desired_width = hints.width+adjustment; X int desired_height = hints.height+adjustment; X X window_width = ((window_width > desired_width) X ? window_width : X desired_width); X window_height = ((window_height > desired_height) X ? window_height : X desired_height); X rval = Neaten_Set_Max((int) w, X window_width, X window_height); X if(neaten_debug_level) X printf("\tmax: width = %d height = %d status = %s\n", X window_width-adjustment, window_height-adjustment, X (rval ? "SUCCESS" : "FAILURE")); X } X } X } X } X X if (UsePriorities == TRUE) X { X priority = MIN_PRIORITY; X if (opened_children > 1) X priority_increment = (MAX_PRIORITY - MIN_PRIORITY) / X (opened_children - 1); X for (ix = 0; ix < nchildren; ix++) X { X w = children[ix]; X awi = GetAwmInfo(w); X if (!awi) X continue; X if (w != TOP_LEVEL && w != awi->icon) X continue; X is_iconic = IsIcon(w, (Window *) NULL); X X if (is_iconic != TRUE) X { X XGetWindowAttributes(dpy, w, &attrs); X if ((attrs.map_state != IsUnmapped) && X (attrs.override_redirect == False)) X { X Neaten_Set_Priorities((int) w, priority, priority); X if (neaten_debug_level) X { X GetName(w, name); X printf("%s: priority = %d\n", name, priority); X } X priority += priority_increment; X } X } X } X } X X if (FixTopOfStack == TRUE) X { X Neaten_Set_Options((int) stacktop, NEATEN_FALSE, NEATEN_TRUE); X if (neaten_debug_level) X { X GetName(stacktop, name); X printf("stacktop = %s\n", name); X } X } X X if(neaten_debug_level) X printf("mapped children = %d\topened_children = %d\n", X mapped_children, opened_children); X X Neaten_Desktop((RetainSize == FALSE), (KeepOpen == FALSE), Fill); X X for (ix = 0; ix < nchildren; ix++) X { X w = children[ix]; X awi = GetAwmInfo(w); X if (!awi) X continue; X if (w != TOP_LEVEL && w != awi->icon) X continue; X if (Neaten_Get_Geometry((int) w, &iconic, &tiled, X &window_x, &window_y, X &window_width, &window_height, X &(unsigned long) adjustment) == 0) X continue; X GetName(w, name); X if(neaten_debug_level) X { X printf("%s iconic = %s tiled = %s\n", name, X (iconic ? "TRUE" : "FALSE"), X (tiled ? "TRUE" : "FALSE")); X printf(" x = %d, y = %d, width = %d, height = %d\n", X window_x, window_y, window_width, window_height); X } X X wc.x = window_x; X wc.y = window_y; X wc.width = window_width; X wc.height = window_height; X wcmask = CWX | CWY | CWWidth | CWHeight; X X if (iconic == NEATEN_TRUE) X { X is_iconic = IsIcon(w, &icon_window); X if (is_iconic == TRUE) X { X wc.width -= adjustment; X wc.height -= adjustment; X X XConfigureWindow(dpy, w, wcmask, &wc); X if(tiled != NEATEN_TRUE) X XRaiseWindow(dpy, w); X } X else X { X /* have to go to the server to get the info, this X could have been avoided if the the variable X adjustment was a pointer to a structure that X contained the information for the icon and the X information for the window. However, I chose X not to mess with all that memory management X */ X GetIconHints(w, &icon_x, &icon_y, X &icon_width, &icon_height, &icon_border); X X wc.x -= icon_border; X wc.y -= icon_border; X wc.width -= (2 * icon_border) + SEPARATION; X wc.height -= (2 * icon_border) + SEPARATION; X X XAddToSaveSet(dpy, w); X XUnmapWindow(dpy, TOP_LEVEL); X XConfigureWindow(icon_window, wcmask, &wc); X XMapWindow(dpy, icon_window); X if (tiled != NEATEN_TRUE) X XRaiseWindow(dpy, icon_window); X } X } X else X { X wc.width -= adjustment; X wc.height -= adjustment; X adjustment -= SEPARATION; X wc.x += adjustment/2; X wc.y += adjustment/2; X /* I think this will be the outer win */ X ConfigureWindow(w, wcmask, &wc); X if(tiled != NEATEN_TRUE) X XRaiseWindow(dpy, TOP_LEVEL); X } X } X X if (FixTopOfStack == TRUE) X XRaiseWindow(dpy, stacktop); X X XFree(children); X } X X XBell(dpy, VOLUME_PERCENTAGE(Volume)); X XUngrabPointer(dpy, CurrentTime); X Leave(FALSE) X} X static void X GetIconHints(window, x, y, width, height, border) Window window; int *x, *y, *width, *height, *border; X{ X Window root; X XWMHints *wmhints; X XWindowAttributes attrs; X int junk; X X *border = *x = *y = 0; X /* X * Process window manager hints. X */ X if (wmhints = XGetWMHints(dpy, window)) X { X if (wmhints->flags&IconWindowHint) X { X XGetWindowAttributes(dpy, wmhints->icon_window, &attrs); X *x = attrs.x; X *y = attrs.y; X *width = attrs.width; X *height = attrs.height; X *border = attrs.border_width; X } X else if (wmhints->flags&IconPixmapHint) X { X XGetWindowAttributes(dpy, wmhints->icon_pixmap, &attrs); X *width = attrs.width; X *height = attrs.height; X } X else X { X GetDefaultSize(window, width, height); X } X } X else X { X GetDefaultSize(window, width, height); X } X X /* X * Fix up sizes by padding. X */ X if (!wmhints || !(wmhints->flags&(IconPixmapHint|IconWindowHint))) { X *width += (HIconPad << 1); X *height += (VIconPad << 1); X } X X if (wmhints && (wmhints->flags&IconPositionHint)) { X *x = wmhints->icon_x; X *y = wmhints->icon_y; X } X} X static void X GetName(w, name) Window w; char *name; X{ X Status rstatus; X char *s = (char *) NULL; X X X rstatus = XFetchName(dpy, w, &s); X X if (rstatus != (Status) 0 && s != (char *) NULL) X { X strcpy(name, s); X XFree(s); X } X else X { X strcpy(name, "UNKNOWN"); X } X} X void NeatenDebug(window, left, top, width, height, adjustment) int window; int left, top; int width, height; unsigned long adjustment; X{ X Window w = (Window) window; X X left += (int) ((float)adjustment/2.0); X top += (int) ((float)adjustment/2.0); X X width -= adjustment; X height -= adjustment; X X XMoveResizeWindow(dpy, w, left, top, width, height); X XFlush(dpy); X} X#else /* NEATEN not installed */ Boolean Neaten(window, mask, button, x, y) Window window; /* Event window. */ int mask; /* Button/key mask. */ int button; /* Button event detail. */ int x, y; /* Event mouse position. */ X{ X fprintf(stderr, "awm: Warning: Neaten package not installed in "); X fprintf(stderr, "this version of of awm.\n"); X} X#endif NEATEN END_OF_FILE if test 14783 -ne `wc -c <'awm/Neaten.c'`; then echo shar: \"'awm/Neaten.c'\" unpacked with wrong size! fi # end of 'awm/Neaten.c' fi if test -f 'awm/Resize.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'awm/Resize.c'\" else echo shar: Extracting \"'awm/Resize.c'\" \(15352 characters\) sed "s/^X//" >'awm/Resize.c' <<'END_OF_FILE' X#ident "%W% %G%" X X#ifndef lint static char *rcsid_Resize_c = "$Header: Resize.c,v 1.1 88/06/15 15:01:04 jkh Exp $"; X#endif lint X X#include "X11/copyright.h" X/* X * X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca. X * X * Copyright 1987 by Jordan Hubbard. X * X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Ardent Computer X * Corporation or Jordan Hubbard not be used in advertising or publicity X * pertaining to distribution of the software without specific, written X * prior permission. X * X */ X X/* X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Digital Equipment X * Corporation not be used in advertising or publicity pertaining to X * distribution of the software without specific, written prior permission. X * X * X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X * SOFTWARE. X */ X X/* X * MODIFICATION HISTORY X * X * 000 -- M. Gancarz, DEC Ultrix Engineering Group X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group X * Convert to X11 X * 002 -- Jordan Hubbard, U.C. berkeley. X * Added alternate placement of resize window, code for title bar X * support. X */ X X#include "awm.h" X#include "X11/Xutil.h" X X#define max(a,b) ( (a) > (b) ? (a) : (b) ) X#define min(a,b) ( (a) > (b) ? (b) : (a) ) X#define makemult(a, b) ((b==1) ? (a) : (((int)((a) / (b))) * (b)) ) X Boolean Resize(window, mask, button, x0, y0) Window window; /* Event window. */ int mask; /* Button/key mask. */ int button; /* Button event detail. */ int x0, y0; /* Event mouse position. */ X{ X XWindowAttributes client_info; /* client window info. */ X XWindowAttributes frame_info; /* frame window info */ X int x1, y1; /* fixed box corner */ X int x2, y2; /* moving box corner */ X int x, y; X int xinc, yinc; X int minwidth, minheight; X int maxwidth, maxheight; X int defwidth, defheight; X int ox, oy; /* which quadrant of window */ X int pop_x, pop_y; /* location of pop window */ X int hsize, vsize; /* dynamic size */ X int delta; X int junk_x, junk_y; X int ptrmask; /* pointer status word */ X int num_vectors; /* Number of vectors to XDraw. */ X Window assoc; /* Window represented by the icon. */ X Window sub_win; /* Mouse query sub window. */ X Window root; /* Root query window. */ X XEvent button_event, *b_ev; /* Button event packet. */ X XSegment box[MAX_BOX_VECTORS]; /* Box drawing vertex buffer. */ X XSegment zap[MAX_ZAP_VECTORS]; /* Zap drawing vertex buffer. */ X Boolean stop; /* Should the window stop changing? */ X XSizeHints sizehints; X XWindowChanges values; X int width_offset, height_offset; /* to subtract if resize increments */ X int x_offset, y_offset; /* add to pointer to get anchor */ X AwmInfoPtr awi; X int (*storegrid_func)(); /* which StoreGrid routine to use */ X int (*storebox_func)(); /* which StoreBox routing to use */ X int buttonConfirmEvent; X X Entry("Resize") X X /* X * Do nothing if the event window is the root window. X */ X if (window == RootWindow(dpy, scr)) X Leave(FALSE) X X /* X * Gather info about the event window. X */ X awi = GetAwmInfo(window); X if (!awi) X Leave(FALSE) X /* X * Do not resize an icon window. X */ X if (window == awi->icon) X Leave(FALSE) X X window = awi->client; X b_ev = &button_event; X buttonConfirmEvent = ButtonRelease; X X status = XGetWindowAttributes(dpy, window, &client_info); X if (status == FAILURE) X Leave(FALSE) X X if (awi->frame) { /* we have to compensate */ X status = XGetWindowAttributes(dpy, awi->frame, &frame_info); X if (status == FAILURE) X Leave(FALSE) X client_info.x = frame_info.x + (BContext ? BContext + 1 : 0); X client_info.y = frame_info.y + titleHeight + 2; X } X X /* X * Clear the vector buffers. X */ X bzero(box, sizeof(box)); X if (Zap) X bzero(zap, sizeof(zap)); X storegrid_func = StoreGridBox; X storebox_func = StoreBox; X X /* X * If we are here then we have a resize operation in progress. X */ X X /* X * Turn on the resize cursor. X */ X grab_pointer(); X X /* X * calculate fixed point (x1, y1) and varying point (x2, y2). X */ X hsize = defwidth = client_info.width; X vsize = defheight = client_info.height; X x1 = client_info.x; X y1 = client_info.y; X x2 = x1 + hsize; X y2 = y1 + vsize; X X /* X * Get the event window resize hint. X */ X sizehints.flags = 0; X XGetSizeHints(dpy, window, &sizehints, XA_WM_NORMAL_HINTS); X CheckConsistency(&sizehints); X X /* until there are better WM_HINTS, we'll assume that the client's X * minimum width and height are the appropriate offsets to subtract X * when resizing with an explicit resize increment. X */ X if ((sizehints.flags & PMinSize) && (sizehints.flags & PResizeInc)) { X width_offset = sizehints.min_width; X height_offset = sizehints.min_height; X } else X width_offset = height_offset = 0; X X /* X * decide what resize mode we are in. Always rubberband if window X * is too small. X */ X if (client_info.width > 2 && client_info.height > 2) { X ox = ((x0 - client_info.x) * 3) / client_info.width; X oy = ((y0 - client_info.y) * 3) / client_info.height; X if ((ox + oy) & 1) { X if (ox & 1) { X /* fix up size hints so that we will never change width */ X sizehints.min_width = sizehints.max_width = X client_info.width; X if ((sizehints.flags & PMinSize) == 0) { X sizehints.min_height = 0; X sizehints.flags |= PMinSize; X } X if ((sizehints.flags & PMaxSize) == 0) { X sizehints.max_height = DisplayHeight(dpy, scr); X sizehints.flags |= PMaxSize; X } X } X if (oy & 1) { X /* fix up size hints so that we will never change height */ X sizehints.min_height = sizehints.max_height = X client_info.height; X if ((sizehints.flags & PMinSize)==0) { X sizehints.min_width = 0; X sizehints.flags |= PMinSize; X } X if ((sizehints.flags & PMaxSize)==0) { X sizehints.max_width = DisplayWidth(dpy, scr); X sizehints.flags |= PMaxSize; X } X } X } X } X else ox = oy = 2; X /* change fixed point to one that shouldn't move */ X if (oy == 0) { X y = y1; y1 = y2; y2 = y; X } X if (ox == 0) { X x = x1; x1 = x2; x2 = x; X } X if (sizehints.flags & PMinSize) { X minwidth = sizehints.min_width; X minheight = sizehints.min_height; X } else { X minwidth = 0; X minheight = 0; X } X if (sizehints.flags & PMaxSize) { X maxwidth = max(sizehints.max_width, minwidth); X maxheight = max(sizehints.max_height, minheight); X } else { X maxwidth = DisplayWidth(dpy, scr); X maxheight = DisplayHeight(dpy, scr); X } X if (sizehints.flags & PResizeInc) { X xinc = sizehints.width_inc; X yinc = sizehints.height_inc; X } else { X xinc = 1; X yinc = 1; X } X switch (ox) { X case 0: X pop_x = x1 - PWidth; X break; X case 1: X pop_x = x1 + (hsize - PWidth) / 2; X break; X case 2: X pop_x = x1; X break; X } X switch (oy) { X case 0: X pop_y = y1 - PHeight; X break; X case 1: X pop_y = y1 + (vsize - PHeight) / 2; X break; X case 2: X pop_y = y1; X break; X } X /* X * Double expose on the target window is too expensive for some reason X * or another. Paint the popup window in the upper left hand X * corner of the screen if RootResizeBox is FALSE. This is also X * more-or-less consistent with the position of the map request popup. X */ X if (RootResizeBox == TRUE) X values.x = values.y = 0; X else { X if (pop_x < 0 || pop_x > (DisplayWidth(dpy, scr) - PWidth)) X pop_x = 0; X if (pop_y < 0 || pop_y > (DisplayHeight(dpy, scr) - PHeight)) X pop_y = 0; X values.x = pop_x; X values.y = pop_y; X } X values.stack_mode = Above; X XConfigureWindow(dpy, Pop, CWX|CWY|CWStackMode, &values); X XMapWindow(dpy, Pop); X if (Grid) { X num_vectors = (*storegrid_func)(box, X MIN(x1, x2), MIN(y1, y2), X MAX(x1, x2), MAX(y1, y2)); X } X else { X num_vectors = (*storebox_func)(box, X MIN(x1, x2), MIN(y1, y2), X MAX(x1, x2), MAX(y1, y2)); X } X X /* X * If we freeze the server, then we will draw solid X * lines instead of flickering ones during resizing. X */ X if (Freeze) X XGrabServer(dpy); X /* protect us from ourselves */ X Snatched = True; X /* X * Process any pending exposure events before drawing the box. X */ X while (QLength(dpy) > 0) { X XPeekEvent(dpy, b_ev); X if (b_ev->xany.window == RootWindow(dpy, scr)) X break; X GetButton(b_ev); X } X if (ResizeRelative) { X x_offset = x2 - x0; X y_offset = y2 - y0; X } X else X x_offset = y_offset = 0; X X /* X * Now draw the box. X */ X DrawBox(); X Frozen = window; X X stop = FALSE; X x = -1; y = -1; X X while (!stop) { X if (x != x2 || y != y2) { X x = x2; y = y2; X X /* X * If we've frozen the server, then erase X * the old box. X */ X if (Freeze) X DrawBox(); X X if (Grid) { X num_vectors = (*storegrid_func)(box, X MIN(x1, x), MIN(y1, y), X MAX(x1, x), MAX(y1, y)); X } X else { X num_vectors = (*storebox_func)(box, X MIN(x1, x), MIN(y1, y), X MAX(x1, x), MAX(y1, y)); X } X X if (Freeze) X DrawBox(); X X { X int Hsize = (hsize - width_offset) / xinc; X int Vsize = (vsize - height_offset) / yinc; X int pos = 4; X PText[0] = (Hsize>99) ? (Hsize / 100 + '0') : ' '; X PText[1] = (Hsize>9) ? ((Hsize / 10) % 10 + '0') : ' '; X PText[2] = Hsize % 10 + '0'; X if (Vsize>99) PText[pos++] = Vsize / 100 + '0'; X if (Vsize>9) PText[pos++] = (Vsize / 10) % 10 + '0'; X PText[pos++] = Vsize % 10 + '0'; X while (pos<7) PText[pos++] = ' '; X } X /* X * If the font is not fixed width we have to X * clear the window to guarantee that the characters X * that were there before are erased. X */ X if (!(PFontInfo->per_char)) X XClearWindow(dpy, Pop); X XDrawImageString( X dpy, Pop, PopGC, X PPadding, PPadding+PFontInfo->ascent, X PText, PTextSize); X } X if (!Freeze) { X DrawBox(); X DrawBox(); X } X X if (XPending(dpy) && !ProcessRequests(box, num_vectors) && X GetButton(b_ev)) { X if ((b_ev->xany.type != ButtonPress) && X (b_ev->xany.type != ButtonRelease)) X continue; /* spurious menu event... */ X X if (Freeze) { X DrawBox(); X Frozen = (Window)0; X XUngrabServer(dpy); X } X X if (b_ev->xany.type == buttonConfirmEvent && X b_ev->xbutton.button == button) X stop = TRUE; X else { X XUnmapWindow(dpy, Pop); X ResetCursor(button); X Snatched = False; X ungrab_pointer(); X Leave(TRUE) X } X } X else { X XQueryPointer(dpy, RootWindow(dpy, scr), &root, X &sub_win, &x2, &y2, &junk_x, &junk_y, &ptrmask); X x2 += x_offset; /* get to anchor point */ X y2 += y_offset; X } X hsize = max(min(abs (x2 - x1), maxwidth), minwidth); X hsize = makemult(hsize - minwidth, xinc) + minwidth; X X vsize = max(min(abs(y2 - y1), maxheight), minheight); X vsize = makemult(vsize - minheight, yinc) + minheight; X if (sizehints.flags & PAspect) { X if ((hsize * sizehints.max_aspect.y > X vsize * sizehints.max_aspect.x)) { X delta = makemult((hsize * sizehints.max_aspect.y / X sizehints.max_aspect.x) - vsize, X yinc); X if ((vsize + delta <= maxheight)) X vsize += delta; X else { X delta = makemult(hsize - X (sizehints.max_aspect.x * X vsize/sizehints.max_aspect.y), X xinc); X if (hsize - delta >= minwidth) X hsize -= delta; X } X } X if (hsize * sizehints.min_aspect.y < vsize * X sizehints.min_aspect.x) { X delta = makemult((sizehints.min_aspect.x * X vsize/sizehints.min_aspect.y) - hsize, X xinc); X if (hsize + delta <= maxwidth) X hsize += delta; X else { X delta = makemult(vsize - X (hsize*sizehints.min_aspect.y / X sizehints.min_aspect.x), X yinc); X if (vsize - delta >= minheight) X vsize -= delta; X } X } X X } X if (ox == 0) X x2 = x1 - hsize; X else X x2 = x1 + hsize; X X if (oy == 0) X y2 = y1 - vsize; X else X y2 = y1 + vsize; X X } X if (x2 < x1) { X x = x1; x1 = x2; x2 = x; X } X if (y2 < y1) { X y = y1; y1 = y2; y2 = y; X } X XUnmapWindow(dpy, Pop); X if ((x1 !=client_info.x) || (y1 != client_info.y) || X (hsize != client_info.width) || X (vsize != client_info.height)) { X XWindowChanges xwc; X X xwc.x = x1; X xwc.y = y1; X xwc.width = hsize; X xwc.height = vsize; X ConfigureWindow(window, CWX | CWY | CWHeight | CWWidth, &xwc); X } X Snatched = False; X ungrab_pointer(); X Leave(TRUE) X} X CheckConsistency(hints) XXSizeHints *hints; X{ X Entry("CheckConsistency") X X if (hints->min_height < 0) X hints->min_height = 0; X if (hints->min_width < 0) X hints->min_width = 0; X X if (hints->max_height <= 0 || hints->max_width <= 0) X hints->flags &= ~PMaxSize; X X hints->min_height = min(DisplayHeight(dpy, scr), hints->min_height); X hints->min_width = min(DisplayWidth(dpy, scr), hints->min_width); X X hints->max_height = min(DisplayHeight(dpy, scr), hints->max_height); X hints->max_width = min(DisplayWidth(dpy, scr), hints->max_width); X X if ((hints->flags & PMinSize) && (hints->flags & PMaxSize) && X ((hints->min_height > hints->max_height) || X (hints->min_width > hints->max_width))) X hints->flags &= ~(PMinSize|PMaxSize); X X if ((hints->flags & PAspect) && X (hints->min_aspect.x * hints->max_aspect.y > X hints->max_aspect.x * hints->min_aspect.y)) X hints->flags &= ~(PAspect); X Leave_void X} END_OF_FILE if test 15352 -ne `wc -c <'awm/Resize.c'`; then echo shar: \"'awm/Resize.c'\" unpacked with wrong size! fi # end of 'awm/Resize.c' fi echo shar: End of archive 10 \(of 17\). cp /dev/null ark10isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 17 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0