From 4de27730589a0e9ccd012dbd36737fd15047cdc7 Mon Sep 17 00:00:00 2001 From: Mike Small Date: Sat, 25 Aug 2018 15:01:34 -0400 Subject: [PATCH] Remove RandomPlacement and UsePPosition options. For now that means to behave as if RandomPlacement is true and UsePPosition is non-zero (use PPosition if the window position isn't (0,0). --- man/twmruined.man | 17 --- src/add_window.c | 308 +++------------------------------------------- src/parse.c | 38 ------ src/screen.h | 8 -- src/twm.c | 2 - 5 files changed, 14 insertions(+), 359 deletions(-) diff --git a/man/twmruined.man b/man/twmruined.man index 9aa162e..ad21242 100644 --- a/man/twmruined.man +++ b/man/twmruined.man @@ -554,10 +554,6 @@ work around bugs in older applications that have problems with focus events. This variable sets \fItwmruined\fP's priority. \fIpriority\fP should be an unquoted, signed number (e.g. 999). This variable has an effect only if the server supports the SYNC extension. -.IP "\fBRandomPlacement\fP" 8 -This variable indicates that windows with no specified geometry should -be placed in a pseudo-random location instead of having the user drag out -an outline. .IP "\fBResizeFont\fP \fIstring\fP" 8 This variable specifies the font to be used for in the dimensions window when resizing windows. The default is "fixed". @@ -625,19 +621,6 @@ This variable specifies the filename of a bitmap file to be used as the default icon. This bitmap will be used as the icon of all clients which do not provide an icon bitmap and are not listed in the \fBIcons\fP list. -.IP "\fBUsePPosition\fP \fIstring\fP" 8 -This variable specifies whether or not \fItwmruined\fP should honor -program-requested locations (given by the \fBPPosition\fP flag in the -WM_NORMAL_HINTS property) in the absence of a user-specified position. -The argument \fIstring\fP may have one of three values: \fB"off"\fP -(the default) -indicating that \fItwmruined\fP -should ignore the program-supplied position, -\fB"on"\fP indicating that the position -should be used, and -\fB"non-zero"\fP indicating that the position should used if -it is other than (0,0). The latter option is for working around a bug in -older toolkits. .IP "\fBWarpCursor\fP [{ \fIwin-list\fP }]" 8 This variable indicates that the pointer should be warped into windows when they are deiconified. If the optional \fIwin-list\fP is given, the pointer diff --git a/src/add_window.c b/src/add_window.c index 333d6be..3d1bae6 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -144,12 +144,9 @@ TwmWindow * AddWindow(Window w) { TwmWindow *tmp_win; /* new twm window structure */ - int stat; - XEvent event; unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ - int width, height; /* tmp variable */ - int ask_user; /* don't know where to put the window */ + int random_placement; /* don't know where to put the window */ int gravx, gravy; /* gravity signs for positioning */ int namelen; int bw2; @@ -341,32 +338,29 @@ AddWindow(Window w) } else { - GetGravityOffsets (tmp_win, &gravx, &gravy); + GetGravityOffsets(tmp_win, &gravx, &gravy); } /* - * Don't bother user if: + * Random placement is used when... * - * o the window is a transient, or + * o the window is not a transient, and * - * o a USPosition was requested, or + * o a USPosition was not requested, and * - * o a PPosition was requested and UsePPosition is ON or - * NON_ZERO if the window is at other than (0,0) + * o a PPosition was not requested or it was and the window is not at (0,0) + * + * According to twm's man page, not respecting PPosition = (0,0) + * avoids problems with old toolkits. */ - ask_user = TRUE; - if (tmp_win->transient || - (tmp_win->hints.flags & USPosition) || - ((tmp_win->hints.flags & PPosition) && Scr->UsePPosition && - (Scr->UsePPosition == PPOS_ON || - tmp_win->attr.x != 0 || tmp_win->attr.y != 0))) - ask_user = FALSE; + random_placement = !tmp_win->transient && !(tmp_win->hints.flags & USPosition) + && !((tmp_win->hints.flags & PPosition) + && (tmp_win->attr.x != 0 || tmp_win->attr.y != 0)); /* - * do any prompting for position + * set window position */ - if (HandlingEvents && ask_user && !restoredFromPrevSession) { - if (Scr->RandomPlacement) { /* just stick it somewhere */ + if (HandlingEvents && random_placement && !restoredFromPrevSession) { if ((PlaceX + tmp_win->attr.width) > Scr->MyDisplayWidth) PlaceX = 50; if ((PlaceY + tmp_win->attr.height) > Scr->MyDisplayHeight) @@ -376,280 +370,6 @@ AddWindow(Window w) tmp_win->attr.y = PlaceY; PlaceX += 30; PlaceY += 30; - } else { /* else prompt */ - if (!(tmp_win->wmhints && tmp_win->wmhints->flags & StateHint && - tmp_win->wmhints->initial_state == IconicState)) - { - Bool firsttime = True; - - /* better wait until all the mouse buttons have been - * released. - */ - while (TRUE) - { - XUngrabServer(dpy); - XSync(dpy, 0); - XGrabServer(dpy); - - JunkMask = 0; - if (!XQueryPointer (dpy, Scr->Root, &JunkRoot, - &JunkChild, &JunkX, &JunkY, - &AddingX, &AddingY, &JunkMask)) - JunkMask = 0; - - JunkMask &= (Button1Mask | Button2Mask | Button3Mask | - Button4Mask | Button5Mask); - - /* - * watch out for changing screens - */ - if (firsttime) { - if (JunkRoot != Scr->Root) { - register int scrnum; - - for (scrnum = 0; scrnum < NumScreens; scrnum++) { - if (JunkRoot == RootWindow (dpy, scrnum)) break; - } - - if (scrnum != NumScreens) PreviousScreen = scrnum; - } - firsttime = False; - } - - /* - * wait for buttons to come up; yuck - */ - if (JunkMask != 0) continue; - - /* - * this will cause a warp to the indicated root - */ - stat = XGrabPointer(dpy, Scr->Root, False, - ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | PointerMotionHintMask, - GrabModeAsync, GrabModeAsync, - Scr->Root, UpperLeftCursor, CurrentTime); - - if (stat == GrabSuccess) - break; - } - - width = (SIZE_HINDENT + MyFont_TextWidth (&Scr->SizeFont, - tmp_win->name, namelen)); - height = Scr->SizeFont.height + SIZE_VINDENT * 2; - - XResizeWindow (dpy, Scr->SizeWindow, width + SIZE_HINDENT, height); - XMapRaised(dpy, Scr->SizeWindow); - InstallRootColormap(); - - MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back, - &Scr->SizeFont); - MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, - Scr->NormalGC, - SIZE_HINDENT, - SIZE_VINDENT + Scr->SizeFont.ascent, - tmp_win->name, namelen); - - AddingW = tmp_win->attr.width + bw2; - AddingH = tmp_win->attr.height + tmp_win->title_height + bw2; - - if (Scr->DontMoveOff) { - /* - * Make sure the initial outline comes up on the screen. - */ - if (AddingX < 0) - AddingX = 0; - if (AddingX > Scr->MyDisplayWidth - AddingW) - AddingX = Scr->MyDisplayWidth - AddingW; - - if (AddingY < 0) - AddingY = 0; - if (AddingY > Scr->MyDisplayHeight - AddingH) - AddingY = Scr->MyDisplayHeight - AddingH; - } - - MoveOutline(Scr->Root, AddingX, AddingY, AddingW, AddingH, - tmp_win->frame_bw, tmp_win->title_height); - - while (TRUE) - { - XMaskEvent(dpy, ButtonPressMask | PointerMotionMask, &event); - - if (Event.type == MotionNotify) { - /* discard any extra motion events before a release */ - while(XCheckMaskEvent(dpy, - ButtonMotionMask | ButtonPressMask, &Event)) - if (Event.type == ButtonPress) - break; - } - - if (event.type == ButtonPress) { - AddingX = event.xbutton.x_root; - AddingY = event.xbutton.y_root; - - /* DontMoveOff prohibits user form off-screen placement */ - if (Scr->DontMoveOff) - { - int AddingR, AddingB; - - AddingR = AddingX + AddingW; - AddingB = AddingY + AddingH; - - if (AddingX < 0) - AddingX = 0; - if (AddingR > Scr->MyDisplayWidth) - AddingX = Scr->MyDisplayWidth - AddingW; - - if (AddingY < 0) - AddingY = 0; - if (AddingB > Scr->MyDisplayHeight) - AddingY = Scr->MyDisplayHeight - AddingH; - - } - break; - } - - if (event.type != MotionNotify) { - continue; - } - - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, - &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); - - if (Scr->DontMoveOff) - { - int AddingR, AddingB; - - AddingR = AddingX + AddingW; - AddingB = AddingY + AddingH; - - if (AddingX < 0) - AddingX = 0; - if (AddingR > Scr->MyDisplayWidth) - AddingX = Scr->MyDisplayWidth - AddingW; - - if (AddingY < 0) - AddingY = 0; - if (AddingB > Scr->MyDisplayHeight) - AddingY = Scr->MyDisplayHeight - AddingH; - } - - MoveOutline(Scr->Root, AddingX, AddingY, AddingW, AddingH, - tmp_win->frame_bw, tmp_win->title_height); - - } - - if (event.xbutton.button == Button2) { - int lastx, lasty; - - Scr->SizeStringOffset = width + - MyFont_TextWidth(&Scr->SizeFont, ": ", 2); - XResizeWindow (dpy, Scr->SizeWindow, Scr->SizeStringOffset + - Scr->SizeStringWidth, height); - MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, - Scr->NormalGC, width, - SIZE_VINDENT + Scr->SizeFont.ascent, - ": ", 2); - if (0/*Scr->AutoRelativeResize*/) { - int dx = (tmp_win->attr.width / 4); - int dy = (tmp_win->attr.height / 4); - -#define HALF_AVE_CURSOR_SIZE 8 /* so that it is visible */ - if (dx < HALF_AVE_CURSOR_SIZE) dx = HALF_AVE_CURSOR_SIZE; - if (dy < HALF_AVE_CURSOR_SIZE) dy = HALF_AVE_CURSOR_SIZE; -#undef HALF_AVE_CURSOR_SIZE - dx += (tmp_win->frame_bw + 1); - dy += (bw2 + tmp_win->title_height + 1); - if (AddingX + dx >= Scr->MyDisplayWidth) - dx = Scr->MyDisplayWidth - AddingX - 1; - if (AddingY + dy >= Scr->MyDisplayHeight) - dy = Scr->MyDisplayHeight - AddingY - 1; - if (dx > 0 && dy > 0) - XWarpPointer (dpy, None, None, 0, 0, 0, 0, dx, dy); - } else { - XWarpPointer (dpy, None, Scr->Root, 0, 0, 0, 0, - AddingX + AddingW/2, AddingY + AddingH/2); - } - AddStartResize(tmp_win, AddingX, AddingY, AddingW, AddingH); - - lastx = -10000; - lasty = -10000; - while (TRUE) - { - XMaskEvent(dpy, - ButtonReleaseMask | ButtonMotionMask, &event); - - if (Event.type == MotionNotify) { - /* discard any extra motion events before a release */ - while(XCheckMaskEvent(dpy, - ButtonMotionMask | ButtonReleaseMask, &Event)) - if (Event.type == ButtonRelease) - break; - } - - if (event.type == ButtonRelease) - { - AddEndResize(tmp_win); - break; - } - - if (event.type != MotionNotify) { - continue; - } - - /* - * XXX - if we are going to do a loop, we ought to consider - * using multiple GXxor lines so that we don't need to - * grab the server. - */ - XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, - &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); - - if (lastx != AddingX || lasty != AddingY) - { - DoResize(AddingX, AddingY, tmp_win); - - lastx = AddingX; - lasty = AddingY; - } - - } - } - else if (event.xbutton.button == Button3) - { - int maxw = Scr->MyDisplayWidth - AddingX - bw2; - int maxh = Scr->MyDisplayHeight - AddingY - bw2; - - /* - * Make window go to bottom of screen, and clip to right edge. - * This is useful when popping up large windows and fixed - * column text windows. - */ - if (AddingW > maxw) AddingW = maxw; - AddingH = maxh; - - ConstrainSize (tmp_win, &AddingW, &AddingH); /* w/o borders */ - AddingW += bw2; - AddingH += bw2; - } - else - { - XMaskEvent(dpy, ButtonReleaseMask, &event); - } - - MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0); - XUnmapWindow(dpy, Scr->SizeWindow); - UninstallRootColormap(); - XUngrabPointer(dpy, CurrentTime); - - tmp_win->attr.x = AddingX; - tmp_win->attr.y = AddingY + tmp_win->title_height; - tmp_win->attr.width = AddingW - bw2; - tmp_win->attr.height = AddingH - tmp_win->title_height - bw2; - - XUngrabServer(dpy); - } - } } else { /* put it where asked, mod title bar */ /* if the gravity is towards the top, move it by the title height */ if (gravy < 0) tmp_win->attr.y -= gravy * tmp_win->title_height; diff --git a/src/parse.c b/src/parse.c index cfc8fc6..a8e9e80 100644 --- a/src/parse.c +++ b/src/parse.c @@ -86,7 +86,6 @@ static unsigned char **stringListSource, *currentString; static int doparse ( int (*ifunc)(void), const char *srctypename, const char *srcname ); static int twmFileInput ( void ); static int twmStringListInput ( void ); -static int ParseUsePPosition ( char *s ); static int ParseStringList ( unsigned char **sl ); extern int yylineno; @@ -325,12 +324,10 @@ typedef struct _TwmKeyword { #define kw0_RestartPreviousState 17 #define kw0_ClientBorderWidth 18 #define kw0_NoTitleFocus 19 -#define kw0_RandomPlacement 20 #define kw0_DecorateTransients 21 #define kw0_NoRaiseOnWarp 24 #define kw0_WarpUnmapped 25 -#define kws_UsePPosition 1 #define kws_IconFont 2 #define kws_ResizeFont 3 #define kws_MenuFont 4 @@ -512,7 +509,6 @@ static TwmKeyword keytable[] = { { "pointerforeground", CKEYWORD, kwc_PointerForeground }, { "priority", NKEYWORD, kwn_Priority }, { "r", ROOT, 0 }, - { "randomplacement", KEYWORD, kw0_RandomPlacement }, { "resize", RESIZE, 0 }, { "resizefont", SKEYWORD, kws_ResizeFont }, { "restartpreviousstate", KEYWORD, kw0_RestartPreviousState }, @@ -533,7 +529,6 @@ static TwmKeyword keytable[] = { { "titleforeground", CLKEYWORD, kwcl_TitleForeground }, { "titlepadding", NKEYWORD, kwn_TitlePadding }, { "unknownicon", SKEYWORD, kws_UnknownIcon }, - { "usepposition", SKEYWORD, kws_UsePPosition }, { "w", WINDOW, 0 }, { "wait", WAIT, 0 }, { "warpcursor", WARP_CURSOR, 0 }, @@ -643,10 +638,6 @@ int do_single_keyword (int keyword) Scr->TitleFocus = FALSE; return 1; - case kw0_RandomPlacement: - Scr->RandomPlacement = TRUE; - return 1; - case kw0_DecorateTransients: Scr->DecorateTransients = TRUE; return 1; @@ -667,19 +658,6 @@ int do_single_keyword (int keyword) int do_string_keyword (int keyword, char *s) { switch (keyword) { - case kws_UsePPosition: - { - int ppos = ParseUsePPosition (s); - if (ppos < 0) { - twmrc_error_prefix(); - fprintf (stderr, - "ignoring invalid UsePPosition argument \"%s\"\n", s); - } else { - Scr->UsePPosition = ppos; - } - return 1; - } - case kws_IconFont: if (!Scr->HaveFonts) Scr->IconFont.name = s; return 1; @@ -966,19 +944,3 @@ assign_var_savecolor(void) } } -static int -ParseUsePPosition (char *s) -{ - XmuCopyISOLatin1Lowered (s, s); - - if (strcmp (s, "off") == 0) { - return PPOS_OFF; - } else if (strcmp (s, "on") == 0) { - return PPOS_ON; - } else if (strcmp (s, "non-zero") == 0 || - strcmp (s, "nonzero") == 0) { - return PPOS_NON_ZERO; - } - - return -1; -} diff --git a/src/screen.h b/src/screen.h index 2fce2b7..b5c5ac9 100644 --- a/src/screen.h +++ b/src/screen.h @@ -193,7 +193,6 @@ typedef struct ScreenInfo int ButtonIndent; /* amount to shrink buttons on each side */ int NumAutoRaises; /* number of autoraise windows on screen */ short NoDefaults; /* do not add in default UI stuff */ - short UsePPosition; /* what do with PPosition, see values below */ short AutoRelativeResize; /* start resize relative to position in quad */ short FocusRoot; /* is the input focus on the root ? */ short WarpCursor; /* warp cursor on de-iconify ? */ @@ -210,7 +209,6 @@ typedef struct ScreenInfo short DecorateTransients; /* put title bars on transients */ short BackingStore; /* use backing store for menus */ short SaveUnder; /* use save under's for menus */ - short RandomPlacement; /* randomly place windows that no give hints */ short StackMode; /* should we honor stack mode requests */ short MoveDelta; /* number of pixels before f.move starts */ short ZoomCount; /* zoom outline count */ @@ -231,10 +229,4 @@ extern ScreenInfo **ScreenList; extern ScreenInfo *Scr; extern int FirstScreen; -#define PPOS_OFF 0 -#define PPOS_ON 1 -#define PPOS_NON_ZERO 2 -/* may eventually want an option for having the PPosition be the initial - location for the drag lines */ - #endif /* _SCREEN_ */ diff --git a/src/twm.c b/src/twm.c index 38c9586..1738415 100644 --- a/src/twm.c +++ b/src/twm.c @@ -703,7 +703,6 @@ InitVariables(void) Scr->UnknownHeight = 0; Scr->NumAutoRaises = 0; Scr->NoDefaults = FALSE; - Scr->UsePPosition = PPOS_OFF; Scr->FocusRoot = TRUE; Scr->Focus = NULL; Scr->WarpCursor = FALSE; @@ -720,7 +719,6 @@ InitVariables(void) Scr->DecorateTransients = FALSE; Scr->BackingStore = TRUE; Scr->SaveUnder = TRUE; - Scr->RandomPlacement = FALSE; Scr->StackMode = TRUE; Scr->MoveDelta = 1; /* so that f.deltastop will work */ Scr->ZoomCount = 8;