1 /*****************************************************************************/
2 /** Copyright 1988 by Evans & Sutherland Computer Corporation, **/
3 /** Salt Lake City, Utah **/
4 /** Portions Copyright 1989 by the Massachusetts Institute of Technology **/
5 /** Cambridge, Massachusetts **/
7 /** All Rights Reserved **/
9 /** Permission to use, copy, modify, and distribute this software and **/
10 /** its documentation for any purpose and without fee is hereby **/
11 /** granted, provided that the above copyright notice appear in all **/
12 /** copies and that both that copyright notice and this permis- **/
13 /** sion notice appear in supporting documentation, and that the **/
14 /** names of Evans & Sutherland and M.I.T. not be used in advertising **/
15 /** in publicity pertaining to distribution of the software without **/
16 /** specific, written prior permission. **/
18 /** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/
19 /** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/
20 /** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/
21 /** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/
22 /** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/
23 /** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/
24 /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/
25 /** OR PERFORMANCE OF THIS SOFTWARE. **/
26 /*****************************************************************************/
29 /***********************************************************************
31 * $XConsortium: resize.c,v 1.80 91/05/11 17:35:42 dave Exp $
33 * window resizing borrowed from the "wm" window manager
35 * 11-Dec-87 Thomas E. LaStrange File created
37 ***********************************************************************/
44 #include "add_window.h"
50 #define MINHEIGHT 0 /* had been 32 */
51 #define MINWIDTH 0 /* had been 60 */
53 static int dragx; /* all these variables are used */
54 static int dragy; /* in resize operations */
56 static int dragHeight;
64 static int clampBottom;
66 static int clampRight;
70 static int last_width;
71 static int last_height;
73 static int resize_context;
75 /* set in menus.c:ExecuteFunction(), cleared in *EndResize() - djhjr - 9/5/98 */
76 int resizing_window = 0;
79 void PaintBorderAndTitlebar();
82 static void DoVirtualMoveResize();
85 void ResizeTwmWindowContents();
88 static void SetVirtualDesktopIncrs();
89 static void EndResizeAdjPointer();
91 static void do_auto_clamp (tmp_win, evp)
96 int x, y, h, v, junkbw;
97 unsigned int junkMask;
101 x = evp->xbutton.x_root;
102 y = evp->xbutton.y_root;
105 x = evp->xkey.x_root;
106 y = evp->xkey.y_root;
109 if (!XQueryPointer (dpy, Scr->Root, &junkRoot, &junkRoot,
110 &x, &y, &junkbw, &junkbw, &junkMask))
114 h = ((x - dragx) / (dragWidth < 3 ? 1 : (dragWidth / 3)));
115 v = ((y - dragy - tmp_win->title_height) /
116 (dragHeight < 3 ? 1 : (dragHeight / 3)));
120 clampDX = (x - dragx);
123 clampDX = (x - dragx - dragWidth);
128 clampDY = (y - dragy);
131 clampDY = (y - dragy - dragHeight);
136 /***********************************************************************
139 * StartResize - begin a window resize operation
142 * ev - the event structure (button press)
143 * tmp_win - the TwmWindow pointer
144 * fromtitlebar - action invoked from titlebar button
146 ***********************************************************************
150 StartResize(evp, tmp_win, fromtitlebar, context)
157 unsigned int junkbw, junkDepth;
159 resize_context = context;
161 SetVirtualDesktopIncrs(tmp_win); /* djhjr - 9/13/02 */
163 if (context == C_VIRTUAL_WIN)
164 ResizeWindow = tmp_win->VirtualDesktopDisplayWindow;
166 ResizeWindow = tmp_win->frame;
170 if (!Scr->NoGrabServer)
173 /* added test - djhjr - 4/7/98 */
174 if (!tmp_win->opaque_resize)
177 if (context == C_VIRTUAL_WIN)
178 XGrabPointer(dpy, Scr->VirtualDesktopDisplay, True,
179 ButtonPressMask | ButtonReleaseMask |
180 ButtonMotionMask | PointerMotionHintMask,
181 GrabModeAsync, GrabModeAsync,
182 Scr->Root, Scr->ResizeCursor, CurrentTime);
184 XGrabPointer(dpy, Scr->Root, True,
185 ButtonPressMask | ButtonReleaseMask |
186 ButtonMotionMask | PointerMotionHintMask,
187 GrabModeAsync, GrabModeAsync,
188 Scr->Root, Scr->ResizeCursor, CurrentTime);
190 XGetGeometry(dpy, (Drawable) ResizeWindow, &junkRoot,
191 &dragx, &dragy, (unsigned int *)&dragWidth, (unsigned int *)&dragHeight, &junkbw,
194 if (context != C_VIRTUAL_WIN) {
195 dragx += tmp_win->frame_bw;
196 dragy += tmp_win->frame_bw;
200 origWidth = dragWidth;
201 origHeight = dragHeight;
202 clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0;
204 if (Scr->AutoRelativeResize && !fromtitlebar)
205 do_auto_clamp (tmp_win, evp);
207 /* use initialized size... djhjr - 5/9/96
208 Scr->SizeStringOffset = SIZE_HINDENT;
209 XResizeWindow (dpy, Scr->SizeWindow,
210 Scr->SizeStringWidth + SIZE_HINDENT * 2,
211 Scr->SizeFont.height + SIZE_VINDENT * 2);
214 XMapRaised(dpy, Scr->SizeWindow);
215 if (!tmp_win->opaque_resize) InstallRootColormap();
218 DisplaySize(tmp_win, origWidth, origHeight);
220 if (resize_context == C_VIRTUAL_WIN)
221 MoveOutline (Scr->VirtualDesktopDisplay, dragx,
224 tmp_win->frame_bw, 0);
226 /* added this 'if ... else' - djhjr - 4/6/98 */
227 if (tmp_win->opaque_resize)
229 SetupWindow (tmp_win,
230 dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
231 dragWidth, dragHeight, -1);
232 PaintBorderAndTitlebar(tmp_win);
235 MoveOutline (Scr->Root, dragx - tmp_win->frame_bw,
236 dragy - tmp_win->frame_bw, dragWidth + 2 * tmp_win->frame_bw,
237 dragHeight + 2 * tmp_win->frame_bw,
239 tmp_win->frame_bw, tmp_win->title_height);
241 tmp_win->frame_bw, tmp_win->title_height + tmp_win->frame_bw3D);
246 /* added the passed 'context' - djhjr - 2/22/99 */
248 MenuStartResize(tmp_win, x, y, w, h, context)
253 /* djhjr - 2/22/99 */
254 resize_context = context;
256 SetVirtualDesktopIncrs(tmp_win); /* djhjr - 9/13/02 */
260 if (!Scr->NoGrabServer)
263 /* added test - djhjr - 4/7/98 */
264 if (!tmp_win->opaque_resize)
267 XGrabPointer(dpy, Scr->Root, True,
268 ButtonPressMask | ButtonMotionMask | PointerMotionMask,
269 GrabModeAsync, GrabModeAsync,
270 Scr->Root, Scr->ResizeCursor, CurrentTime);
271 dragx = x + tmp_win->frame_bw;
272 dragy = y + tmp_win->frame_bw;
275 dragWidth = origWidth = w; /* - 2 * tmp_win->frame_bw; */
276 dragHeight = origHeight = h; /* - 2 * tmp_win->frame_bw; */
277 clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0;
281 /* use initialized size... djhjr - 5/9/96
282 Scr->SizeStringOffset = SIZE_HINDENT;
283 XResizeWindow (dpy, Scr->SizeWindow,
284 Scr->SizeStringWidth + SIZE_HINDENT * 2,
285 Scr->SizeFont.height + SIZE_VINDENT * 2);
288 XMapRaised(dpy, Scr->SizeWindow);
289 if (!tmp_win->opaque_resize) InstallRootColormap();
290 DisplaySize(tmp_win, origWidth, origHeight);
292 /* added this 'if ... else' - djhjr - 4/6/98 */
293 if (tmp_win->opaque_resize)
295 SetupWindow (tmp_win,
296 dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
297 dragWidth, dragHeight, -1);
298 PaintBorderAndTitlebar(tmp_win);
301 MoveOutline (Scr->Root, dragx - tmp_win->frame_bw,
302 dragy - tmp_win->frame_bw,
303 dragWidth + 2 * tmp_win->frame_bw,
304 dragHeight + 2 * tmp_win->frame_bw,
306 tmp_win->frame_bw, tmp_win->title_height);
308 tmp_win->frame_bw, tmp_win->title_height + tmp_win->frame_bw3D);
311 /***********************************************************************
314 * AddStartResize - begin a windorew resize operation from AddWindow
317 * tmp_win - the TwmWindow pointer
319 ***********************************************************************
323 AddStartResize(tmp_win, x, y, w, h)
327 /* djhjr - 2/22/99 */
328 resize_context = C_WINDOW;
330 SetVirtualDesktopIncrs(tmp_win); /* djhjr - 9/13/02 */
334 if (!Scr->NoGrabServer)
337 /* added test - djhjr - 4/7/98 */
338 if (!tmp_win->opaque_resize)
342 XGrabPointer(dpy, Scr->Root, True,
343 ButtonReleaseMask | ButtonMotionMask | PointerMotionHintMask,
344 GrabModeAsync, GrabModeAsync,
345 Scr->Root, Scr->ResizeCursor, CurrentTime);
347 dragx = x + tmp_win->frame_bw;
348 dragy = y + tmp_win->frame_bw;
351 dragWidth = origWidth = w - 2 * tmp_win->frame_bw;
352 dragHeight = origHeight = h - 2 * tmp_win->frame_bw;
353 clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0;
355 if (Scr->AutoRelativeResize) {
356 clampRight = clampBottom = 1;
361 DisplaySize(tmp_win, origWidth, origHeight);
367 * Functionally identical with DoResize(), except that this
368 * handles a virtual window differently, but it isn't used anyway.
373 MenuDoResize(x_root, y_root, tmp_win)
386 int delta = y_root - dragy;
387 if (dragHeight - delta < MINHEIGHT) {
388 delta = dragHeight - MINHEIGHT;
395 else if (y_root <= dragy/* ||
396 y_root == findRootInfo(root)->rooty*/) {
398 dragHeight = origy + origHeight -
406 int delta = x_root - dragx;
407 if (dragWidth - delta < MINWIDTH) {
408 delta = dragWidth - MINWIDTH;
415 else if (x_root <= dragx/* ||
416 x_root == findRootInfo(root)->rootx*/) {
418 dragWidth = origx + origWidth -
426 int delta = y_root - dragy - dragHeight;
427 if (dragHeight + delta < MINHEIGHT) {
428 delta = MINHEIGHT - dragHeight;
434 else if (y_root >= dragy + dragHeight - 1/* ||
435 y_root == findRootInfo(root)->rooty
436 + findRootInfo(root)->rootheight - 1*/) {
438 dragHeight = 1 + y_root - dragy;
445 int delta = x_root - dragx - dragWidth;
446 if (dragWidth + delta < MINWIDTH) {
447 delta = MINWIDTH - dragWidth;
453 else if (x_root >= dragx + dragWidth - 1/* ||
454 x_root == findRootInfo(root)->rootx +
455 findRootInfo(root)->rootwidth - 1*/) {
457 dragWidth = 1 + x_root - origx;
465 ConstrainSize (tmp_win, &dragWidth, &dragHeight);
467 dragx = origx + origWidth - dragWidth;
469 dragy = origy + origHeight - dragHeight;
471 if (resize_context == C_VIRTUAL_WIN)
472 MoveOutline(Scr->VirtualDesktopDisplay,
477 tmp_win->frame_bw, 0);
479 /* added this 'if ... else' - djhjr - 4/6/98 */
480 if (tmp_win->opaque_resize)
482 SetupWindow (tmp_win,
483 dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
484 dragWidth, dragHeight, -1);
486 /* force the redraw of a door - djhjr - 2/28/99 */
490 if (XFindContext(dpy, tmp_win->w, DoorContext, (caddr_t *)&door) != XCNOENT)
491 RedoDoorName(tmp_win, door);
494 /* force the redraw of the desktop - djhjr - 2/28/99 */
495 if (!strcmp(tmp_win->class.res_class, VTWM_DESKTOP_CLASS))
497 ResizeDesktopDisplay(dragWidth, dragHeight);
499 Draw3DBorder(Scr->VirtualDesktopDisplayOuter, 0, 0,
500 Scr->VirtualDesktopMaxWidth + (Scr->VirtualDesktopBevelWidth * 2),
501 Scr->VirtualDesktopMaxHeight + (Scr->VirtualDesktopBevelWidth * 2),
502 Scr->VirtualDesktopBevelWidth, Scr->VirtualC, off, False, False);
505 /* force the redraw of an icon manager - djhjr - 3/1/99 */
506 if (tmp_win->iconmgr)
509 int ncols = tmp_win->iconmgrp->cur_columns;
510 if (ncols == 0) ncols = 1;
513 tmp_win->iconmgrp->width = (int) ((dragWidth *
515 tmp_win->iconmgrp->width = (int) (((dragWidth - 2 * tmp_win->frame_bw3D) *
517 (long) tmp_win->iconmgrp->columns)
519 PackIconManager(tmp_win->iconmgrp);
521 list = tmp_win->iconmgrp->first;
524 RedoListWindow(list->twm);
529 PaintBorderAndTitlebar(tmp_win);
531 /* djhjr - 4/15/98 */
532 /* added '&& !resizing_window' - djhjr - 11/7/03 */
533 if (!Scr->NoGrabServer && !resizing_window)
535 /* these let the application window be drawn - djhjr - 4/14/98 */
536 XUngrabServer(dpy); XSync(dpy, 0); XGrabServer(dpy);
540 MoveOutline(Scr->Root,
541 dragx - tmp_win->frame_bw,
542 dragy - tmp_win->frame_bw,
543 dragWidth + 2 * tmp_win->frame_bw,
544 dragHeight + 2 * tmp_win->frame_bw,
546 tmp_win->frame_bw, tmp_win->title_height);
548 tmp_win->frame_bw, tmp_win->title_height + tmp_win->frame_bw3D);
550 /* djhjr - 4/17/98 */
551 if (Scr->VirtualReceivesMotionEvents)
552 DoVirtualMoveResize(tmp_win, dragx, dragy, dragWidth, dragHeight);
556 DisplaySize(tmp_win, dragWidth, dragHeight);
560 /***********************************************************************
563 * DoResize - move the rubberband around. This is called for
564 * each motion event when we are resizing
567 * x_root - the X corrdinate in the root window
568 * y_root - the Y corrdinate in the root window
569 * tmp_win - the current twm window
571 ***********************************************************************
575 DoResize(x_root, y_root, tmp_win)
588 int delta = y_root - dragy;
589 if (dragHeight - delta < MINHEIGHT) {
590 delta = dragHeight - MINHEIGHT;
597 else if (y_root <= dragy/* ||
598 y_root == findRootInfo(root)->rooty*/) {
600 dragHeight = origy + origHeight -
608 int delta = x_root - dragx;
609 if (dragWidth - delta < MINWIDTH) {
610 delta = dragWidth - MINWIDTH;
617 else if (x_root <= dragx/* ||
618 x_root == findRootInfo(root)->rootx*/) {
620 dragWidth = origx + origWidth -
628 int delta = y_root - dragy - dragHeight;
629 if (dragHeight + delta < MINHEIGHT) {
630 delta = MINHEIGHT - dragHeight;
636 else if (y_root >= dragy + dragHeight - 1/* ||
637 y_root == findRootInfo(root)->rooty
638 + findRootInfo(root)->rootheight - 1*/) {
640 dragHeight = 1 + y_root - dragy;
647 int delta = x_root - dragx - dragWidth;
648 if (dragWidth + delta < MINWIDTH) {
649 delta = MINWIDTH - dragWidth;
655 else if (x_root >= dragx + dragWidth - 1/* ||
656 x_root == findRootInfo(root)->rootx +
657 findRootInfo(root)->rootwidth - 1*/) {
659 dragWidth = 1 + x_root - origx;
667 ConstrainSize (tmp_win, &dragWidth, &dragHeight);
669 dragx = origx + origWidth - dragWidth;
671 dragy = origy + origHeight - dragHeight;
673 /* added this 'if() ... else' - djhjr - 4/6/98 */
674 if (tmp_win->opaque_resize)
677 dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
678 dragWidth, dragHeight, -1);
680 /* force the redraw of a door - djhjr - 2/28/99 */
684 if (XFindContext(dpy, tmp_win->w, DoorContext, (caddr_t *)&door) != XCNOENT)
685 RedoDoorName(tmp_win, door);
688 /* force the redraw of the desktop - djhjr - 2/28/99 */
689 if (!strcmp(tmp_win->class.res_class, VTWM_DESKTOP_CLASS))
691 ResizeDesktopDisplay(dragWidth, dragHeight);
693 Draw3DBorder(Scr->VirtualDesktopDisplayOuter, 0, 0,
694 Scr->VirtualDesktopMaxWidth + (Scr->VirtualDesktopBevelWidth * 2),
695 Scr->VirtualDesktopMaxHeight + (Scr->VirtualDesktopBevelWidth * 2),
696 Scr->VirtualDesktopBevelWidth, Scr->VirtualC, off, False, False);
699 /* force the redraw of an icon manager - djhjr - 3/1/99 */
700 if (tmp_win->iconmgr)
703 int ncols = tmp_win->iconmgrp->cur_columns;
704 if (ncols == 0) ncols = 1;
707 tmp_win->iconmgrp->width = (int) ((dragWidth *
709 tmp_win->iconmgrp->width = (int) (((dragWidth - 2 * tmp_win->frame_bw3D) *
711 (long) tmp_win->iconmgrp->columns)
713 PackIconManager(tmp_win->iconmgrp);
715 list = tmp_win->iconmgrp->first;
718 RedoListWindow(list->twm);
723 PaintBorderAndTitlebar(tmp_win);
725 /* djhjr - 4/15/98 */
726 /* added '&& !resizing_window' - djhjr - 11/7/03 */
727 if (!Scr->NoGrabServer && !resizing_window)
729 /* these let the application window be drawn - djhjr - 4/14/98 */
730 XUngrabServer(dpy); XSync(dpy, 0); XGrabServer(dpy);
734 MoveOutline(Scr->Root,
735 dragx - tmp_win->frame_bw,
736 dragy - tmp_win->frame_bw,
737 dragWidth + 2 * tmp_win->frame_bw,
738 dragHeight + 2 * tmp_win->frame_bw,
740 tmp_win->frame_bw, tmp_win->title_height);
742 tmp_win->frame_bw, tmp_win->title_height + tmp_win->frame_bw3D);
744 /* djhjr - 4/17/98 */
745 if (Scr->VirtualReceivesMotionEvents)
746 DoVirtualMoveResize(tmp_win, dragx, dragy, dragWidth, dragHeight);
749 DisplaySize(tmp_win, dragWidth, dragHeight);
752 /* djhjr - 9/13/02 */
754 SetVirtualDesktopIncrs(tmp_win)
757 if (strcmp(tmp_win->class.res_class, VTWM_DESKTOP_CLASS) == 0)
759 if (Scr->snapRealScreen)
761 Scr->VirtualDesktopDisplayTwin->hints.flags |= PResizeInc;
762 Scr->VirtualDesktopDisplayTwin->hints.width_inc =
763 SCALE_D(Scr->VirtualDesktopPanDistanceX);
764 Scr->VirtualDesktopDisplayTwin->hints.height_inc =
765 SCALE_D(Scr->VirtualDesktopPanDistanceY);
768 Scr->VirtualDesktopDisplayTwin->hints.flags &= ~PResizeInc;
770 XSetWMNormalHints(dpy, tmp_win->w,
771 &Scr->VirtualDesktopDisplayTwin->hints);
775 /***********************************************************************
778 * DisplaySize - display the size in the dimensions window
781 * tmp_win - the current twm window
782 * width - the width of the rubber band
783 * height - the height of the rubber band
785 ***********************************************************************
789 DisplaySize(tmp_win, width, height)
795 int i, dwidth, dheight;
797 if (last_width == width && last_height == height)
801 last_height = height;
803 if (resize_context == C_VIRTUAL_WIN) {
804 dheight = SCALE_U(height) - tmp_win->title_height;
805 dwidth = SCALE_U(width);
808 dheight = height - tmp_win->title_height;
811 dheight = height - tmp_win->title_height - 2 * tmp_win->frame_bw3D;
812 dwidth = width - 2 * tmp_win->frame_bw3D;
817 * ICCCM says that PMinSize is the default is no PBaseSize is given,
819 * Don't adjust if window is the virtual desktop - djhjr - 9/13/02
821 if (tmp_win->hints.flags&(PMinSize|PBaseSize) && tmp_win->hints.flags & PResizeInc)
823 if (tmp_win->hints.flags & PBaseSize)
825 dwidth -= tmp_win->hints.base_width;
826 dheight -= tmp_win->hints.base_height;
827 } else if (strcmp(tmp_win->class.res_class, VTWM_DESKTOP_CLASS) != 0)
829 dwidth -= tmp_win->hints.min_width;
830 dheight -= tmp_win->hints.min_height;
834 if (tmp_win->hints.flags & PResizeInc)
836 dwidth /= tmp_win->hints.width_inc;
837 dheight /= tmp_win->hints.height_inc;
841 * Non-SysV systems - specifically, BSD-derived systems - return a
842 * pointer to the string, not its length. Submitted by Goran Larsson
843 i = sprintf (str, "%5d x %-5d", dwidth, dheight);
845 sprintf (str, "%5d x %-5d", dwidth, dheight);
848 XRaiseWindow(dpy, Scr->SizeWindow);
849 /* font was font.font->fid - djhjr - 9/14/03 */
850 FBF(Scr->DefaultC.fore, Scr->DefaultC.back, Scr->SizeFont);
851 /* djhjr - 9/14/03 */
852 #ifndef NO_I18N_SUPPORT
853 MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont,
855 XDrawImageString (dpy, Scr->SizeWindow,
860 Scr->SizeStringOffset,
862 (Scr->SizeStringWidth -
863 /* djhjr - 9/14/03 */
864 #ifndef NO_I18N_SUPPORT
865 MyFont_TextWidth(&Scr->SizeFont,
867 XTextWidth(Scr->SizeFont.font,
872 Scr->SizeFont.font->ascent + SIZE_VINDENT,
874 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
876 Scr->SizeFont.font->ascent +
878 Scr->SizeFont.ascent +
880 ((Scr->InfoBevelWidth > 0) ? Scr->InfoBevelWidth : 0),
884 /* I know, I know, but the above code overwrites it... djhjr - 5/9/96 */
885 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
886 if (Scr->InfoBevelWidth > 0)
887 Draw3DBorder(Scr->SizeWindow, 0, 0,
888 Scr->SizeStringWidth,
891 (unsigned int) (Scr->SizeFont.height + SIZE_VINDENT*2),
892 BW, Scr->DefaultC, off, False, False);
894 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
895 (unsigned int) (Scr->SizeFont.height + SIZE_VINDENT*2) +
896 ((Scr->InfoBevelWidth > 0) ? 2 * Scr->InfoBevelWidth : 0),
897 Scr->InfoBevelWidth, Scr->DefaultC, off, False, False);
900 /***********************************************************************
903 * EndResize - finish the resize operation
905 ***********************************************************************
914 fprintf(stderr, "EndResize\n");
917 if (resize_context == C_VIRTUAL_WIN)
918 MoveOutline(Scr->VirtualDesktopDisplay, 0, 0, 0, 0, 0, 0);
920 MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
921 XUnmapWindow(dpy, Scr->SizeWindow);
923 XFindContext(dpy, ResizeWindow, TwmContext, (caddr_t *)&tmp_win);
925 if (resize_context == C_VIRTUAL_WIN) {
927 dragWidth = SCALE_U(dragWidth);
928 dragHeight = SCALE_U(dragHeight);
929 dragx = SCALE_U(dragx);
930 dragy = SCALE_U(dragy);
933 ConstrainSize (tmp_win, &dragWidth, &dragHeight);
935 if (dragWidth != tmp_win->frame_width ||
936 dragHeight != tmp_win->frame_height)
937 tmp_win->zoomed = ZOOM_NONE;
939 SetupWindow (tmp_win, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
940 dragWidth, dragHeight, -1);
942 EndResizeAdjPointer(tmp_win); /* djhjr - 9/13/02 */
944 /* added test for opaque resizing - djhjr - 2/28/99, 3/1/99 */
945 if (!tmp_win->opaque_resize)
947 /* was inline code - djhjr - 9/10/99 */
948 ResizeTwmWindowContents(tmp_win, dragWidth, dragHeight);
951 #if 0 /* done in menus.c:ExecuteFunction() - djhjr - 10/6/02 */
952 if (!Scr->NoRaiseResize) {
953 XRaiseWindow(dpy, tmp_win->frame);
955 RaiseStickyAbove (); /* DSE */
959 UninstallRootColormap();
961 /* the resize can have cause the window to move on the screen, hence on the virtual
962 * desktop - need to fix the virtual coords */
963 tmp_win->virtual_frame_x = R_TO_V_X(dragx);
964 tmp_win->virtual_frame_y = R_TO_V_Y(dragy);
966 /* UpdateDesktop(tmp_win); Stig */
967 MoveResizeDesktop(tmp_win, Scr->NoRaiseResize); /* Stig */
970 #if 0 /* done in menus.c:ExecuteFunction() - djhjr - 10/11/01 */
972 /* don't re-map if the window is the virtual desktop - djhjr - 2/28/99 */
973 if (Scr->VirtualReceivesMotionEvents &&
974 /* !tmp_win->opaque_resize && */
975 tmp_win->w != Scr->VirtualDesktopDisplayOuter)
977 XUnmapWindow(dpy, Scr->VirtualDesktopDisplay);
978 XMapWindow(dpy, Scr->VirtualDesktopDisplay);
988 /* added the passed 'context' - djhjr - 9/30/02 */
990 MenuEndResize(tmp_win, context)
994 /* added this 'if (...) ... else' - djhjr - 2/22/99 */
995 if (resize_context == C_VIRTUAL_WIN)
996 MoveOutline(Scr->VirtualDesktopDisplay, 0, 0, 0, 0, 0, 0);
998 MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
999 XUnmapWindow(dpy, Scr->SizeWindow);
1001 ConstrainSize (tmp_win, &dragWidth, &dragHeight);
1003 /* djhjr - 9/19/96 */
1004 if (dragWidth != tmp_win->frame_width || dragHeight != tmp_win->frame_height)
1005 tmp_win->zoomed = ZOOM_NONE;
1010 AddingW = dragWidth + (2 * tmp_win->frame_bw);
1011 AddingH = dragHeight + (2 * tmp_win->frame_bw);
1012 SetupWindow (tmp_win, AddingX, AddingY, AddingW, AddingH, -1);
1014 SetupWindow (tmp_win, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
1015 dragWidth, dragHeight, -1);
1017 /* djhjr - 9/13/02 9/30/02 */
1018 if (context != C_VIRTUAL_WIN)
1019 EndResizeAdjPointer(tmp_win);
1021 /* added test for opaque resizing - djhjr - 2/28/99, 3/1/99 */
1022 if (!tmp_win->opaque_resize)
1024 /* was inline code - djhjr - 9/10/99 */
1025 ResizeTwmWindowContents(tmp_win, dragWidth, dragHeight);
1028 #if 0 /* done in menus.c:ExecuteFunction() - djhjr - 10/11/01 */
1029 /* djhjr - 6/4/98 */
1030 /* don't re-map if the window is the virtual desktop - djhjr - 2/28/99 */
1031 if (Scr->VirtualReceivesMotionEvents &&
1032 /* !tmp_win->opaque_resize && */
1033 tmp_win->w != Scr->VirtualDesktopDisplayOuter)
1035 XUnmapWindow(dpy, Scr->VirtualDesktopDisplay);
1036 XMapWindow(dpy, Scr->VirtualDesktopDisplay);
1040 /* djhjr - 9/5/98 */
1041 resizing_window = 0;
1046 /***********************************************************************
1049 * AddEndResize - finish the resize operation for AddWindow
1051 ***********************************************************************
1055 AddEndResize(tmp_win)
1060 fprintf(stderr, "AddEndResize\n");
1063 /* djhjr - 2/22/99 */
1064 MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
1065 XUnmapWindow(dpy, Scr->SizeWindow);
1067 ConstrainSize (tmp_win, &dragWidth, &dragHeight);
1070 AddingW = dragWidth + (2 * tmp_win->frame_bw);
1071 AddingH = dragHeight + (2 * tmp_win->frame_bw);
1073 EndResizeAdjPointer(tmp_win); /* djhjr - 9/13/02 */
1075 /* djhjr - 9/19/96 */
1076 if (dragWidth != tmp_win->frame_width || dragHeight != tmp_win->frame_height)
1077 tmp_win->zoomed = ZOOM_NONE;
1079 #if 0 /* done in add_window.c:AddMoveAndResize() - djhjr - 10/11/01 */
1080 /* djhjr - 6/4/98 */
1081 if (Scr->VirtualReceivesMotionEvents/* && !tmp_win->opaque_resize*/)
1083 XUnmapWindow(dpy, Scr->VirtualDesktopDisplay);
1084 XMapWindow(dpy, Scr->VirtualDesktopDisplay);
1088 /* djhjr - 9/5/98 */
1089 resizing_window = 0;
1092 /* djhjr - 9/13/02 */
1094 EndResizeAdjPointer(tmp_win)
1097 int x, y, bw = tmp_win->frame_bw + tmp_win->frame_bw3D;
1099 XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
1100 &JunkX, &JunkY, &JunkBW, &JunkBW, &JunkBW);
1101 XTranslateCoordinates(dpy, Scr->Root, tmp_win->frame,
1102 JunkX, JunkY, &x, &y, &JunkChild);
1104 /* for borderless windows */
1105 if (bw == 0) bw = 4;
1107 /* (tmp_win->frame_bw) == no 3D borders */
1111 if (y < tmp_win->title_height)
1112 x = tmp_win->title_x + ((tmp_win->frame_bw) ? (bw / 2) : -(bw / 2));
1114 x = ((tmp_win->frame_bw) ? -(bw / 2) : (bw / 2));
1116 if (x >= tmp_win->frame_width)
1118 if (y < tmp_win->title_height)
1119 x = tmp_win->title_x + tmp_win->title_width + (bw / 2);
1121 x = tmp_win->frame_width + ((tmp_win->frame_bw) ? (bw / 2) : -(bw / 2));
1124 if (y <= tmp_win->title_height)
1126 if (x >= tmp_win->title_x - ((tmp_win->frame_bw) ? 0 : bw) &&
1127 x < tmp_win->title_x + tmp_win->title_width + bw)
1130 y = ((tmp_win->frame_bw) ? -(bw / 2) : (bw / 2));
1133 y = tmp_win->title_height + ((tmp_win->frame_bw) ? -(bw / 2) : (bw / 2));
1135 if (y >= tmp_win->frame_height)
1136 y = tmp_win->frame_height + ((tmp_win->frame_bw) ? (bw / 2) : -(bw / 2));
1138 XWarpPointer(dpy, None, tmp_win->frame, 0, 0, 0, 0, x, y);
1141 /***********************************************************************
1144 * ConstrainSize - adjust the given width and height to account for the
1145 * constraints imposed by size hints
1147 * The general algorithm, especially the aspect ratio stuff, is
1148 * borrowed from uwm's CheckConsistency routine.
1150 ***********************************************************************/
1152 void ConstrainSize (tmp_win, widthp, heightp)
1154 int *widthp, *heightp;
1156 #define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
1157 #define _min(a,b) (((a) < (b)) ? (a) : (b))
1159 int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
1160 int baseWidth, baseHeight;
1161 int dwidth = *widthp, dheight = *heightp;
1165 dheight -= tmp_win->title_height;
1167 dwidth -= 2 * tmp_win->frame_bw3D;
1168 dheight -= (tmp_win->title_height + 2 * tmp_win->frame_bw3D);
1170 if (tmp_win->hints.flags & PMinSize) {
1171 minWidth = tmp_win->hints.min_width;
1172 minHeight = tmp_win->hints.min_height;
1173 } else if (tmp_win->hints.flags & PBaseSize) {
1174 minWidth = tmp_win->hints.base_width;
1175 minHeight = tmp_win->hints.base_height;
1177 minWidth = minHeight = 1;
1179 if (resize_context == C_VIRTUAL_WIN) {
1180 minWidth = SCALE_D(minWidth);
1181 minHeight = SCALE_D(minHeight);
1184 if (tmp_win->hints.flags & PBaseSize) {
1185 baseWidth = tmp_win->hints.base_width;
1186 baseHeight = tmp_win->hints.base_height;
1187 } else if (tmp_win->hints.flags & PMinSize) {
1188 baseWidth = tmp_win->hints.min_width;
1189 baseHeight = tmp_win->hints.min_height;
1191 baseWidth = baseHeight = 0;
1193 if (resize_context == C_VIRTUAL_WIN) {
1194 baseWidth = SCALE_D(baseWidth);
1195 baseHeight = SCALE_D(baseHeight);
1198 if (tmp_win->hints.flags & PMaxSize) {
1199 maxWidth = _min (Scr->MaxWindowWidth, tmp_win->hints.max_width);
1200 maxHeight = _min (Scr->MaxWindowHeight, tmp_win->hints.max_height);
1202 maxWidth = Scr->MaxWindowWidth;
1203 maxHeight = Scr->MaxWindowHeight;
1206 if (resize_context == C_VIRTUAL_WIN) {
1207 maxWidth = SCALE_D(maxWidth);
1208 maxHeight = SCALE_D(maxHeight);
1211 if (tmp_win->hints.flags & PResizeInc) {
1212 xinc = tmp_win->hints.width_inc;
1213 yinc = tmp_win->hints.height_inc;
1217 if (resize_context == C_VIRTUAL_WIN) {
1218 xinc = SCALE_D(xinc);
1219 yinc = SCALE_D(yinc);
1223 * First, clamp to min and max values
1225 if (dwidth < minWidth) dwidth = minWidth;
1226 if (dheight < minHeight) dheight = minHeight;
1228 if (dwidth > maxWidth) dwidth = maxWidth;
1229 if (dheight > maxHeight) dheight = maxHeight;
1233 * Second, fit to base + N * inc
1235 dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
1236 dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
1240 * Third, adjust for aspect ratio
1242 #define maxAspectX tmp_win->hints.max_aspect.x
1243 #define maxAspectY tmp_win->hints.max_aspect.y
1244 #define minAspectX tmp_win->hints.min_aspect.x
1245 #define minAspectY tmp_win->hints.min_aspect.y
1247 * The math looks like this:
1249 * minAspectX dwidth maxAspectX
1250 * ---------- <= ------- <= ----------
1251 * minAspectY dheight maxAspectY
1253 * If that is multiplied out, then the width and height are
1254 * invalid in the following situations:
1256 * minAspectX * dheight > minAspectY * dwidth
1257 * maxAspectX * dheight < maxAspectY * dwidth
1261 if (tmp_win->hints.flags & PAspect)
1263 if (minAspectX * dheight > minAspectY * dwidth)
1265 delta = makemult(minAspectX * dheight / minAspectY - dwidth,
1267 if (dwidth + delta <= maxWidth) dwidth += delta;
1270 delta = makemult(dheight - dwidth*minAspectY/minAspectX,
1272 if (dheight - delta >= minHeight) dheight -= delta;
1276 if (maxAspectX * dheight < maxAspectY * dwidth)
1278 delta = makemult(dwidth * maxAspectY / maxAspectX - dheight,
1280 if (dheight + delta <= maxHeight) dheight += delta;
1283 delta = makemult(dwidth - maxAspectX*dheight/maxAspectY,
1285 if (dwidth - delta >= minWidth) dwidth -= delta;
1292 * Fourth, account for border width and title height
1296 *heightp = dheight + tmp_win->title_height;
1298 *widthp = dwidth + 2 * tmp_win->frame_bw3D;
1299 *heightp = dheight + tmp_win->title_height + 2 * tmp_win->frame_bw3D;
1304 /***********************************************************************
1307 * SetupWindow - set window sizes, this was called from either
1308 * AddWindow, EndResize, or HandleConfigureNotify.
1311 * tmp_win - the TwmWindow pointer
1312 * x - the x coordinate of the upper-left outer corner of the frame
1313 * y - the y coordinate of the upper-left outer corner of the frame
1314 * w - the width of the frame window w/o border
1315 * h - the height of the frame window w/o border
1316 * bw - the border width of the frame window or -1 not to change
1318 * Special Considerations:
1319 * This routine will check to make sure the window is not completely
1320 * off the display, if it is, it'll bring some of it back on.
1322 * The tmp_win->frame_XXX variables should NOT be updated with the
1323 * values of x,y,w,h prior to calling this routine, since the new
1324 * values are compared against the old to see whether a synthetic
1325 * ConfigureNotify event should be sent. (It should be sent if the
1326 * window was moved but not resized.)
1328 ***********************************************************************
1331 void SetupWindow (tmp_win, x, y, w, h, bw)
1335 SetupFrame (tmp_win, x, y, w, h, bw, False);
1338 void SetupFrame (tmp_win, x, y, w, h, bw, sendEvent)
1341 Bool sendEvent; /* whether or not to force a send */
1343 XWindowChanges frame_wc, xwc;
1344 unsigned long frame_mask, xwcm;
1345 int title_width, title_height;
1349 fprintf (stderr, "SetupWindow: x=%d, y=%d, w=%d, h=%d, bw=%d\n",
1353 if ((tmp_win->virtual_frame_x + tmp_win->frame_width) < 0)
1354 x = 16; /* one "average" cursor width */
1355 if (x >= Scr->VirtualDesktopWidth)
1356 x = Scr->VirtualDesktopWidth - 16;
1357 if ((tmp_win->virtual_frame_y + tmp_win->frame_height) < 0)
1358 y = 16; /* one "average" cursor width */
1359 if (y >= Scr->VirtualDesktopHeight)
1360 y = Scr->VirtualDesktopHeight - 16;
1363 bw = tmp_win->frame_bw; /* -1 means current frame width */
1365 if (tmp_win->iconmgr) {
1367 tmp_win->iconmgrp->width = w;
1368 h = tmp_win->iconmgrp->height + tmp_win->title_height;
1370 tmp_win->iconmgrp->width = w - (2 * tmp_win->frame_bw3D);
1371 h = tmp_win->iconmgrp->height + tmp_win->title_height + (2 * tmp_win->frame_bw3D);
1376 * According to the July 27, 1988 ICCCM draft, we should send a
1377 * "synthetic" ConfigureNotify event to the client if the window
1378 * was moved but not resized.
1380 if (((x != tmp_win->frame_x || y != tmp_win->frame_y) &&
1381 (w == tmp_win->frame_width && h == tmp_win->frame_height)) ||
1382 (bw != tmp_win->frame_bw))
1387 title_width = xwc.width = w;
1389 title_width = xwc.width = w - (2 * tmp_win->frame_bw3D);
1390 title_height = Scr->TitleHeight + bw;
1392 ComputeWindowTitleOffsets (tmp_win, xwc.width, True);
1394 reShape = (tmp_win->wShaped ? TRUE : FALSE);
1395 if (tmp_win->squeeze_info) /* check for title shaping */
1397 title_width = tmp_win->rightx + Scr->TBInfo.rightoff;
1398 if (title_width < xwc.width)
1400 xwc.width = title_width;
1401 if (tmp_win->frame_height != h ||
1402 tmp_win->frame_width != w ||
1403 tmp_win->frame_bw != bw ||
1404 title_width != tmp_win->title_width)
1409 if (!tmp_win->wShaped) reShape = TRUE;
1410 title_width = xwc.width;
1414 tmp_win->title_width = title_width;
1415 if (tmp_win->title_height) tmp_win->title_height = title_height;
1417 if (tmp_win->title_w) {
1418 if (bw != tmp_win->frame_bw) {
1419 xwc.border_width = bw;
1421 tmp_win->title_x = xwc.x = -bw;
1422 tmp_win->title_y = xwc.y = -bw;
1424 tmp_win->title_x = xwc.x = tmp_win->frame_bw3D - bw;
1425 tmp_win->title_y = xwc.y = tmp_win->frame_bw3D - bw;
1427 xwcm |= (CWX | CWY | CWBorderWidth);
1430 XConfigureWindow(dpy, tmp_win->title_w, xwcm, &xwc);
1434 tmp_win->attr.width = w;
1435 tmp_win->attr.height = h - tmp_win->title_height;
1437 tmp_win->attr.width = w - (2 * tmp_win->frame_bw3D);
1438 tmp_win->attr.height = h - tmp_win->title_height - (2 * tmp_win->frame_bw3D);
1441 XMoveResizeWindow (dpy, tmp_win->w, 0, tmp_win->title_height,
1442 w, h - tmp_win->title_height);
1446 * fix up frame and assign size/location values in tmp_win
1450 if (bw != tmp_win->frame_bw) {
1451 frame_wc.border_width = tmp_win->frame_bw = bw;
1452 frame_mask |= CWBorderWidth;
1454 frame_wc.x = tmp_win->frame_x = x;
1455 frame_wc.y = tmp_win->frame_y = y;
1456 frame_wc.width = tmp_win->frame_width = w;
1457 frame_wc.height = tmp_win->frame_height = h;
1458 frame_mask |= (CWX | CWY | CWWidth | CWHeight);
1459 XConfigureWindow (dpy, tmp_win->frame, frame_mask, &frame_wc);
1460 tmp_win->virtual_frame_x = R_TO_V_X(tmp_win->frame_x);
1461 tmp_win->virtual_frame_y = R_TO_V_Y(tmp_win->frame_y);
1463 /* djhjr - 4/24/96 */
1464 XMoveResizeWindow (dpy, tmp_win->w, tmp_win->frame_bw3D,
1465 tmp_win->title_height + tmp_win->frame_bw3D,
1466 tmp_win->attr.width, tmp_win->attr.height);
1469 * fix up highlight window
1472 if (tmp_win->title_height && tmp_win->hilite_w)
1475 xwc.width = (tmp_win->rightx - tmp_win->highlightx);
1476 if (Scr->TBInfo.nright > 0) xwc.width -= Scr->TitlePadding;
1479 if (Scr->use3Dtitles) xwc.width -= 4;
1481 xwc.width = ComputeHighlightWindowWidth(tmp_win);
1483 if (xwc.width <= 0) {
1484 xwc.x = Scr->MyDisplayWidth; /* move offscreen */
1487 xwc.x = tmp_win->highlightx;
1490 xwcm = CWX | CWWidth;
1491 XConfigureWindow(dpy, tmp_win->hilite_w, xwcm, &xwc);
1494 if (HasShape && reShape) {
1495 SetFrameShape (tmp_win);
1500 SendConfigureNotify(tmp_win, x, y);
1504 /* djhjr - 4/6/98 */
1506 PaintBorderAndTitlebar(tmp_win)
1509 if (tmp_win->highlight)
1510 SetBorder(tmp_win, True);
1513 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
1514 if (Scr->BorderBevelWidth > 0) PaintBorders(tmp_win, True);
1516 if (tmp_win->titlebuttons)
1518 int i, nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
1521 for (i = 0, tbw = tmp_win->titlebuttons; i < nb; i++, tbw++)
1522 PaintTitleButton(tmp_win, tbw, 0);
1526 PaintTitle(tmp_win);
1527 PaintTitleHighlight(tmp_win, on); /* djhjr - 10/25/02 */
1531 /* djhjr - 4/17/98 */
1533 DoVirtualMoveResize(tmp_win, x, y, w, h)
1537 int fw = tmp_win->frame_width, fh = tmp_win->frame_height;
1539 tmp_win->virtual_frame_x = R_TO_V_X(x - tmp_win->frame_bw);
1540 tmp_win->virtual_frame_y = R_TO_V_Y(y - tmp_win->frame_bw);
1541 if (!tmp_win->opaque_resize)
1543 tmp_win->frame_width = w + 2 * tmp_win->frame_bw;
1544 tmp_win->frame_height = h + 2 * tmp_win->frame_bw;
1548 MoveResizeDesktop(tmp_win, Scr->NoRaiseResize);
1550 MoveResizeDesktop(tmp_win, TRUE);
1552 tmp_win->frame_width = fw; tmp_win->frame_height = fh;
1556 /**********************************************************************
1557 * Rutgers mod #1 - rocky.
1559 * fullzoom - zooms window to full height of screen or
1560 * to full height and width of screen. (Toggles
1561 * so that it can undo the zoom - even when switching
1562 * between fullzoom and vertical zoom.)
1565 * tmp_win - the TwmWindow pointer
1568 **********************************************************************
1572 fullzoom(tmp_win,flag)
1577 unsigned int junkbw, junkDepth;
1579 int frame_bw_times_2;
1581 XGetGeometry(dpy, (Drawable) tmp_win->frame, &junkRoot, &dragx, &dragy,
1582 (unsigned int *)&dragWidth, (unsigned int *)&dragHeight, &junkbw,
1587 if (tmp_win->zoomed == flag)
1589 dragHeight = tmp_win->save_frame_height;
1590 dragWidth = tmp_win->save_frame_width;
1591 dragx = tmp_win->save_frame_x;
1592 dragy = tmp_win->save_frame_y;
1593 tmp_win->zoomed = ZOOM_NONE;
1597 if (tmp_win->zoomed == ZOOM_NONE)
1599 tmp_win->save_frame_x = dragx;
1600 tmp_win->save_frame_y = dragy;
1601 tmp_win->save_frame_width = dragWidth;
1602 tmp_win->save_frame_height = dragHeight;
1605 tmp_win->zoomed = flag;
1607 frame_bw_times_2 = 2 * tmp_win->frame_bw;
1614 dragx = tmp_win->save_frame_x;
1616 dragWidth = tmp_win->save_frame_width;
1617 dragHeight = Scr->MyDisplayHeight - frame_bw_times_2;
1621 dragy = tmp_win->save_frame_y;
1622 dragWidth = Scr->MyDisplayWidth - frame_bw_times_2;
1623 dragHeight = tmp_win->save_frame_height;
1628 dragWidth = Scr->MyDisplayWidth - frame_bw_times_2;
1629 dragHeight = Scr->MyDisplayHeight - frame_bw_times_2;
1634 dragWidth = Scr->MyDisplayWidth / 2 - frame_bw_times_2;
1635 dragHeight = Scr->MyDisplayHeight - frame_bw_times_2;
1638 dragx = basex + Scr->MyDisplayWidth / 2;
1640 dragWidth = Scr->MyDisplayWidth / 2 - frame_bw_times_2;
1641 dragHeight = Scr->MyDisplayHeight - frame_bw_times_2;
1646 dragWidth = Scr->MyDisplayWidth - frame_bw_times_2;
1647 dragHeight = Scr->MyDisplayHeight / 2 - frame_bw_times_2;
1651 dragy = basey + Scr->MyDisplayHeight / 2;
1652 dragWidth = Scr->MyDisplayWidth - frame_bw_times_2;
1653 dragHeight = Scr->MyDisplayHeight / 2 - frame_bw_times_2;
1658 if (!Scr->NoRaiseResize) {
1659 XRaiseWindow(dpy, tmp_win->frame);
1661 RaiseStickyAbove(); /* DSE */
1665 ConstrainSize(tmp_win, &dragWidth, &dragHeight);
1666 SetupWindow (tmp_win, dragx , dragy , dragWidth, dragHeight, -1);
1668 /* djhjr - 9/10/99 */
1669 ResizeTwmWindowContents(tmp_win, dragWidth, dragHeight);
1671 /* 9/21/96 - djhjr */
1672 if ((Scr->WarpCursor || LookInList(Scr->WarpCursorL, tmp_win->full_name, &tmp_win->class)))
1673 WarpToWindow (tmp_win);
1675 XUngrabPointer (dpy, CurrentTime);
1676 XUngrabServer (dpy);
1680 * adjust contents of iconmgrs, doors and the desktop - djhjr - 9/10/99
1682 void ResizeTwmWindowContents(tmp_win, width, height)
1689 if (tmp_win->iconmgr)
1691 ncols = tmp_win->iconmgrp->cur_columns;
1692 if (ncols == 0) ncols = 1;
1695 tmp_win->iconmgrp->width = (int) ((width *
1697 tmp_win->iconmgrp->width =
1698 (int)(((width - 2 * tmp_win->frame_bw3D) *
1700 (long) tmp_win->iconmgrp->columns) / ncols);
1701 PackIconManager(tmp_win->iconmgrp);
1703 else if (tmp_win->w == Scr->VirtualDesktopDisplayOuter)
1704 ResizeDesktopDisplay(width, height);
1705 else if (XFindContext(dpy, tmp_win->w, DoorContext, (caddr_t *)&door) != XCNOENT)
1706 RedoDoorName(tmp_win, door);
1709 void SetFrameShape (tmp)
1713 * see if the titlebar needs to move
1716 int oldx = tmp->title_x, oldy = tmp->title_y;
1717 ComputeTitleLocation (tmp);
1718 if (oldx != tmp->title_x || oldy != tmp->title_y)
1719 XMoveWindow (dpy, tmp->title_w, tmp->title_x, tmp->title_y);
1723 * The frame consists of the shape of the contents window offset by
1724 * title_height or'ed with the shape of title_w (which is always
1729 * need to do general case
1731 XShapeCombineShape (dpy, tmp->frame, ShapeBounding,
1733 0, tmp->title_height, tmp->w,
1735 tmp->frame_bw3D, tmp->title_height + tmp->frame_bw3D, tmp->w,
1737 ShapeBounding, ShapeSet);
1739 XShapeCombineShape (dpy, tmp->frame, ShapeBounding,
1740 tmp->title_x + tmp->frame_bw,
1741 tmp->title_y + tmp->frame_bw,
1742 tmp->title_w, ShapeBounding,
1747 * can optimize rectangular contents window
1749 if (tmp->squeeze_info) {
1750 XRectangle newBounding[3];
1751 XRectangle newClip[3];
1752 int count = 3, order = YXSorted, fbw2 = 2 * tmp->frame_bw;
1753 int client_width = tmp->attr.width + fbw2 + 2 * tmp->frame_bw3D;
1756 * Build the border clipping rectangles; one around title, one
1757 * around window. The title_[xy] field already have had frame_bw
1758 * subtracted off them so that they line up properly in the frame.
1760 * The frame_width and frame_height do *not* include borders.
1764 newBounding[0].x = tmp->title_x;
1765 newBounding[0].y = tmp->title_y;
1766 newBounding[0].width = tmp->title_width + fbw2;
1767 newBounding[0].height = tmp->title_height;
1768 newBounding[1].x = -tmp->frame_bw;
1769 newBounding[1].y = Scr->TitleHeight;
1770 newBounding[1].width = tmp->attr.width + fbw2;
1771 newBounding[1].height = tmp->attr.height + fbw2;
1773 newBounding[0].x = tmp->title_x - tmp->frame_bw3D;
1774 newBounding[0].y = tmp->title_y - tmp->frame_bw3D;
1775 newBounding[0].width = tmp->title_width + fbw2 + 2 * tmp->frame_bw3D;
1776 newBounding[0].height = tmp->title_height + tmp->frame_bw3D;
1778 /* was 'Scr->use3Dborders' - djhjr - 8/11/98 */
1779 if (Scr->BorderBevelWidth > 0 &&
1780 newBounding[0].width < client_width)
1782 /* re-ordered arrays for XYSorted - djhjr - 11/5/03 */
1783 newBounding[1].x = -tmp->frame_bw3D;
1784 newBounding[1].y = tmp->title_height;
1785 newBounding[1].width = tmp->attr.width + 3 * tmp->frame_bw3D;
1786 newBounding[1].height = tmp->frame_bw3D;
1787 newBounding[2].x = -tmp->frame_bw;
1788 newBounding[2].y = Scr->TitleHeight + tmp->frame_bw3D;
1789 newBounding[2].width = client_width;
1790 newBounding[2].height = tmp->attr.height + fbw2 + tmp->frame_bw3D;
1794 newBounding[1].x = -tmp->frame_bw;
1795 newBounding[1].y = Scr->TitleHeight + tmp->frame_bw3D;
1796 newBounding[1].width = client_width;
1797 newBounding[1].height = tmp->attr.height + fbw2 + tmp->frame_bw3D;
1804 newClip[0].x = tmp->title_x + tmp->frame_bw;
1806 newClip[0].width = tmp->title_width;
1807 newClip[0].height = Scr->TitleHeight;
1809 newClip[1].y = tmp->title_height;
1810 newClip[1].width = tmp->attr.width;
1811 newClip[1].height = tmp->attr.height;
1813 newClip[0].x = tmp->title_x + tmp->frame_bw - tmp->frame_bw3D;
1815 newClip[0].width = tmp->title_width + 2 * tmp->frame_bw3D;
1816 newClip[0].height = Scr->TitleHeight + tmp->frame_bw3D;
1820 /* re-ordered arrays for XYSorted - djhjr - 11/5/03 */
1821 newClip[1].x = newBounding[1].x;
1822 newClip[1].y = newBounding[1].y;
1823 newClip[1].width = newBounding[1].width;
1824 newClip[1].height = newBounding[1].height;
1826 newClip[2].y = tmp->title_height + tmp->frame_bw3D;
1827 newClip[2].width = client_width;
1828 newClip[2].height = tmp->attr.height + tmp->frame_bw3D;
1833 newClip[1].y = tmp->title_height + tmp->frame_bw3D;
1834 newClip[1].width = client_width;
1835 newClip[1].height = tmp->attr.height + tmp->frame_bw3D;
1838 XShapeCombineRectangles (dpy, tmp->frame, ShapeBounding, 0, 0,
1839 newBounding, count, ShapeSet, order);
1840 XShapeCombineRectangles (dpy, tmp->frame, ShapeClip, 0, 0,
1841 newClip, count, ShapeSet, order);
1843 (void) XShapeCombineMask (dpy, tmp->frame, ShapeBounding, 0, 0,
1845 (void) XShapeCombineMask (dpy, tmp->frame, ShapeClip, 0, 0,
1856 * tmp->title_y ........+--------------+......... -+,- tmp->frame_bw
1857 * 0 : ......| +----------+ |....... : -++
1858 * : : | | | | : : ||-Scr->TitleHeight
1859 * : : | | | | : : ||
1860 * +-------+ +----------+ +--------+ -+|-tmp->title_height
1861 * | +---------------------------+ | --+
1867 * | +---------------------------+ |
1868 * +-------------------------------+
1875 * tmp->title_y +-------------------------------+ -+,tmp->frame_bw
1876 * 0 | +---------------------------+ | -+'
1877 * | | | | |-Scr->TitleHeight
1879 * + +---------------------------+ + -+
1880 * |-+---------------------------+-|
1886 * | +---------------------------+ |
1887 * +-------------------------------+
1891 * Dimensions and Positions:
1893 * frame orgin (0, 0)
1894 * frame upper left border (-tmp->frame_bw, -tmp->frame_bw)
1895 * frame size w/o border tmp->frame_width , tmp->frame_height
1896 * frame/title border width tmp->frame_bw
1897 * extra title height w/o bdr tmp->title_height = TitleHeight + frame_bw
1898 * title window height Scr->TitleHeight
1899 * title origin w/o border (tmp->title_x, tmp->title_y)
1900 * client origin (0, Scr->TitleHeight + tmp->frame_bw)
1901 * client size tmp->attr.width , tmp->attr.height
1903 * When shaping, need to remember that the width and height of rectangles
1904 * are really deltax and deltay to lower right handle corner, so they need
1905 * to have -1 subtracted from would normally be the actual extents.