static char *rcsid_Resize_c
= "$Header: Resize.c,v 10.3 86/02/01 16:23:45 tony Rel $";
/************************************************************************
* Copyright (c) 1986 by *
* Digital Equipment Corporation, Maynard, MA *
* Permission to use, copy, modify, and distribute this software *
* and its documentation is hereby granted only to licensees of *
* The Regents of the University of California pursuant to their *
* license agreement for the Berkeley Software Distribution *
* provided that the following appears on all copies. *
* "LICENSED FROM DIGITAL EQUIPMENT CORPORATION *
* DIGITAL EQUIPMENT CORPORATION *
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT *
* NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL *
* EQUIPMENT CORPORATION. DIGITAL MAKES NO REPRESENTATIONS *
* ABOUT SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. IT IS *
* SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. *
* IF THE UNIVERSITY OF CALIFORNIA OR ITS LICENSEES MODIFY *
* THE SOFTWARE IN A MANNER CREATING DERIVATIVE COPYRIGHT *
* RIGHTS APPROPRIATE COPYRIGHT LEGENDS MAY BE PLACED ON THE *
* DERIVATIVE WORK IN ADDITION TO THAT SET FORTH ABOVE." *
************************************************************************/
* 000 -- M. Gancarz, DEC Ultrix Engineering Group
static char *sccsid
= "@(#)Resize.c 3.8 1/24/86";
Bool
Resize(window
, mask
, button
, x0
, y0
)
Window window
; /* Event window. */
int mask
; /* Button/key mask. */
short button
; /* Button event detail. */
int x0
, y0
; /* Event mouse position. */
register WindowInfo window_info
; /* Event window info. */
register WindowInfo assoc_info
; /* Icon's associated window info. */
int h0
, hinc
, w0
, winc
, wadd
, hadd
; /* ??? */
int x1
, y1
, x2
, y2
; /* ??? */
int pop_x
, pop_y
; /* ??? */
int hsize
, vsize
; /* ??? */
int num_vectors
; /* Number of vectors to XDraw. */
Window assoc
; /* Window represented by the icon. */
Window sub_win
; /* Mouse query sub window. */
XButtonEvent button_event
; /* Button event packet. */
Vertex box
[MAX_BOX_VECTORS
]; /* Box drawing vertex buffer. */
Vertex zap
[MAX_ZAP_VECTORS
]; /* Zap drawing vertex buffer. */
Bool stop
; /* Should the window stop changing? */
* Do nothing if the event window is the root window.
if (window
== RootWindow
)
* Gather info about the event window.
status
= XQueryWindow(window
, &window_info
);
if (status
== FAILURE
) return(FALSE
);
* Do not resize an icon window.
if (window_info
.type
== IsIcon
)
* Clear the vector buffers.
if (Zap
) bzero(zap
, sizeof(zap
));
* If we are here then we have a resize operation in progress.
* Turn on the resize cursor.
status
= XGrabButton(RootWindow
, ArrowCrossCursor
, mask
, EVENTMASK
);
Error("Resize -> Unable to grab button and change cursor.");
* Get the event window resize hint.
XGetResizeHint(window
, &w0
, &h0
, &winc
, &hinc
);
* If I ever have the time to REALLY figure the rest of this out I will
x2
= x1
+ window_info
.width
+ (window_info
.bdrwidth
<< 1) - 1;
y2
= y1
+ window_info
.height
+ (window_info
.bdrwidth
<< 1) - 1;
domult
= (winc
> 3 && hinc
> 3 &&
(window_info
.width
- w0
) % winc
== 0 &&
(window_info
.height
- h0
) % hinc
== 0) ? TRUE
: FALSE
;
if (w0
== 0 && winc
== 1 && h0
== 0 && hinc
== 1) {
mx
= x2
- window_info
.width
+ w0
+ winc
;
my
= y2
- window_info
.height
+ h0
+ hinc
;
w0
+= (window_info
.bdrwidth
<< 1) - 1;
h0
+= (window_info
.bdrwidth
<< 1) - 1;
ox
= ((x0
- window_info
.x
- window_info
.bdrwidth
) * 3) /
oy
= ((y0
- window_info
.y
- window_info
.bdrwidth
) * 3) /
if (window_info
.width
> 2 && window_info
.height
> 2 && ((ox
+ oy
) & 1)) {
num_vectors
= StoreGridBox(
* If we freeze the server, then we will draw solid
* lines instead of flickering ones during resizing.
if (Freeze
) XGrabServer();
* Process any pending exposure events before drawing the box.
XPeekEvent(&button_event
);
if (button_event
.window
== RootWindow
)
GetButton(&button_event
);
if (x
!= ox
|| y
!= oy
) {
* If we've frozen the server, then erase
num_vectors
= StoreGridBox(
hsize
= (abs(x
- x1
) - w0
) / winc
;
vsize
= (abs(y
- y1
) - h0
) / hinc
;
PText
[0] = hsize
/ 100 + '0';
PText
[1] = (hsize
/ 10) % 10 + '0';
PText
[2] = hsize
% 10 + '0';
PText
[4] = vsize
/ 100 + '0';
PText
[5] = (vsize
/ 10) % 10 + '0';
PText
[6] = vsize
% 10 + '0';
* If the font is not fixed width we have to
* clear the window to guarantee that the characters
* that were there before are erased.
if (!(PFontInfo
.fixedwidth
)) XClear(Pop
);
PTextForground
, PTextBackground
,
if (XPending() && GetButton(&button_event
)) {
(button_event
.type
== ButtonReleased
) &&
((button_event
.detail
& ValueMask
) == button
)
XUpdateMouse(RootWindow
, &x
, &y
, &sub_win
);
if (x
== lx
&& y
== ly
) {
pop_x
= x1
+ window_info
.bdrwidth
;
pop_x
= x1
- PWidth
- window_info
.bdrwidth
+ 1;
pop_x
= window_info
.x
+ window_info
.bdrwidth
+
(window_info
.width
- PWidth
) / 2;
pop_y
= y1
+ window_info
.bdrwidth
;
pop_y
= y1
- PHeight
- window_info
.bdrwidth
+ 1;
pop_y
= window_info
.y
+ window_info
.bdrwidth
+
(window_info
.height
- PHeight
) / 2;
XMoveWindow(Pop
, pop_x
, pop_y
);
if ((d
= abs(x
- x0
) + wadd
) < 0)
if ((d
= abs(y
- y0
) + hadd
) < 0)
if (x
== x2
&& y
== y2
) {
dx
= x
- x1
+ 1 - (window_info
.bdrwidth
<< 1);
dy
= y
- y1
+ 1 - (window_info
.bdrwidth
<< 1);
(PWidth
> window_info
.width
) ||
(PHeight
> window_info
.height
) ||
XConfigureWindow(window
, x1
, y1
, dx
, dy
);