34#include "functions_defs.h"
79 int x,
y, h, v, junkbw;
80 unsigned int junkMask;
84 x = evp->xbutton.x_root;
85 y = evp->xbutton.y_root;
92 if(!XQueryPointer(
dpy,
Scr->Root, &junkRoot, &junkRoot,
93 &
x, &
y, &junkbw, &junkbw, &junkMask)) {
145 if(
Scr->OpaqueResizeThreshold >= 1000) {
146 Scr->OpaqueResize =
true;
155 const unsigned long scrsz =
Scr->rootw *
Scr->rooth;
156 if(winsz > (scrsz * (
Scr->OpaqueResizeThreshold / 100.0))) {
157 Scr->OpaqueResize =
false;
160 Scr->OpaqueResize =
true;
165 Scr->OpaqueResize =
false;
184 bool fromtitlebar,
bool from3dborder)
186 Window junkRoot, grabwin;
187 unsigned int junkbw, junkDepth;
190 cursor = (
Scr->BorderCursors
197 ButtonMotionMask | PointerMotionHintMask;
201 if(tmp_win->winbox) {
202 grabwin = tmp_win->winbox->window;
206 GrabModeAsync, GrabModeAsync, grabwin, cursor, CurrentTime);
208 XGetGeometry(
dpy, (Drawable) tmp_win->
frame, &junkRoot,
219 if(
Scr->AutoRelativeResize && (from3dborder || !fromtitlebar)) {
227 XMapRaised(
dpy,
Scr->SizeWindow);
243 if(!
Scr->OpaqueResize) {
246 resizeGrabMask = ButtonPressMask | ButtonMotionMask | PointerMotionMask;
248 GrabModeAsync, GrabModeAsync,
249 Scr->Root,
Scr->ResizeCursor, CurrentTime);
263 XMapRaised(
dpy,
Scr->SizeWindow);
265 if(!
Scr->OpaqueResize)
287 resizeGrabMask = ButtonReleaseMask | ButtonMotionMask | PointerMotionHintMask;
289 GrabModeAsync, GrabModeAsync,
290 Scr->Root,
Scr->ResizeCursor, CurrentTime);
316 int delta = y_root -
dragy;
326 else if(y_root <=
dragy) {
337 int delta = x_root -
dragx;
347 else if(x_root <=
dragx) {
406 if(
Scr->OpaqueResize)
416 if(
Scr->BorderCursors && (cursor != tmp_win->
curcurs)) {
450 int delta = y_root -
dragy;
460 else if(y_root <=
dragy) {
471 int delta = x_root -
dragx;
481 else if(x_root <=
dragx) {
552 if(
Scr->BorderCursors && (cursor != tmp_win->
curcurs)) {
594 if(tmp_win->
hints.flags & (PMinSize | PBaseSize)
595 && tmp_win->
hints.flags & PResizeInc) {
596 if(tmp_win->
hints.flags & PBaseSize) {
597 dwidth -= tmp_win->
hints.base_width;
598 dheight -= tmp_win->
hints.base_height;
601 dwidth -= tmp_win->
hints.min_width;
602 dheight -= tmp_win->
hints.min_height;
606 if(tmp_win->
hints.flags & PResizeInc) {
607 dwidth /= tmp_win->
hints.width_inc;
608 dheight /= tmp_win->
hints.height_inc;
611 sprintf(str,
" %4d x %-4d ", dwidth, dheight);
612 XRaiseWindow(
dpy,
Scr->SizeWindow);
617 2,
Scr->DefaultC,
off,
false,
false);
619 FB(
Scr->DefaultC.fore,
Scr->DefaultC.back);
620 XmbDrawImageString(
dpy,
Scr->SizeWindow,
Scr->SizeFont.font_set,
621 Scr->NormalGC,
Scr->SizeStringOffset,
638 fprintf(stderr,
"EndResize\n");
642 XUnmapWindow(
dpy,
Scr->SizeWindow);
671 if(!
Scr->NoRaiseResize) {
684 XUnmapWindow(
dpy,
Scr->SizeWindow);
706 fprintf(stderr,
"AddEndResize\n");
728 unsigned int *widthp,
unsigned int *heightp)
730#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) )
732 int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta;
733 int baseWidth, baseHeight;
734 int dwidth = *widthp, dheight = *heightp;
740 if(tmp_win->
hints.flags & PMinSize) {
741 minWidth = tmp_win->
hints.min_width;
742 minHeight = tmp_win->
hints.min_height;
744 else if(tmp_win->
hints.flags & PBaseSize) {
745 minWidth = tmp_win->
hints.base_width;
746 minHeight = tmp_win->
hints.base_height;
749 minWidth = minHeight = 1;
752 if(tmp_win->
hints.flags & PBaseSize) {
753 baseWidth = tmp_win->
hints.base_width;
754 baseHeight = tmp_win->
hints.base_height;
756 else if(tmp_win->
hints.flags & PMinSize) {
757 baseWidth = tmp_win->
hints.min_width;
758 baseHeight = tmp_win->
hints.min_height;
761 baseWidth = baseHeight = 0;
765 if(tmp_win->
hints.flags & PMaxSize) {
766 maxWidth =
min(
Scr->MaxWindowWidth, tmp_win->
hints.max_width);
767 maxHeight =
min(
Scr->MaxWindowHeight, tmp_win->
hints.max_height);
770 maxWidth =
Scr->MaxWindowWidth;
771 maxHeight =
Scr->MaxWindowHeight;
774 if(tmp_win->
hints.flags & PResizeInc) {
775 xinc = tmp_win->
hints.width_inc;
776 yinc = tmp_win->
hints.height_inc;
791 if(dwidth < minWidth) {
794 if(dheight < minHeight) {
798 if(dwidth > maxWidth) {
801 if(dheight > maxHeight) {
809 dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
810 dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
831 if(tmp_win->
hints.flags & PAspect) {
832 int minAspectX = tmp_win->
hints.min_aspect.x;
833 int minAspectY = tmp_win->
hints.min_aspect.y;
834 int maxAspectX = tmp_win->
hints.max_aspect.x;
835 int maxAspectY = tmp_win->
hints.max_aspect.y;
837 if(minAspectX && minAspectY && maxAspectX && maxAspectY) {
838 if(minAspectX * dheight > minAspectY * dwidth) {
839 delta =
makemult(minAspectX * dheight / minAspectY - dwidth,
841 if(dwidth + delta <= maxWidth) {
845 delta =
makemult(dheight - dwidth * minAspectY / minAspectX,
847 if(dheight - delta >= minHeight) {
853 if(maxAspectX * dheight < maxAspectY * dwidth) {
854 delta =
makemult(dwidth * maxAspectY / maxAspectX - dheight,
856 if(dheight + delta <= maxHeight) {
860 delta =
makemult(dwidth - maxAspectX * dheight / maxAspectY,
862 if(dwidth - delta >= minWidth) {
899 unsigned int junkbw, junkDepth;
900 int tmpX, tmpY, tmpW, tmpH;
913 XGetGeometry(
dpy, (Drawable) tmp_win->
frame, &junkRoot,
936 if(tmp_win->
zoomed == func) {
948 RLayout *borderedLayout = NULL;
950 int frame_bw_times_2;
953 if(tmp_win->winbox) {
954 XWindowAttributes winattrs;
955 if(XGetWindowAttributes(
dpy, tmp_win->winbox->window, &winattrs)) {
966 if(borderedLayout == NULL) {
967 borderedLayout =
Scr->BorderedLayout;
978 frame_bw_times_2 = 2 * tmp_win->
frame_bw;
1027 case F_XRIGHTZOOM: {
1029 dragWidth = limit - area.
x + 1 - frame_bw_times_2;
1035 dragWidth = limit - area.
x + 1 - frame_bw_times_2;
1049 case F_XBOTTOMZOOM: {
1051 dragHeight = limit - area.
y + 1 - frame_bw_times_2;
1055 case F_BOTTOMZOOM: {
1057 dragHeight = limit - area.
y + 1 - frame_bw_times_2;
1061 case F_FULLSCREENZOOM:
1062 case F_XFULLSCREENZOOM: {
1064 int bw3D_times_2 = 2 * bw3D;
1067 finalArea = func == F_XFULLSCREENZOOM
1070 dragx = finalArea.
x - bw;
1086 if(borderedLayout !=
Scr->BorderedLayout) {
1091 if(!
Scr->NoRaiseResize && func != F_FULLSCREENZOOM) {
1095 if(func != F_FULLSCREENZOOM) {
1099 if(func == F_ZOOM) {
1113 &junkRoot, &junkRoot,
1114 &tmpX, &tmpY, &tmpW, &tmpH, &junkDepth);
1119 XWarpPointer(
dpy,
Scr->Root, tmp_win->
w, 0, 0, 0, 0, 0, 0);
1139 if(tmp_win->
zoomed == F_FULLSCREENZOOM) {
1181 int change = 0, size = 0;
1183 int rx, ry, wx, wy, mr;
1188 wx = strtol(in_string, &endptr, 10);
1189 if(*endptr++ !=
'x') {
1191 "%s: Bad argument to f.changesize: \"%s\" (pattern \"640x480\")\n",
1195 wy = strtol(endptr, &endptr, 10);
1197 if(wy < tmp_win->title_height + 1) {
1208 while(in_string[cmdlen] !=
' ' && in_string[cmdlen] !=
'\0') {
1212 if(in_string[cmdlen] !=
' ') {
1214 "%s: Bad argument to f.changesize: \"%s\" (sizechange missing)\n",
1219 change = strtol(in_string + cmdlen + 1, &endptr, 10);
1222 "%s: Bad argument to f.changesize: \"%s\" (sizechange not a number)\n",
1227 if(strncmp(
"bottom", in_string, cmdlen) == 0) {
1238 XQueryPointer(
dpy, tmp_win->
w, &rr, &cr, &rx, &ry, &wx, &wy,
1239 (
unsigned int *)&mr);
1242 XWarpPointer(
dpy, None, tmp_win->
w, 0, 0, 0, 0, 0, 0);
1245 else if(strncmp(
"top", in_string, cmdlen) == 0) {
1256 XQueryPointer(
dpy, tmp_win->
w, &rr, &cr, &rx, &ry, &wx, &wy,
1257 (
unsigned int *)&mr);
1260 XWarpPointer(
dpy, None, tmp_win->
w, 0, 0, 0, 0, 0, 0);
1265 else if(strncmp(
"left", in_string, cmdlen) == 0) {
1276 XQueryPointer(
dpy, tmp_win->
w, &rr, &cr, &rx, &ry, &wx, &wy,
1277 (
unsigned int *)&mr);
1280 XWarpPointer(
dpy, None, tmp_win->
w, 0, 0, 0, 0, 0, 0);
1285 else if(strncmp(
"right", in_string, cmdlen) == 0) {
1296 XQueryPointer(
dpy, tmp_win->
w, &rr, &cr, &rx, &ry, &wx, &wy,
1297 (
unsigned int *)&mr);
1300 XWarpPointer(
dpy, None, tmp_win->
w, 0, 0, 0, 0, 0, 0);
1306 fprintf(stderr,
"%s: Bad argument to f.changesize: \"%s\"\n (unknown border)",
1324 int lastx, lasty, bw2;
1335 XWarpPointer(
dpy, None, w,
1347 ButtonPressMask | PointerMotionMask | ExposureMask, &
Event);
1349 if(
Event.type == MotionNotify) {
1351 while(XCheckMaskEvent(
dpy,
1352 ButtonMotionMask | ButtonPressMask, &
Event))
1353 if(
Event.type == ButtonPress) {
1358 if(
Event.type == ButtonPress) {
1365 if(
Event.type != MotionNotify) {
void UninstallRootColormap(void)
void InstallRootColormap(void)
#define FB(fix_fore, fix_back)
void Draw3DBorder(Window w, int x, int y, int width, int height, int bw, ColorPair cp, ButtonState state, bool fill, bool forcebw)
bool DispatchEvent2(void)
void EwmhSet_NET_WM_STATE(TwmWindow *twm_win, int changes)
#define EWMH_STATE_MAXIMIZED_VERT
int frame_x
X position on screen of frame.
int frame_y
Y position on screen of frame.
Window frame
The X window for the overall frame.
int frame_bw
2d border width.
unsigned int title_height
Height of the full title bar.
Cursor curcurs
Current resize cursor.
unsigned int frame_width
Width of frame.
unsigned int frame_height
Height of frame.
int frame_bw3D
3d border width.
void PackIconManager(IconMgr *ip)
void OtpSetAflag(TwmWindow *twm_win, unsigned flag)
void OtpRestackWindow(TwmWindow *twm_win)
void OtpClearAflag(TwmWindow *twm_win, unsigned flag)
void OtpRaise(TwmWindow *twm_win, WinType wintype)
RArea RAreaInvalid(void)
Return a facially-invalid RArea.
RArea RAreaNew(int x, int y, int width, int height)
Construct an RArea from given components.
bool RAreaIsValid(const RArea *self)
Is an RArea facially valid?
RAreaList * RAreaListNew(int cap,...)
Create an RAreaList from a set of RArea's.
void RLayoutFree(RLayout *self)
Clean up and free an RLayout.
RArea RLayoutFullVert1(const RLayout *self, const RArea *area)
Figure the best way to stretch an area vertically without crossing monitors.
int RLayoutFindBottomEdge(const RLayout *self, const RArea *area)
Find the bottom of the top stripe of self that area fits into.
int RLayoutFindRightEdge(const RLayout *self, const RArea *area)
Find the right edge of the left-most stripe of self that area fits into.
RArea RLayoutFullHoriz1(const RLayout *self, const RArea *area)
Figure the best way to stretch an area horizontally without crossing monitors.
int RLayoutFindMonitorTopEdge(const RLayout *self, const RArea *area)
Find the top edge of the bottom-most monitor that contains the most of a given RArea.
int RLayoutFindMonitorRightEdge(const RLayout *self, const RArea *area)
Find the right edge of the left-most monitor that contains the most of a given RArea.
int RLayoutFindLeftEdge(const RLayout *self, const RArea *area)
Find the left edge of the right-most stripe of self that area fits into.
int RLayoutFindMonitorBottomEdge(const RLayout *self, const RArea *area)
Find the bottom edge of the top-most monitor that contains the most of a given RArea.
RLayout * RLayoutNew(RAreaList *monitors)
Create an RLayout for a given set of monitors.
RArea RLayoutFull1(const RLayout *self, const RArea *area)
Figure the best way to resize an area to fill one monitor.
int RLayoutFindTopEdge(const RLayout *self, const RArea *area)
Find the top of the bottom stripe of self that area fits into.
RArea RLayoutFull(const RLayout *self, const RArea *area)
Figure the best way to stretch an area across the largest horizontal and vertical space it can from i...
RArea RLayoutFullHoriz(const RLayout *self, const RArea *area)
Figure the best way to stretch an area across the full horizontal width of an RLayout.
RArea RLayoutFullVert(const RLayout *self, const RArea *area)
Figure the best way to stretch an area across the full vertical height of an RLayout.
int RLayoutFindMonitorLeftEdge(const RLayout *self, const RArea *area)
Find the left edge of the right-most monitor that contains the most of a given RArea.
#define SIZE_VINDENT
Internal padding in the size window.
#define SIZE_HINDENT
Internal padding in the size window.
A particular extent of space.
The layout of our display.
unsigned int width
Saved width.
unsigned int height
Saved height.
Info and control for every X Window we take over.
bool isiconmgr
This is an icon manager window.
bool OpaqueResize
Resize opaquely.
int save_frame_y
y position of frame (saved from zoom)
Window w
The actual X Window handle.
int zoomed
ZOOM_NONE || function causing zoom.
unsigned int save_frame_width
width of frame (saved from zoom)
unsigned int save_frame_height
height of frame (saved from zoom)
XSizeHints hints
Window size hints.
struct IconMgr * iconmgrp
Pointer to the icon manager structure, for windows that are icon managers.
struct TwmWindow::_savegeometry savegeometry
Saved window geometry. "
XWindowAttributes attr
Window attributes from XGetWindowAttributes().
int save_frame_x
x position of frame (saved from zoom)
bool squeezed
Is the window squeezed ?
static int min(int a, int b)
void SetupWindow(TwmWindow *tmp_win, int x, int y, int w, int h, int bw)
void MoveOutline(Window root, int x, int y, int width, int height, int bw, int th)
static void DisplaySize(TwmWindow *tmp_win, int width, int height)
void ChangeSize(char *in_string, TwmWindow *tmp_win)
void StartResize(XEvent *evp, TwmWindow *tmp_win, bool fromtitlebar, bool from3dborder)
void MenuStartResize(TwmWindow *tmp_win, int x, int y, int w, int h)
void ConstrainSize(TwmWindow *tmp_win, unsigned int *widthp, unsigned int *heightp)
void unzoom(TwmWindow *tmp_win)
void restoregeometry(TwmWindow *tmp_win)
static void do_auto_clamp(TwmWindow *tmp_win, XEvent *evp)
static unsigned int dragWidth
void resizeFromCenter(Window w, TwmWindow *tmp_win)
void OpaqueResizeSize(TwmWindow *tmp_win)
void MenuEndResize(TwmWindow *tmp_win)
static unsigned int dragHeight
void AddEndResize(TwmWindow *tmp_win)
void AddStartResize(TwmWindow *tmp_win, int x, int y, int w, int h)
void DoResize(int x_root, int y_root, TwmWindow *tmp_win)
static unsigned int resizeGrabMask
void MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win)
void fullzoom(TwmWindow *tmp_win, int func)
void savegeometry(TwmWindow *tmp_win)
void MoveResizeSizeWindow(int x, int y, unsigned int width, unsigned int height)
TwmWindow * GetTwmWindow(Window w)
void WMapRaise(TwmWindow *win)