Index: .cvsignore =================================================================== RCS file: .cvsignore diff -N .cvsignore --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ .cvsignore 8 Mar 1998 23:43:56 -0000 1.1 @@ -0,0 +1,6 @@ +Makefile +lex.c +gram.h +gram.c +deftwmrc.c +ctwm Index: Imakefile =================================================================== RCS file: /u/monnier/cvsroot/ctwm/Imakefile,v retrieving revision 1.1.1.8 retrieving revision 1.11 diff -u -r1.1.1.8 -r1.11 --- Imakefile 2 Apr 2005 23:00:28 -0000 1.1.1.8 +++ Imakefile 3 Apr 2005 16:35:58 -0000 1.11 @@ -13,7 +13,7 @@ #define XPM #define JPEG #define USEM4 -#define GNOME +#undef GNOME #define X11R6 #undef I18N #undef USE_GNU_REGEX @@ -61,8 +61,8 @@ #endif #ifdef IMCONV - IMCONVLIBDIR = -L/logiciels/public/graphix/lib - IMCONVINCDIR = -I/logiciels/public/graphix/include + IMCONVLIBDIR = + IMCONVINCDIR = IMCONVDEFINES = -DIMCONV IMCONVLIB = $(IMCONVLIBDIR) -lim -lsdsc #else @@ -135,12 +135,14 @@ SRCS = gram.c lex.c deftwmrc.c add_window.c gc.c list.c ctwm.c \ parse.c menus.c events.c resize.c util.c version.c iconmgr.c \ - cursor.c icons.c workmgr.c windowbox.c clicktofocus.c vscreen.c \ + cursor.c icons.c workmgr.c otp.c \ + windowbox.c clicktofocus.c vscreen.c \ $(GNOMESRC) ${SESSIONSRC} ${SOUNDSRC} OBJS = gram.o lex.o deftwmrc.o add_window.o gc.o list.o ctwm.o \ parse.o menus.o events.o resize.o util.o version.o iconmgr.o \ - cursor.o icons.o workmgr.o windowbox.o clicktofocus.o vscreen.o \ + cursor.o icons.o workmgr.o otp.o \ + windowbox.o clicktofocus.o vscreen.o \ $(GNOMEOBJ) ${SESSIONOBJ} ${SOUNDOBJ} PIXMAPFILES = xpm/IslandD.xpm xpm/mail1.xpm xpm/xgopher.xpm \ Index: README.VMS =================================================================== RCS file: README.VMS diff -N README.VMS --- README.VMS 2 Apr 2005 23:00:29 -0000 1.1.1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,123 +0,0 @@ -To compile and install ctwm on VMS machines: - -Unpacking and configuration: ----------------------------- - -0) You must have the X miscellaneous utilities and X extension libraries. - Possibly, also have some unix type tools such as tar and gzip - (get these from ftp.spc.edu in macros32/savesets). - -1) Get the latest xpm library (at time of writing, 3.4) and compile that - first. This is used for coloured icons. (There should be many sites that - have a copy of xpm, try using Archie to find a site near you.) - -2) Copy the xpm.h file from the xpm distribution to the ctwm source directory. - -3) Edit the make.com or descrip.mms file to change x11xmu, x11xmulib, - x11lib and EXIT_ENDSESSION logicals or symbols to point to your own set-up. - - About EXIT_ENDSESSION, see warning W1 below. - -Compilation and linking: ------------------------- - -4) IF YOU DOWNLOADED A PACKAGE WITH OBJECT FILES, you only need to link - ctwm, doing "@link.com". Then go to step 7). - -5) You do not need to rename the files with _VMS extensions any more. - -6) compile ctwm, either with make.com by doing "@make", or with descrip.mms - by doing "mms/ign=w". - -[ N.B.: WHEN LINKING object files that have been compiled with VAX C - (*.VAX_VAXC_OBJ), the linker may complain about two undefined symbols. - They are however not refered to anywhere, so this is completelly harmless. - The two symbols are COLORCONVERTARGS and SCREENCONVERTARG. - /Richard Levitte ] - -[ N.B.2: The resulting executable will have the name CTWM.VAX_EXE or - CTWM.AXP_EXE! This because you may want to compile or link for both - architectures in the same directory. /Richard Levitte ] - -Installation: -------------- - -7) When ctwm has been successfully built, work out where to put the xpm - icons, say disk$users:[joe.xpm]. Edit the file ctwm.com and change it to - suit you. - -8) Create your user config file ctwm.rc and put it in DECW$USER_DEFAULTS. - Now is the time to read the man page on ctwm. Be sure to read vms.txt for - differences between the Unix ctwm and the VMS version. - (See peterc.ctwmrc or levitte_system.ctwmrc, for an example config file.) - -9) [Optional] Create your own system default config file system.ctwmrc - and put it in DECW$SYSTEM_DEFAULTS. - -10) Go to the session manager and under the Options menu pick out the - "Menus..." item. Make a menu item called "CT Window Manager" and enter the - DCL command "@disk$users:[joe.com]ctwm.com", as an example. - -11) Go to the session manager, again, and under the Options menu pick out - the "Automatic Startup..." item. Take out your current window manager - and replace it with ctwm using the "CT Window Manager" item you just - created. - -12) Now all is done. Exit from the session and log back in to try out ctwm. - - -WARNINGS: ---------- - -W1) [THIS APPLIES ON VAX ONLY!] - - It seems like some older DECwindows/Motif versions end their session - like this: - - %decw$endsession -vueimage sys$system:.exe - - this is an internal Session Manager command. If this is how it's - done on your machine, you'd better not use the session ending features - of ctwm at all, or you won't get back a login prompt when you end - your session. In such a case, EXIT_ENDSESSION must be set to 0, or - you may get into trouble. - -W2) Bitmap (xbm) files are sometimes stored in files with no extensions - on older Unix X11 releases, which makes definitions like this work - on those ("plaid" is the culprit here): - - WorkSpaces { - "One" {"#619AAE" "white" "firebrick" "white" "plaid"} - } - - Since those files have never been stored without extension on VMS, - you have to rewrite such definitions like this: - - WorkSpaces { - "One" {"#619AAE" "white" "firebrick" "white" "plaid.xbm"} - } - - I has been discussed if you couldn't add a "dna=.xbm" parameter to - the open() or fopen() that opens the bitmap file. This would of - course have been possible, if the loading of bitmap files wasn't - done through the function XmuLocateBitmapFile(). Of course, you - could as well hack ExpandFilename(), but that is less clean. The - Xmu library needs to be enhanced for this task. - - -Ctwm 3.3 ported by Peter Chang - peterc@v2.ph.man.ac.uk 4/5/94. -Ctwm 3.4pl2 and 3.5 further ported by Richard Levitte - - -Thank you: ----------- - -A thank you goes to the following people: - - Claude Lecommandeur , for making ctwm - to begin with. - Peter Chang , for the previous ports. - - Michael Lemke - -/Richard Levitte, Index: add_window.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/add_window.c,v retrieving revision 1.1.1.13 retrieving revision 1.12 diff -u -r1.1.1.13 -r1.12 --- add_window.c 2 Apr 2005 23:00:25 -0000 1.1.1.13 +++ add_window.c 3 Apr 2005 16:35:58 -0000 1.12 @@ -86,6 +86,7 @@ #include "add_window.h" #include "windowbox.h" #include "util.h" +#include "otp.h" #include "resize.h" #include "parse.h" #include "gram.h" @@ -95,6 +96,7 @@ #include "screen.h" #include "icons.h" #include "iconmgr.h" +#include "session.h" #define gray_width 2 #define gray_height 2 @@ -120,9 +122,6 @@ char NoName[] = "Untitled"; /* name if no name is specified */ int resizeWhenAdd; -extern Atom _OL_WIN_ATTR; -extern int captive; - #if defined(__hpux) && !defined(_XPG4_EXTENDED) # define FDSET int* #else @@ -137,7 +136,7 @@ ************************************************************************ */ -GetGravityOffsets (tmp, xp, yp) +void GetGravityOffsets (tmp, xp, yp) TwmWindow *tmp; /* window from which to get gravity */ int *xp, *yp; /* return values */ { @@ -224,7 +223,7 @@ int saved_occupation; /* <== [ Matthew McNeill Feb 1997 ] == */ #endif Bool random_placed = False; - int found; + int found = 0; #ifndef VMS fd_set mask; int fd; @@ -390,9 +389,6 @@ (!LookInList(Scr->NoStackModeL, tmp_win->full_name, &tmp_win->class)); - tmp_win->ontoppriority = (LookInList(Scr->AlwaysOnTopL, - tmp_win->full_name, &tmp_win->class)) ? ONTOP_MAX : ONTOP_DEFAULT; - tmp_win->titlehighlight = Scr->TitleHighlight && (!(short)(int) LookInList(Scr->NoTitleHighlight, tmp_win->full_name, &tmp_win->class)); @@ -1177,7 +1173,7 @@ else tmp_win->gray = None; - RaiseWindow(tmp_win); + OtpAdd(tmp_win, WinWin); if (tmp_win->title_w) { ComputeTitleLocation (tmp_win); @@ -1359,7 +1355,7 @@ AddFuncButton (button, context, modifier, func, NULL, NULL); } -AddDefaultBindings () +void AddDefaultBindings () { #define NoModifierMask 0 @@ -1627,7 +1623,7 @@ gc = XCreateGC (dpy, pm, (GCForeground|GCBackground|GCGraphicsExposures), &gcv); if (gc) { XCopyPlane (dpy, bm, pm, gc, 0, 0, gray_width, gray_height, 0, 0, 1); - tmp_win->HiliteImage = (Image*) malloc (sizeof (struct _Image)); + tmp_win->HiliteImage = (Image*) malloc (sizeof (Image)); tmp_win->HiliteImage->pixmap = pm; tmp_win->HiliteImage->width = gray_width; tmp_win->HiliteImage->height = gray_height; @@ -1928,7 +1924,7 @@ } -SetHighlightPixmap (filename) +void SetHighlightPixmap (filename) char *filename; { #ifdef VMS @@ -1941,7 +1937,7 @@ } -FetchWmProtocols (tmp) +void FetchWmProtocols (tmp) TwmWindow *tmp; { unsigned long flags = 0L; @@ -2038,7 +2034,7 @@ return (cwin); } -FetchWmColormapWindows (tmp) +void FetchWmColormapWindows (tmp) TwmWindow *tmp; { register int i, j; @@ -2047,12 +2043,12 @@ int number_cmap_windows = 0; ColormapWindow **cwins = NULL; int previously_installed; - extern void free_cwins(); number_cmap_windows = 0; - if (/* SUPPRESS 560 */previously_installed = - (Scr->cmapInfo.cmaps == &tmp->cmaps && tmp->cmaps.number_cwins)) { + previously_installed = + (Scr->cmapInfo.cmaps == &tmp->cmaps && tmp->cmaps.number_cwins); + if (previously_installed) { cwins = tmp->cmaps.cwins; for (i = 0; i < tmp->cmaps.number_cwins; i++) cwins[i]->colormap->state = 0; @@ -2163,8 +2159,6 @@ else XFree ((char *) cmap_windows); } - - return (0); } @@ -2195,7 +2189,7 @@ } } -AnimateButton (tbw) +void AnimateButton (tbw) TBWindow *tbw; { Image *image; @@ -2208,7 +2202,7 @@ tbw->image = image->next; } -AnimateHighlight (t) +void AnimateHighlight (t) TwmWindow *t; { Image *image; Index: add_window.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/add_window.h,v retrieving revision 1.1.1.4 retrieving revision 1.4 diff -u -r1.1.1.4 -r1.4 --- add_window.h 8 Mar 1998 23:45:09 -0000 1.1.1.4 +++ add_window.h 11 Mar 1998 04:32:38 -0000 1.4 @@ -64,20 +64,23 @@ #ifndef _ADD_WINDOW_ #define _ADD_WINDOW_ +#include "typedefs.h" +#include + extern char NoName[]; extern int resizeWhenAdd; -extern int GetGravityOffsets (); +extern void GetGravityOffsets (); extern TwmWindow *AddWindow(); extern int MappedNotOverride(); -extern AddDefaultBindings (); +extern void AddDefaultBindings (); extern void GrabButtons(); extern void GrabKeys(); extern void UngrabButtons(); extern void UngrabKeys(); extern void GetWindowSizeHints(); -extern int AnimateButton (); -extern int AnimateHighlight (); +extern void AnimateButton (); +extern void AnimateHighlight (); extern void CreateWindowRegions (); extern Bool PlaceWindowInRegion (); extern void RemoveWindowFromRegion (); @@ -91,8 +94,13 @@ extern char *GetWMPropertyString(); #endif /* NO_LOCALE */ -extern SetHighlightPixmap (); -extern FetchWmColormapWindows (); -extern FetchWmProtocols (); +ColormapWindow *CreateColormapWindow (Window w, Bool creating_parent, + Bool property_window); +TwmColormap *CreateTwmColormap (Colormap c); + +extern void SetHighlightPixmap (); +extern void FetchWmColormapWindows (); +extern void FetchWmProtocols (); + #endif /* _ADD_WINDOW_ */ Index: alloca.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/alloca.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- alloca.c 8 Mar 1998 23:45:17 -0000 1.1.1.1 +++ alloca.c 11 Mar 1998 04:32:38 -0000 1.2 @@ -69,6 +69,7 @@ typedef char *pointer; typedef int procedure; #endif +#include #define NULL 0 @@ -100,8 +101,6 @@ #endif #endif #endif -extern pointer malloc (); -extern procedure free (); /* Define STACK_DIRECTION if you know the direction of stack growth for your system; otherwise it will be automatically Index: ctwm.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/ctwm.c,v retrieving revision 1.1.1.14 retrieving revision 1.10 diff -u -r1.1.1.14 -r1.10 --- ctwm.c 2 Apr 2005 23:00:26 -0000 1.1.1.14 +++ ctwm.c 3 Apr 2005 16:35:58 -0000 1.10 @@ -73,6 +73,7 @@ #include #include +#include #ifdef __WAIT_FOR_CHILDS # include @@ -95,6 +96,12 @@ #include "screen.h" #include "icons.h" #include "iconmgr.h" +#include "session.h" +#include "list.h" +#include "otp.h" +#ifdef SOUNDS +#include "sound.h" +#endif #ifdef VMS # include # include @@ -167,9 +174,8 @@ char *InitFile = NULL; static Window CreateRootWindow (); static void DisplayInfo (); -int InternUsefulAtoms (); -int InitVariables(); -int CreateFonts(); +static void InternUsefulAtoms (void); +static void InitVariables(void); Cursor UpperLeftCursor; Cursor TopRightCursor, @@ -199,7 +205,6 @@ Window captiveroot; char *Home; /* the HOME environment variable */ int HomeLen; /* length of Home */ -int ParseError; /* error parsing the .twmrc file */ int HandlingEvents = FALSE; /* are we handling events yet? */ @@ -225,15 +230,12 @@ unsigned long black, white; -extern void assign_var_savecolor(); SIGNAL_T Restart(); SIGNAL_T Crash(); #ifdef __WAIT_FOR_CHILDS SIGNAL_T ChildExit(); #endif -extern Atom _XA_WM_WORKSPACESLIST; - /*********************************************************************** * * Procedure: @@ -242,6 +244,7 @@ *********************************************************************** */ +int #ifdef VMS main(int argc, char **argv) #else @@ -258,7 +261,6 @@ unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ int numManaged, firstscrn, lastscrn, scrnum; - extern ColormapWindow *CreateColormapWindow(); #ifdef X11R6 int zero = 0; char *restore_filename = NULL; @@ -573,6 +575,8 @@ Scr->TitleBackgroundL = NULL; Scr->IconForegroundL = NULL; Scr->IconBackgroundL = NULL; + Scr->AutoPopupL = NULL; + Scr->AutoPopup = FALSE; Scr->NoBorder = NULL; Scr->NoIconTitle = NULL; Scr->NoTitle = NULL; @@ -584,11 +588,12 @@ Scr->AlwaysSqueezeToGravityL = NULL; Scr->MakeTitle = NULL; Scr->AutoRaise = NULL; + Scr->WarpOnDeIconify = NULL; Scr->AutoLower = NULL; Scr->IconNames = NULL; Scr->NoHighlight = NULL; Scr->NoStackModeL = NULL; - Scr->AlwaysOnTopL = NULL; + Scr->OTP = NULL; Scr->NoTitleHighlight = NULL; Scr->DontIconify = NULL; Scr->IconMgrNoShow = NULL; @@ -953,7 +958,7 @@ *********************************************************************** */ -InitVariables() +static void InitVariables (void) { FreeList(&Scr->BorderColorL); FreeList(&Scr->IconBorderColorL); @@ -966,17 +971,19 @@ FreeList(&Scr->IconManagerFL); FreeList(&Scr->IconManagerBL); FreeList(&Scr->IconMgrs); + FreeList(&Scr->AutoPopupL); FreeList(&Scr->NoBorder); FreeList(&Scr->NoIconTitle); FreeList(&Scr->NoTitle); FreeList(&Scr->OccupyAll); FreeList(&Scr->MakeTitle); FreeList(&Scr->AutoRaise); + FreeList(&Scr->WarpOnDeIconify); FreeList(&Scr->AutoLower); FreeList(&Scr->IconNames); FreeList(&Scr->NoHighlight); FreeList(&Scr->NoStackModeL); - FreeList(&Scr->AlwaysOnTopL); + OtpScrInitData(Scr); FreeList(&Scr->NoTitleHighlight); FreeList(&Scr->DontIconify); FreeList(&Scr->IconMgrNoShow); @@ -1082,6 +1089,7 @@ Scr->MenuShadowDepth = 2; Scr->IconManagerShadowDepth = 2; Scr->AutoOccupy = FALSE; + Scr->AutoPriority = FALSE; Scr->TransientHasOccupation = FALSE; Scr->DontPaintRootWindow = FALSE; Scr->IconManagerDontShow = FALSE; @@ -1200,7 +1208,7 @@ } -CreateFonts () +void CreateFonts (void) { GetFont(&Scr->TitleBarFont); GetFont(&Scr->MenuFont); @@ -1213,7 +1221,7 @@ } -RestoreWithdrawnLocation (tmp) +void RestoreWithdrawnLocation (tmp) TwmWindow *tmp; { int gravx, gravy; @@ -1266,7 +1274,7 @@ int xbox, ybox; if (XGetGeometry (dpy, tmp->frame, &JunkRoot, &xbox, &ybox, &JunkWidth, &JunkHeight, &bw, &JunkDepth)) { - XReparentWindow (dpy, tmp->frame, Scr->Root, xbox, ybox); + ReparentWindow (dpy, tmp, WinWin, Scr->Root, xbox, ybox); } } XConfigureWindow (dpy, tmp->w, mask, &xwc); @@ -1444,6 +1452,7 @@ Atom _XA_WM_TAKE_FOCUS; Atom _XA_WM_SAVE_YOURSELF; Atom _XA_WM_DELETE_WINDOW; +Atom _XA_WM_END_OF_ANIMATION; Atom _XA_WM_CLIENT_MACHINE; #ifdef X11R6 Atom _XA_SM_CLIENT_ID; @@ -1451,7 +1460,7 @@ Atom _XA_WM_WINDOW_ROLE; #endif -InternUsefulAtoms () +static void InternUsefulAtoms (void) { /* * Create priority colors if necessary. @@ -1464,6 +1473,7 @@ _XA_WM_TAKE_FOCUS = XInternAtom (dpy, "WM_TAKE_FOCUS", False); _XA_WM_SAVE_YOURSELF = XInternAtom (dpy, "WM_SAVE_YOURSELF", False); _XA_WM_DELETE_WINDOW = XInternAtom (dpy, "WM_DELETE_WINDOW", False); + _XA_WM_END_OF_ANIMATION = XInternAtom (dpy, "WM_END_OF_ANIMATION", False); _XA_WM_CLIENT_MACHINE = XInternAtom (dpy, "WM_CLIENT_MACHINE", False); #ifdef X11R6 _XA_SM_CLIENT_ID = XInternAtom (dpy, "SM_CLIENT_ID", False); Index: ctwm.man =================================================================== RCS file: /u/monnier/cvsroot/ctwm/ctwm.man,v retrieving revision 1.1.1.15 retrieving revision 1.11 diff -u -r1.1.1.15 -r1.11 --- ctwm.man 2 Apr 2005 23:00:26 -0000 1.1.1.15 +++ ctwm.man 3 Apr 2005 16:35:58 -0000 1.11 @@ -399,6 +399,17 @@ when their name or icon name changes. The new occupation will be recalculated from the Occupy and OccupyAll fields in the \fI.ctwmrc\fP file. +.IP "\fBAutoPopup\fP [{ "\fIwin-list\fP }]" 8 +This variables specifies a list of windows which will be deiconified whenever +their name changes. Can be used for xconsole, for instance,which adds a "*" to +its name whenever something gets displayed on the console, or for various mail +readers who change their icons depending on the presence of unread mail. + +.IP "\fBAutoPriority\fP" 8 +This variable specifies that \fIctwm\fP should automatically recompute the +priority of a window (and its associated icon) when its name changes. +See also \fBOnTopPriority\fP. + .IP "\fBAutoRaise\fP { \fIwin-list\fP }" 8 This variable specifies a list of windows (all windows if the list is defaulted) to be automatically raised whenever the pointer has come to rest in a window for @@ -1117,6 +1128,30 @@ .EE Note : The OccupyAll declaration should come after the WorkSpaces declaration. +.IP "\fBOnTopPriority\fP [\fBIcons\fP] \fIpriority\fP [ { \fIwin-list\fP } ]" 8 +\fICtwm\fP allows you to put windows in several overlapping priority planes +going from -8 to +8, which makes it possible to have windows that stay on +top or that are kept in the background. If \fIwin-list\fP is present, it +specifies which windows should be put in the \fIpriority\fP plane. +Else the \fIpriority\fP sets the default value to use (the default default +is 0). The \fBIcons\fP parameter, if present, indicates that the preference +described applies to icons rather than to windows. +.IP +Example: +.EX +OnTopPriority Icons -1 # place icons a little in the background +OnTopPriority Icons 1 +{ + "Exmh" "xbiff" # place mail icons on top of normal windows +} + +OnTopPriority 8 # keep these always on top of other windows +{ + "Emacs Icon Manager" "WorkSpaceManager" + "TWM Icon Manager" "XDaliClock" +} +.EE + .IP "\fBOpaqueMove\fP { \fIwindow-list\fP }" 8 This variable indicates that the \fBf.move\fP function should actually move the window instead of just an outline so that the user can immediately see @@ -1179,6 +1214,18 @@ N.B This is only valid if your version of \fIctwm\fP has been compiled with the right extention (XPM, JPEG or IMCONV options). +.IP "\fBPrioritySwitching\fP [\fBIcons\fP] { \fIwin-list\fP }" 8 +Specifies that the windows in \fIwin-list\fP can switch priority. This means +that they can be in plane \fIpriority\fP or \fI-priority\fP depending on the +situation. For instance a window whose \fIpriority\fP is 2 will be put into +plane 2 when raised and plane -2 when lowered, which means that it will usually +stay on top if you raise another window, but can still be lowered if its +priority is temporarily too high for your liking. If \fBIcons\fP is specified, +it means that the preference applies to icons rather than windows. +.IP "\fBPriorityNotSwitching\fP [\fBIcons\fP] { \fIwin-list\fP }" 8 +As above except that it declares that the default should be for windows to be +able to switch priority except for the windows in \fIwin-list\fP which can't. + .IP "\fBRaiseDelay\fP \fImilliseconds\fP" 8 For windows that are to be automatically raised when the pointer enters (see the \fBAutoRaise\fP variable and the \fIf.autoraise\fP function) @@ -1484,6 +1531,17 @@ This variable specifies a list of windows along which the \fBf.warpring\fP function cycles. If no argument is given, all the windows are in the ring. +.IP "\fBWarpOnDeIconify\fP { \fIwin-list\fP }" 8 +When \fIctwm\fP receives a request to map a window, it normally just deiconifies +it, but if the window is in \fIwin-list\fP, it will additionally bring it +into the current workspace, if necessary. For example +.EX +WarpOnDeIconify { "Emacs" } +.EE +will make sure emacs windows will always popup in the current workspace when +necessary (typically when the minibuffer or the *Help* frame is in another +workspace). + .IP "\fBWarpRingOnScreen\fP" 8 Tells \fIctwm\fP that f.warpring warps pointer only to windows visible in the current workspace. @@ -1806,6 +1864,10 @@ .IP "\fBf.bottomzoom\fP" 8 This function is similar to the \fBf.fullzoom\fP function, but resizes the window to fill only the bottom half of the screen. +.IP "\fBf.changepriority \fIrel-value\fP" 8 +Change the priority of a window by \fIrel-value\fP (enclosed within double +quotes). For instance, to bury a window one level down, you would use +f.changepriority "-1". .IP "\fBf.changesize\fP \fIstring\fP" 8 This function allows you to change the size of the focused window. The @@ -2089,6 +2151,9 @@ function, if you select it while the menu is already permanent, it becomes non-permanent. +.IP "\fBf.priorityswitching" 8 +Toggle the window's switching ability. + .IP "\fBf.quit\fP" 8 This function causes \fIctwm\fP to restore the window's borders and exit. If \fIctwm\fP is the first client invoked from \fIxdm\fP, this will result in a @@ -2104,6 +2169,9 @@ This function raises the selected window to the top of the stacking order if it is occluded by any windows, otherwise the window will be lowered. +.IP "\fBf.raiseorsqueeze\fP" 8 +Raise the window or squeeze it if it's a double click. + .IP "\fBf.removefromworkspace\fP \fIstring\fP" 8 This function removes the selected window from the workspace whose name is \fIstring\fP. @@ -2166,6 +2234,9 @@ .IP "\fBf.setmapstate\fP" 8 Set the WorkSpace manager in map state. +.IP "\fBf.setpriority \fIvalue\fP" 8 +Set the window's priority to \fIvalue\fP (enclosed between double quotes). + .IP "\fBf.showiconmgr\fP" 8 This function maps the current icon manager. @@ -2203,6 +2274,16 @@ .IP "\fBf.stopanimation\fP" 8 Freeze animations (if any). +.IP "\fBf.switchpriority" 8 +Switch the window's priority, independently of its ability to switch +automatically. + +.IP "\fBf.tinylower\fP" 8 +.IP "\fBf.tinyraise\fP" 8 +These two functions allow you to raise/lower a window "one step" at +a time. For instance, \fBf.tinyraise\fP will bring the current window +just above the lowest one that's hiding it. These two functions are not +subject to priority-switching. .IP "\fBf.title\fP" 8 This function provides a centered, unselectable item in a menu definition. It @@ -2233,6 +2314,9 @@ This function resets the focus back to pointer-driven. This should be used when a focused window is no longer desired. +.IP "\fBf.unsqueeze\fP" 8 +Is to \fBf.squeeze\fP what \fBf.deiconify\fP is to \fBf.iconify\fP. + .IP "\fBf.upiconmgr\fI" 8 This function warps the pointer to the previous row in the current icon manager, wrapping to the last row in the same column if necessary. Index: cursor.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/cursor.c,v retrieving revision 1.1.1.4 retrieving revision 1.2 diff -u -r1.1.1.4 -r1.2 --- cursor.c 8 Mar 1998 23:45:10 -0000 1.1.1.4 +++ cursor.c 11 Mar 1998 04:32:38 -0000 1.2 @@ -176,7 +176,7 @@ ProgramName, str); } -NewBitmapCursor(cp, source, mask) +int NewBitmapCursor(cp, source, mask) Cursor *cp; char *source, *mask; { @@ -218,7 +218,7 @@ Cursor cursor; XColor black, white; Pixmap bitmap; - unsigned int width, height, rwidth, rheight, middle; + unsigned int width, height, middle; GC gc; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; MyFont myfont = Scr->TitleBarFont; Index: cursor.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/cursor.h,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- cursor.h 8 Mar 1998 23:45:10 -0000 1.1.1.2 +++ cursor.h 11 Mar 1998 04:32:38 -0000 1.2 @@ -38,8 +38,9 @@ #ifndef _CURSOR_ #define _CURSOR_ -extern void NewFontCursor(); -extern NewBitmapCursor(); -extern Cursor MakeStringCursor (); +extern void NewFontCursor(Cursor *cp, char *str); +extern int NewBitmapCursor(Cursor *cp, char *source, char *mask); +extern Cursor MakeStringCursor (char *string); + #endif /* _CURSOR_ */ Index: deftwmrc.h =================================================================== RCS file: deftwmrc.h diff -N deftwmrc.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ deftwmrc.h 11 Mar 1998 17:22:25 -0000 1.1 @@ -0,0 +1,6 @@ +#ifndef _DEFTWMRC_H_ +#define _DEFTWMRC_H_ + +extern char *defTwmrc[]; + +#endif Index: events.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/events.c,v retrieving revision 1.1.1.13 retrieving revision 1.17 diff -u -r1.1.1.13 -r1.17 --- events.c 2 Apr 2005 23:00:27 -0000 1.1.1.13 +++ events.c 4 Apr 2005 19:57:09 -0000 1.17 @@ -75,9 +75,9 @@ #if defined(AIXV3) || defined(_SYSTYPE_SVR4) || defined(ibm) || defined __QNX__ #include #endif -#if defined(__QNX__) || defined(VMS) +/* #if defined(__QNX__) || defined(VMS) */ #include -#endif +/* #endif */ #include "twm.h" #ifdef VMS @@ -92,49 +92,27 @@ #include "parse.h" #include "gram.h" #include "util.h" +#include "otp.h" #include "screen.h" #include "icons.h" #include "iconmgr.h" #include "version.h" +#include "list.h" #ifdef VMS #include #include #include #define USE_SIGNALS -#else -#define MAX(x,y) ((x)>(y)?(x):(y)) -#define MIN(x,y) ((x)<(y)?(x):(y)) #endif -#define ABS(x) ((x)<0?-(x):(x)) - -extern int iconifybox_width, iconifybox_height; -extern unsigned int mods_used; -extern int menuFromFrameOrWindowOrTitlebar; -extern char *CurrentSelectedWorkspace; - -extern int captive; - -#ifdef USE_SIGNALS -extern Bool AnimationPending; -#else /* USE_SIGNALS */ -extern struct timeval AnimateTimeout; -#endif /* USE_SIGNALS */ -extern int AnimationSpeed; -extern Bool AnimationActive; -extern Bool MaybeAnimate; - -extern int AlternateKeymap; -extern Bool AlternateContext; static void CtwmNextEvent (); static void RedoIcon(); static void do_key_menu (); -int RedoIconName(); -int RestoreWithdrawnLocation (); /* in ctwm.c */ +static void RedoIconName(); #ifdef SOUNDS -extern play_sound(); +#include "sounds.h" #endif FILE *tracefile = NULL; @@ -159,10 +137,6 @@ int CurrentDragX; int CurrentDragY; -/* Vars to tell if the resize has moved. */ -extern int ResizeOrigX; -extern int ResizeOrigY; - static int enter_flag; static int leave_flag; static int ColortableThrashing; @@ -220,7 +194,7 @@ void AutoRaiseWindow (tmp) TwmWindow *tmp; { - RaiseWindow (tmp); + OtpRaise(tmp, WinWin); if (ActiveMenu && ActiveMenu->w) XRaiseWindow (dpy, ActiveMenu->w); XSync (dpy, 0); @@ -242,10 +216,26 @@ XSync (dpy, 0); } +void AutoPopupMaybe(tmp) + TwmWindow *tmp; +{ + if (LookInList(Scr->AutoPopupL, tmp->full_name, &tmp->class) + || Scr->AutoPopup){ + if (OCCUPY (tmp, Scr->currentvs->wsw->currentwspc)) { + if (!tmp->mapped) { + DeIconify(tmp); + SetRaiseWindow (tmp); + } + }else{ + tmp->mapped = TRUE; + } + } +} + void AutoLowerWindow (tmp) TwmWindow *tmp; { - LowerWindow (tmp); + OtpLower (tmp, WinWin); if (ActiveMenu && ActiveMenu->w) XRaiseWindow (dpy, ActiveMenu->w); XSync (dpy, 0); @@ -581,12 +571,12 @@ nextEvent (event); return; } - if (AnimationPending) Animate (); + if (AnimationPending && Animating < 2) Animate (); while (1) { sys$waitfr(timefe); sys$clref(timefe); - if (AnimationPending) Animate (); + if (AnimationPending && Animating < 2) Animate (); if (QLength (dpy) != 0) { nextEvent (event); return; @@ -605,14 +595,14 @@ fd = ConnectionNumber (dpy); #ifdef USE_SIGNALS - if (AnimationPending) Animate (); + if (AnimationPending && Animating < 2) Animate (); while (1) { FD_ZERO (&mask); FD_SET (fd, &mask); found = select (fd + 1, (FDSET)&mask, (FDSET) 0, (FDSET) 0, 0); if (found < 0) { if (errno == EINTR) { - Animate (); + if (Animating < 2) Animate (); } else perror ("select"); continue; @@ -623,7 +613,7 @@ } } #else /* USE_SIGNALS */ - TryToAnimate (); + if (Animating < 2) TryToAnimate (); if (! MaybeAnimate) { nextEvent (event); return; @@ -643,7 +633,7 @@ return; } if (found == 0) { - TryToAnimate (); + if (Animating < 2) TryToAnimate (); if (! MaybeAnimate) { nextEvent (event); return; @@ -676,7 +666,6 @@ ColormapWindow *cwin, **cwins; TwmColormap *cmap; int lost, won, n, number_cwins; - extern TwmColormap *CreateTwmColormap(); /* if (! Tmp_win) return; */ if (XFindContext(dpy, cevent->window, ColormapContext, (XPointer *)&cwin) == XCNOENT) @@ -1435,13 +1424,12 @@ XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm; int icon_change; + int name_change; #ifdef I18N XRectangle inc_rect; XRectangle logical_rect; #endif - unsigned char *gwkspc; - /* watch for standard colormap changes */ if (Event.xproperty.window == Scr->Root) { XStandardColormap *maps = NULL; @@ -1497,6 +1485,10 @@ return; if (!prop) prop = NoName; #endif /* NO_LOCALE */ + + name_change = strcmp (Tmp_win->full_name, prop); + icon_change = FALSE; + #ifdef CLAUDE if (strstr (prop, " - Mozilla")) { char *moz = strstr (prop, " - Mozilla"); @@ -1521,6 +1513,11 @@ strlen (Tmp_win->name)); #endif + /* recompute the priority if necessary */ + if (name_change && Scr->AutoPriority) { + OtpRecomputeValues(Tmp_win); + } + SetupWindow (Tmp_win, Tmp_win->frame_x, Tmp_win->frame_y, Tmp_win->frame_width, Tmp_win->frame_height, -1); @@ -1565,7 +1562,13 @@ */ if (Tmp_win->icon_name == NoName) { Tmp_win->icon_name = Tmp_win->name; - RedoIcon(); + icon_change = TRUE; + } + if (name_change || icon_change) { + if (icon_change){ + RedoIcon(); + } + AutoPopupMaybe(Tmp_win); } break; @@ -1594,6 +1597,7 @@ if (icon_change) { RedoIcon(); + AutoPopupMaybe(Tmp_win); } break; @@ -1749,11 +1753,21 @@ RedoIconName (); } } + if (Tmp_win->wmhints && (Tmp_win->wmhints->flags & IconPixmapHint)){ + AutoPopupMaybe(Tmp_win); + } + break; case XA_WM_NORMAL_HINTS: { GetWindowSizeHints (Tmp_win); + + if (! strcmp(Tmp_win->name, "zwatch")){ + ConstrainSize (Tmp_win, &Tmp_win->frame_width, &Tmp_win->frame_height); + SetupFrame (Tmp_win, Tmp_win->frame_x, Tmp_win->frame_y, + Tmp_win->frame_width, Tmp_win->frame_height, -1, True); + } break; } default: @@ -1794,15 +1808,15 @@ return; } icon = (Icon*) 0; - if (pattern = LookPatternInNameList (Scr->IconNames, Tmp_win->icon_name)) { + if ((pattern=LookPatternInNameList (Scr->IconNames, Tmp_win->icon_name))) { icon = (Icon*) LookInNameList (Tmp_win->iconslist, pattern); } else - if (pattern = LookPatternInNameList (Scr->IconNames, Tmp_win->full_name)) { + if ((pattern=LookPatternInNameList (Scr->IconNames, Tmp_win->full_name))) { icon = (Icon*) LookInNameList (Tmp_win->iconslist, pattern); } else - if (pattern = LookPatternInList (Scr->IconNames, Tmp_win->full_name, &Tmp_win->class)) { + if ((pattern = LookPatternInList (Scr->IconNames, Tmp_win->full_name, &Tmp_win->class))) { icon = (Icon*) LookInNameList (Tmp_win->iconslist, pattern); } if (pattern == NULL) { @@ -1819,8 +1833,9 @@ if (Tmp_win->icon && Tmp_win->icon->w) XUnmapWindow (dpy, Tmp_win->icon->w); Tmp_win->icon = icon; IconUp (Tmp_win); - XMapRaised (dpy, Tmp_win->icon->w); - } + OtpRaise(Tmp_win, IconWin); + XMapWindow (dpy, Tmp_win->icon->w); + } else { Tmp_win->icon = icon; } @@ -1831,7 +1846,8 @@ IconDown (Tmp_win); if (Tmp_win->icon && Tmp_win->icon->w) XUnmapWindow (dpy, Tmp_win->icon->w); CreateIconWindow (Tmp_win, -100, -100); - XMapRaised (dpy, Tmp_win->icon->w); + OtpRaise(Tmp_win, IconWin); + XMapWindow (dpy, Tmp_win->icon->w); } else { Tmp_win->icon = (Icon*) 0; @@ -1849,7 +1865,7 @@ *********************************************************************** */ -RedoIconName() +void RedoIconName (void) { int x; #ifdef I18N @@ -1966,9 +1982,6 @@ void HandleClientMessage() { - TwmWindow *twm_win; - int i; - if (Event.xclient.message_type == _XA_WM_CHANGE_STATE) { if (Tmp_win != NULL) { if (Event.xclient.data.l[0] == IconicState && !Tmp_win->isicon) { @@ -2027,6 +2040,13 @@ } } #endif /* GNOME */ + else if ((Event.xclient.message_type == _XA_WM_PROTOCOLS) && + (Event.xclient.data.l[0] == _XA_WM_END_OF_ANIMATION)) { + if (Animating > 0) + Animating--; + else + fprintf(stderr, "!! end of unknown animation !!\n"); + } } @@ -2250,6 +2270,10 @@ return; RemoveWindowFromRegion (Tmp_win); + + if (Tmp_win->icon != NULL) OtpRemove(Tmp_win, IconWin); + OtpRemove(Tmp_win, WinWin); + #ifdef GNOME GnomeDeleteClientWindow (Tmp_win); /* Fix the gnome client list */ #endif /* GNOME */ @@ -2335,7 +2359,6 @@ Tmp_win->next->prev = Tmp_win->prev; if (Tmp_win->auto_raise) Scr->NumAutoRaises--; if (Tmp_win->auto_lower) Scr->NumAutoLowers--; - if (Tmp_win->frame == lowerontop) lowerontop = -1; free_window_names (Tmp_win, True, True, True); /* 1, 2, 3 */ if (Tmp_win->wmhints) /* 4 */ @@ -2451,6 +2474,13 @@ break; case InactiveState: + if (!OCCUPY (Tmp_win, Scr->currentvs->wsw->currentwspc) && + HandlingEvents && /* to avoid warping during startup */ + LookInList(Scr->WarpOnDeIconify, Tmp_win->full_name, &Tmp_win->class)) { + if (!Scr->NoRaiseDeicon) + OtpRaise(Tmp_win, WinWin); + AddToWorkSpace(Scr->currentvs->wsw->currentwspc->name, Tmp_win); + } Tmp_win->mapped = TRUE; if (Tmp_win->UnmapByMovingFarAway) { XMoveWindow (dpy, Tmp_win->frame, Scr->rootw + 1, Scr->rooth + 1); @@ -2471,6 +2501,10 @@ /* If no hints, or currently an icon, just "deiconify" */ else { + if (!OCCUPY (Tmp_win, Scr->currentvs->wsw->currentwspc) && + LookInList(Scr->WarpOnDeIconify, Tmp_win->full_name, &Tmp_win->class)) { + AddToWorkSpace(Scr->currentvs->wsw->currentwspc->name, Tmp_win); + } if (1/*OCCUPY (Tmp_win, Scr->workSpaceMgr.activeWSPC)*/) { if (Tmp_win->StartSqueezed) Squeeze (Tmp_win); DeIconify(Tmp_win); @@ -2604,6 +2638,7 @@ } XRemoveFromSaveSet (dpy, Event.xunmap.window); XSelectInput (dpy, Event.xunmap.window, NoEventMask); + XDeleteProperty(dpy, Tmp_win->w, _XA_WM_OCCUPATION); HandleDestroyNotify (); /* do not need to mash event before */ } /* else window no longer exists and we'll get a destroy notify */ XUngrabServer (dpy); @@ -2725,9 +2760,10 @@ if (MoveFunction == F_MOVEPUSH && Scr->OpaqueMove && DragWindow == Tmp_win->frame) TryToPush (Tmp_win, xl, yt, 0); - if (MoveFunction == F_MOVEPACK || - MoveFunction == F_MOVEPUSH && - DragWindow == Tmp_win->frame) TryToPack (Tmp_win, &xl, &yt); + if ((MoveFunction == F_MOVEPACK || MoveFunction == F_MOVEPUSH) + && DragWindow == Tmp_win->frame) { + TryToPack (Tmp_win, &xl, &yt); + } if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { ConstrainByBorders (Tmp_win, &xl, w, &yt, h); @@ -2739,11 +2775,23 @@ SetupWindow (Tmp_win, xl, yt, Tmp_win->frame_width, Tmp_win->frame_height, -1); - else + else { XMoveWindow (dpy, DragWindow, xl, yt); + if (DragWindow == Tmp_win->icon->w) { + Tmp_win->icon->w_x = xl; + Tmp_win->icon->w_y = yt; + } + } - if (!Scr->NoRaiseMove) /* && !Scr->OpaqueMove) opaque already did */ - RaiseFrame(DragWindow); + if (!Scr->NoRaiseMove) { /* && !Scr->OpaqueMove) opaque already did */ + if (DragWindow == Tmp_win->frame) { + OtpRaise(Tmp_win, WinWin); + } else if (Tmp_win->icon && DragWindow == Tmp_win->icon->w) { + OtpRaise(Tmp_win, IconWin); + } else { + fprintf(stderr, "ERROR -- events.c:2455\n"); + } + } if (!Scr->OpaqueMove) UninstallRootColormap(); @@ -2876,7 +2924,7 @@ -static do_menu (menu, w) +static void do_menu (menu, w) MenuRoot *menu; /* menu to pop up */ Window w; /* invoking window or None */ { @@ -3108,8 +3156,8 @@ SetFocus (Tmp_win, CurrentTime); } if (Scr->RaiseOnClick) { - RaiseWindow (Tmp_win); - WMapRaise (Tmp_win); + OtpRaise (Tmp_win, WinWin); + WMapRaise (Tmp_win); } XSync (dpy, 0); XAllowEvents (dpy, ReplayPointer, CurrentTime); @@ -3528,7 +3576,7 @@ Tmp_win->icon && ewp->window == Tmp_win->icon->w && ewp->detail != NotifyInferior) { - if (Scr->AutoRaiseIcons) XRaiseWindow (dpy, Tmp_win->icon->w); + if (Scr->AutoRaiseIcons) OtpRaise(Tmp_win, IconWin); ExpandIconTitle (Tmp_win); return; } @@ -3932,13 +3980,27 @@ if ((cre->value_mask & CWStackMode) && Tmp_win->stackmode) { TwmWindow *otherwin; - xwc.sibling = (((cre->value_mask & CWSibling) && - (XFindContext (dpy, cre->above, TwmContext, - (XPointer *) &otherwin) == XCSUCCESS)) - ? otherwin->frame : cre->above); - xwc.stack_mode = cre->detail; - XConfigureWindow (dpy, Tmp_win->frame, - cre->value_mask & (CWSibling | CWStackMode), &xwc); + if (cre->value_mask & CWSibling) { + if (XFindContext (dpy, cre->above, TwmContext, + (XPointer *) &otherwin) == XCSUCCESS) { + OtpForcePlacement (Tmp_win, cre->detail, otherwin); + } else { + fprintf(stderr, "XConfigureRequest: unkown otherwin\n"); + } + } else { + switch (cre->detail) { + case TopIf: + case Above: OtpRaise(Tmp_win, WinWin); + break; + case BottomIf: + case Below: OtpLower(Tmp_win, WinWin); + break; + case Opposite: OtpRaiseLower(Tmp_win, WinWin); + break; + default: + ; + } + } sendEvent = True; } @@ -3975,11 +4037,15 @@ Tmp_win->old_bw = cre->border_width; /* for restoring */ } - if (cre->value_mask & CWX) { /* override even if border change */ + /* If old_bw is zero, the application has asked not to have any border, + so we indeed do not draw any border. Maybe it would be better to set + frame_bw and frame_bw3D to 0 in this case, but I don't know where + this is handled. --Stef */ + if (cre->value_mask & CWX && Tmp_win->old_bw) { /* override even if border change */ x = cre->x - bw; x -= ((gravx < 0) ? 0 : Tmp_win->frame_bw3D); } - if (cre->value_mask & CWY) { + if (cre->value_mask & CWY && Tmp_win->old_bw) { y = cre->y - ((gravy < 0) ? 0 : Tmp_win->title_height) - bw; y -= ((gravy < 0) ? 0 : Tmp_win->frame_bw3D); } @@ -4141,7 +4207,7 @@ *********************************************************************** */ -InstallWindowColormaps (type, tmp) +void InstallWindowColormaps (type, tmp) int type; TwmWindow *tmp; { @@ -4163,10 +4229,10 @@ * force loaded. */ if (Scr->cmapInfo.root_pushes) - return (0); + return; /* Don't reload the currend window colormap list. if (Scr->cmapInfo.cmaps == &tmp->cmaps) - return (0); + return; */ if (Scr->cmapInfo.cmaps) for (i = Scr->cmapInfo.cmaps->number_cwins, @@ -4248,7 +4314,7 @@ *********************************************************************** */ -InstallRootColormap() +void InstallRootColormap(void) { TwmWindow *tmp; if (Scr->cmapInfo.root_pushes == 0) { @@ -4287,7 +4353,7 @@ -UninstallRootColormap() +void UninstallRootColormap(void) { char args; XEvent dummy; @@ -4309,7 +4375,7 @@ } } -ConfigureRootWindow (ev) +void ConfigureRootWindow (ev) XEvent *ev; { Window root, child; Index: events.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/events.h,v retrieving revision 1.1.1.3 retrieving revision 1.3 diff -u -r1.1.1.3 -r1.3 --- events.h 7 Oct 1999 17:30:59 -0000 1.1.1.3 +++ events.h 7 Oct 1999 19:09:10 -0000 1.3 @@ -64,6 +64,8 @@ #ifndef _EVENTS_ #define _EVENTS_ +#include + typedef void (*event_proc)(); extern void InitEvents(); @@ -100,10 +102,11 @@ #if 0 extern ScreenInfo *FindScreenInfo(w); #endif -extern InstallWindowColormaps (); -extern InstallRootColormap(); -extern UninstallRootColormap(); -extern ConfigureRootWindow (); +extern void InstallWindowColormaps (int type, TwmWindow *tmp); +extern void InstallRootColormap (void); +extern void UninstallRootColormap (void); +extern void ConfigureRootWindow (XEvent *ev); +void free_cwins (TwmWindow *tmp); extern event_proc EventHandler[]; extern Window DragWindow; @@ -116,6 +119,8 @@ extern unsigned int DragBW; extern int CurrentDragX; extern int CurrentDragY; +extern int Context; +extern FILE *tracefile; extern int ButtonPressed; extern int Cancel; Index: gc.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/gc.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- gc.c 28 Oct 1997 21:12:26 -0000 1.1.1.2 +++ gc.c 11 Mar 1998 04:32:39 -0000 1.2 @@ -73,8 +73,6 @@ #include "gram.h" #include "screen.h" -extern int twmrc_error_prefix(); - /*********************************************************************** * * Procedure: Index: gram.y =================================================================== RCS file: /u/monnier/cvsroot/ctwm/gram.y,v retrieving revision 1.1.1.11 retrieving revision 1.12 diff -u -r1.1.1.11 -r1.12 --- gram.y 2 Apr 2005 23:00:28 -0000 1.1.1.11 +++ gram.y 3 Apr 2005 16:35:58 -0000 1.12 @@ -68,6 +68,7 @@ #include #include #include "twm.h" +#include "otp.h" #include "menus.h" #include "icons.h" #include "windowbox.h" @@ -76,6 +77,7 @@ #include "util.h" #include "screen.h" #include "parse.h" +#include "iconmgr.h" #include "cursor.h" #ifdef VMS # include @@ -93,8 +95,8 @@ static char *client, *workspace; static MenuItem *lastmenuitem = (MenuItem*) 0; -extern yyerror(); -extern RemoveDQuote(); +void yyerror(char *s); +static void RemoveDQuote(char *s); static MenuRoot *GetRoot(); @@ -109,20 +111,14 @@ int mods = 0; unsigned int mods_used = (ShiftMask | ControlMask | Mod1Mask); -extern twmrc_error_prefix(); - -extern int do_single_keyword(), do_string_keyword(), do_number_keyword(); -extern name_list **do_colorlist_keyword(); -extern int do_color_keyword(), do_string_savecolor(); -extern int do_var_savecolor(), do_squeeze_entry(); extern int twmrc_lineno; -extern yylex(); +extern int yylex(void); %} %union { int num; - unsigned char *ptr; + char *ptr; }; @@ -130,16 +126,18 @@ %token ALL OR CURSORS PIXMAPS ICONS COLOR SAVECOLOR MONOCHROME FUNCTION %token ICONMGR_SHOW ICONMGR ALTER WINDOW_FUNCTION ZOOM ICONMGRS %token ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE -%token ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING +%token ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING AUTO_POPUP %token NO_BORDER NO_ICON_TITLE NO_TITLE AUTO_RAISE NO_HILITE ICON_REGION %token WINDOW_REGION META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME -%token COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE +%token COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE WARPONDEICONIFY %token START_ICONIFIED NO_TITLE_HILITE TITLE_HILITE %token MOVE RESIZE WAITC SELECT KILL LEFT_TITLEBUTTON RIGHT_TITLEBUTTON -%token NUMBER KEYWORD NKEYWORD CKEYWORD CLKEYWORD FKEYWORD FSKEYWORD +%token NUMBER KEYWORD NKEYWORD CKEYWORD CLKEYWORD FKEYWORD FSKEYWORD +%token FNKEYWORD PRIORITY_SWITCHING PRIORITY_NOT_SWITCHING %token SKEYWORD DKEYWORD JKEYWORD WINDOW_RING WINDOW_RING_EXCLUDE WARP_CURSOR ERRORTOKEN %token NO_STACKMODE ALWAYS_ON_TOP WORKSPACE WORKSPACES WORKSPCMGR_GEOMETRY %token OCCUPYALL OCCUPYLIST MAPWINDOWCURRENTWORKSPACE MAPWINDOWDEFAULTWORKSPACE +%token ON_TOP_PRIORITY %token UNMAPBYMOVINGFARAWAY OPAQUEMOVE NOOPAQUEMOVE OPAQUERESIZE NOOPAQUERESIZE %token DONTSETINACTIVE CHANGE_WORKSPACE_FUNCTION DEICONIFY_FUNCTION ICONIFY_FUNCTION %token AUTOSQUEEZE STARTSQUEEZED DONT_SAVE AUTO_LOWER ICONMENU_DONTSHOW WINDOW_BOX @@ -280,7 +278,7 @@ root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); item = AddToMenu (root, "x", Action, - NULLSTR, $2, NULLSTR, NULLSTR); + NULL, $2, NULLSTR, NULLSTR); AddFuncButton ($1, C_ROOT, 0, $2, (MenuRoot*) 0, item); } Action = ""; @@ -326,7 +324,31 @@ win_list | NO_HILITE { if (Scr->FirstTime) Scr->Highlight = FALSE; } - | ALWAYS_ON_TOP { list = &Scr->AlwaysOnTopL; } + | ON_TOP_PRIORITY signed_number + { OtpScrSetZero(Scr, WinWin, $2); } + | ON_TOP_PRIORITY ICONS signed_number + { OtpScrSetZero(Scr, IconWin, $3); } + | ON_TOP_PRIORITY signed_number + { list = OtpScrPriorityL(Scr, WinWin, $2); } + win_list + | ON_TOP_PRIORITY ICONS signed_number + { list = OtpScrPriorityL(Scr, IconWin, $3); } + win_list + | ALWAYS_ON_TOP { list = OtpScrPriorityL(Scr, WinWin, 8); } + win_list + | PRIORITY_SWITCHING { OtpScrSetSwitching(Scr, WinWin, False); + list = OtpScrSwitchingL(Scr, WinWin); } + win_list + | PRIORITY_NOT_SWITCHING { OtpScrSetSwitching(Scr, WinWin, True); + list = OtpScrSwitchingL(Scr, WinWin); } + win_list + | PRIORITY_SWITCHING ICONS + { OtpScrSetSwitching(Scr, IconWin, False); + list = OtpScrSwitchingL(Scr, IconWin); } + win_list + | PRIORITY_NOT_SWITCHING ICONS + { OtpScrSetSwitching(Scr, IconWin, True); + list = OtpScrSwitchingL(Scr, IconWin); } win_list | NO_STACKMODE { list = &Scr->NoStackModeL; } win_list @@ -334,6 +356,9 @@ Scr->StackMode = FALSE; } | NO_BORDER { list = &Scr->NoBorder; } win_list + | AUTO_POPUP { Scr->AutoPopup = TRUE; } + | AUTO_POPUP { list = &Scr->AutoPopupL; } + win_list | DONT_SAVE { list = &Scr->DontSave; } win_list | NO_ICON_TITLE { list = &Scr->NoIconTitle; } @@ -354,6 +379,8 @@ | AUTO_RAISE { list = &Scr->AutoRaise; } win_list | AUTO_RAISE { Scr->AutoRaiseDefault = TRUE; } + | WARPONDEICONIFY { list = &Scr->WarpOnDeIconify; } + win_list | AUTO_LOWER { list = &Scr->AutoLower; } win_list | AUTO_LOWER { Scr->AutoLowerDefault = TRUE; } @@ -383,7 +410,7 @@ root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); Scr->DefaultFunction.item = AddToMenu(root,"x",Action, - NULLSTR,$2, NULLSTR, NULLSTR); + NULL,$2, NULLSTR, NULLSTR); } Action = ""; pull = NULL; @@ -392,7 +419,7 @@ root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); Scr->WindowFunction.item = AddToMenu(root,"x",Action, - NULLSTR,$2, NULLSTR, NULLSTR); + NULL,$2, NULLSTR, NULLSTR); Action = ""; pull = NULL; } @@ -400,7 +427,7 @@ root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); Scr->ChangeWorkspaceFunction.item = AddToMenu(root,"x",Action, - NULLSTR,$2, NULLSTR, NULLSTR); + NULL,$2, NULLSTR, NULLSTR); Action = ""; pull = NULL; } @@ -408,7 +435,7 @@ root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); Scr->DeIconifyFunction.item = AddToMenu(root,"x",Action, - NULLSTR,$2, NULLSTR, NULLSTR); + NULL,$2, NULLSTR, NULLSTR); Action = ""; pull = NULL; } @@ -416,7 +443,7 @@ root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); Scr->IconifyFunction.item = AddToMenu(root,"x",Action, - NULLSTR,$2, NULLSTR, NULLSTR); + NULL,$2, NULLSTR, NULLSTR); Action = ""; pull = NULL; } @@ -824,7 +851,7 @@ ; win_entries : /* Empty */ - | win_entries win_entry + | win_entries win_entry ; win_entry : string { if (Scr->FirstTime) @@ -887,7 +914,7 @@ | function_entries function_entry ; -function_entry : action { AddToMenu(root, "", Action, NULLSTR, $1, +function_entry : action { AddToMenu(root, "", Action, NULL, $1, NULLSTR, NULLSTR); Action = ""; } @@ -984,7 +1011,7 @@ string : STRING { ptr = (char *)malloc(strlen((char*)$1)+1); strcpy((char*)ptr, (char*)$1); RemoveDQuote(ptr); - $$ = (unsigned char*)ptr; + $$ = ptr; } ; @@ -992,18 +1019,17 @@ ; %% -yyerror(s) char *s; +void yyerror(char *s) { twmrc_error_prefix(); fprintf (stderr, "error in input file: %s\n", s ? s : ""); ParseError = 1; } -RemoveDQuote(str) -char *str; +static void RemoveDQuote(char *str) { register char *i, *o; - register n; - register count; + register int n; + register int count; for (i=str+1, o=str; *i && *i != '\"'; o++) { @@ -1121,7 +1147,7 @@ } else { root = GetRoot (TWM_ROOT, NULLSTR, NULLSTR); - item = AddToMenu (root, "x", Action, NULLSTR, func, NULLSTR, NULLSTR); + item = AddToMenu (root, "x", Action, NULL, func, NULLSTR, NULLSTR); AddFuncButton (butt, i, mods, func, (MenuRoot*) 0, item); } } @@ -1218,7 +1244,7 @@ } -twmrc_error_prefix () +void twmrc_error_prefix (void) { fprintf (stderr, "%s: line %d: ", ProgramName, twmrc_lineno); } Index: iconmgr.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/iconmgr.c,v retrieving revision 1.1.1.7 retrieving revision 1.7 diff -u -r1.1.1.7 -r1.7 --- iconmgr.c 2 Apr 2005 23:00:28 -0000 1.1.1.7 +++ iconmgr.c 3 Apr 2005 16:35:58 -0000 1.7 @@ -72,6 +72,7 @@ #include "screen.h" #include "resize.h" #include "add_window.h" +#include "list.h" #include "siconify.bm" #ifdef VMS #include @@ -84,6 +85,9 @@ int strcmp(); /* missing from string.h in AUX 2.0 */ #endif +#include "otp.h" +#include "iconmgr.h" + int iconmgr_textx = siconify_width+11; WList *Active = NULL; WList *Current = NULL; @@ -390,7 +394,7 @@ /* raise the frame so the icon manager is visible */ if (ip->twm_win->mapped) { - RaiseWindow(ip->twm_win); + OtpRaise(ip->twm_win, WinWin); XWarpPointer(dpy, None, tmp->icon, 0,0,0,0, 5, 5); } else { if (tmp->twm->title_height) { @@ -471,7 +475,7 @@ /* raise the frame so the icon manager is visible */ if (ip->twm_win->mapped) { - RaiseWindow(ip->twm_win); + OtpRaise(ip->twm_win, WinWin); XWarpPointer(dpy, None, tmp->icon, 0,0,0,0, 5, 5); } else { if (tmp->twm->title_height) { @@ -551,7 +555,7 @@ } /* raise the frame so it is visible */ - RaiseWindow(tmp_ip->twm_win); + OtpRaise(tmp_ip->twm_win, WinWin); if (tmp_ip->active) XWarpPointer(dpy, None, tmp_ip->active->icon, 0,0,0,0, 5, 5); else Index: iconmgr.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/iconmgr.h,v retrieving revision 1.1.1.2 retrieving revision 1.4 diff -u -r1.1.1.2 -r1.4 --- iconmgr.h 28 Oct 1997 21:12:28 -0000 1.1.1.2 +++ iconmgr.h 11 Mar 1998 04:32:39 -0000 1.4 @@ -57,13 +57,15 @@ #ifndef _ICONMGR_ #define _ICONMGR_ -typedef struct WList +#include "typedefs.h" + +struct WList { - struct WList *next; - struct WList *prev; - struct WList *nextv; /* pointer to the next virtual Wlist C.L. */ - struct TwmWindow *twm; - struct IconMgr *iconmgr; + WList *next; + WList *prev; + WList *nextv; /* pointer to the next virtual Wlist C.L. */ + TwmWindow *twm; + IconMgr *iconmgr; Window w; Window icon; int x, y, width, height; @@ -75,31 +77,33 @@ unsigned top, bottom; short active; short down; -} WList; +}; -typedef struct IconMgr +struct IconMgr { - struct IconMgr *next; /* pointer to the next icon manager */ - struct IconMgr *prev; /* pointer to the previous icon mgr */ - struct IconMgr *lasti; /* pointer to the last icon mgr */ - struct IconMgr *nextv; /* pointer to the next virtual icon mgr C.L. */ - struct WList *first; /* first window in the list */ - struct WList *last; /* last window in the list */ - struct WList *active; /* the active entry */ - TwmWindow *twm_win; /* back pointer to the new parent */ - struct ScreenInfo *scr; /* the screen this thing is on */ - int vScreen; /* the virtual screen this thing is on */ - Window w; /* this icon manager window */ - char *geometry; /* geometry string */ + IconMgr *next; /* pointer to the next icon manager */ + IconMgr *prev; /* pointer to the previous icon mgr */ + IconMgr *lasti; /* pointer to the last icon mgr */ + IconMgr *nextv; /* pointer to the next virtual icon mgr C.L. */ + WList *first; /* first window in the list */ + WList *last; /* last window in the list */ + WList *active; /* the active entry */ + TwmWindow *twm_win; /* back pointer to the new parent */ + ScreenInfo *scr; /* the screen this thing is on */ + int vScreen; /* the virtual screen this thing is on */ + Window w; /* this icon manager window */ + char *geometry; /* geometry string */ char *name; char *icon_name; int x, y, width, height; int columns, cur_rows, cur_columns; int count; -} IconMgr; +}; extern int iconmgr_textx; extern WList *DownIconManager; +extern int iconifybox_width; +extern int iconifybox_height; extern void CreateIconManagers(); extern IconMgr *AllocateIconManager(); Index: icons.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/icons.c,v retrieving revision 1.1.1.6 retrieving revision 1.10 diff -u -r1.1.1.6 -r1.10 --- icons.c 2 Apr 2005 22:55:31 -0000 1.1.1.6 +++ icons.c 3 Apr 2005 16:35:58 -0000 1.10 @@ -64,21 +64,17 @@ #include "twm.h" #include "screen.h" #include "icons.h" -#include "gram.h" +/* #include "gram.h" */ +#include "otp.h" #include "list.h" #include "parse.h" #include "util.h" -extern int twmrc_error_prefix(); -extern Bool AnimationPending; -extern Bool AnimationActive; -extern Bool MaybeAnimate; - #define iconWidth(w) (w->icon->border_width * 2 + \ Scr->SchrinkIconTitles ? w->icon->width : w->icon->w_width) #define iconHeight(w) (w->icon->border_width * 2 + w->icon->w_height) -static +static void splitEntry (ie, grav1, grav2, w, h) IconEntry *ie; int grav1, grav2; @@ -135,7 +131,7 @@ } } -roundUp (v, multiple) +int roundUp (int v, int multiple) { return ((v + multiple - 1) / multiple) * multiple; } @@ -261,12 +257,11 @@ return 0; } -IconUp (tmp_win) - TwmWindow *tmp_win; +int IconUp (TwmWindow *tmp_win) { int x, y; int defx, defy; - struct IconRegion *ir; + IconRegion *ir; /* * If the client specified a particular location, let's use it (this might @@ -297,6 +292,8 @@ PlaceIcon(tmp_win, defx, defy, &x, &y); if (x != defx || y != defy) { XMoveWindow (dpy, tmp_win->icon->w, x, y); + tmp_win->icon->w_x = x; + tmp_win->icon->w_y = y; tmp_win->icon_moved = FALSE; /* since we've restored it */ } MaybeAnimate = True; @@ -321,9 +318,7 @@ * regions together */ -static -mergeEntries (old, ie) - IconEntry *old, *ie; +static void mergeEntries (IconEntry *old, IconEntry *ie) { if (old->y == ie->y) { ie->w = old->w + ie->w; @@ -336,8 +331,7 @@ } } -IconDown (tmp_win) - TwmWindow *tmp_win; +void IconDown (TwmWindow *tmp_win) { IconEntry *ie, *ip, *in; IconRegion *ir; @@ -469,9 +463,7 @@ } #endif -CreateIconWindow(tmp_win, def_x, def_y) -TwmWindow *tmp_win; -int def_x, def_y; +void CreateIconWindow (TwmWindow *tmp_win, int def_x, int def_y) { unsigned long event_mask; unsigned long valuemask; /* mask for create windows */ @@ -481,7 +473,9 @@ Icon *icon; Image *image = None; - icon = (Icon*) malloc (sizeof (struct Icon)); + icon = (Icon*) malloc (sizeof (Icon)); + + icon->otp = NULL; icon->border = Scr->IconBorderColor; icon->iconc.fore = Scr->IconC.fore; @@ -545,7 +539,7 @@ tmp_win->wmhints->flags & IconPixmapHint) { if (XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap, &JunkRoot, &JunkX, &JunkY, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth)) { - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); image->width = JunkWidth; image->height = JunkHeight; image->pixmap = XCreatePixmap (dpy, Scr->Root, image->width, @@ -805,15 +799,17 @@ if (final_y < 0) final_y = 0; XMoveWindow(dpy, icon->w, final_x, final_y); + icon->w_x = final_x; + icon->w_y = final_y; } tmp_win->iconified = TRUE; + OtpAdd(tmp_win, IconWin); XMapSubwindows(dpy, icon->w); XSaveContext(dpy, icon->w, TwmContext, (XPointer)tmp_win); XSaveContext(dpy, icon->w, ScreenContext, (XPointer)Scr); XDefineCursor(dpy, icon->w, Scr->IconCursor); MaybeAnimate = True; - return (0); } void SchrinkIconTitle (tmp_win) Index: icons.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/icons.h,v retrieving revision 1.1.1.3 retrieving revision 1.4 diff -u -r1.1.1.3 -r1.4 --- icons.h 28 Oct 1997 21:12:26 -0000 1.1.1.3 +++ icons.h 11 Mar 1998 04:32:40 -0000 1.4 @@ -57,16 +57,21 @@ #ifndef ICONS_H #define ICONS_H +#include "typedefs.h" + typedef enum {match_none, match_class, match_name, match_icon} Matchtype; -typedef struct Icon +struct Icon { Matchtype match; Window w; /* the icon window */ + OtpWinList *otp; /* OnTopPriority info for the icon */ Window bm_w; /* the icon bitmap window */ - Image *image; /* image icon structure */ + Image *image; /* image icon structure */ int x; /* icon text x coordinate */ int y; /* icon text y coordiante */ + int w_x; /* x coor of the icon window !!untested!! */ + int w_y; /* y coor of the icon window !!untested!! */ int w_width; /* width of the icon window */ int w_height; /* height of the icon window */ int width; /* width of the icon bitmap */ @@ -76,38 +81,39 @@ ColorPair iconc; Bool has_title, title_schrinked; int border_width; - struct IconRegion *ir; -} Icon; + IconRegion *ir; +}; -typedef struct IconRegion +struct IconRegion { - struct IconRegion *next; + IconRegion *next; int x, y, w, h; int grav1, grav2; int stepx, stepy; /* allocation granularity */ short TitleJustification; /* J_LEFT, J_CENTER or J_RIGHT */ short Justification; /* J_LEFT, J_CENTER J_RIGHT or J_BORDER */ short Alignement; /* J_TOP, J_CENTER, J_BOTTOM or J_BORDER */ - name_list *clientlist; - struct IconEntry *entries; -} IconRegion; + name_list *clientlist; + IconEntry *entries; +}; -typedef struct IconEntry +struct IconEntry { - struct IconEntry *next; + IconEntry *next; int x, y, w, h; TwmWindow *twm_win; short used; -}IconEntry; +}; -extern int IconUp (); -extern int IconDown (); extern name_list **AddIconRegion(); -extern CreateIconWindow(); extern void SchrinkIconTitle (); extern void ExpandIconTitle (); extern void ReshapeIcon (); extern int GetIconOffset (); extern Bool AnimateIcons (); +void CreateIconWindow (TwmWindow *tmp_win, int def_x, int def_y); +void IconDown (TwmWindow *tmp_win); +int IconUp (TwmWindow *tmp_win); + #endif /* ICONS_H */ Index: lex.l =================================================================== RCS file: /u/monnier/cvsroot/ctwm/lex.l,v retrieving revision 1.1.1.3 retrieving revision 1.3 diff -u -r1.1.1.3 -r1.3 --- lex.l 7 Oct 1999 17:31:52 -0000 1.1.1.3 +++ lex.l 7 Oct 1999 19:09:10 -0000 1.3 @@ -72,10 +72,7 @@ #endif #include "gram.h" #include "parse.h" -extern char *ProgramName; -extern int ParseError; -extern int parse_keyword(),twmrc_error_prefix(); #ifdef FLEX_SCANNER int yylineno; # undef YY_INPUT @@ -117,7 +114,7 @@ "!" { yylval.num = F_EXEC; return FSKEYWORD; } "^" { yylval.num = F_CUT; return FSKEYWORD; } -{string} { yylval.ptr = (unsigned char *)yytext; return STRING; } +{string} { yylval.ptr = yytext; return STRING; } {number} { (void)sscanf((char *)yytext, "%d", &yylval.num); return (NUMBER); } @@ -132,7 +129,7 @@ } %% #ifndef yywrap -yywrap() { return(1);} +int yywrap() { return(1);} #endif #ifndef FLEX_SCANNER Index: libctwm.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/libctwm.c,v retrieving revision 1.1.1.3 retrieving revision 1.3 diff -u -r1.1.1.3 -r1.3 --- libctwm.c 2 Apr 2005 22:55:31 -0000 1.1.1.3 +++ libctwm.c 3 Apr 2005 16:35:58 -0000 1.3 @@ -23,6 +23,7 @@ * * Author: Claude Lecommandeur [ lecom@sic.epfl.ch ][ April 1992 ] */ +#include #include #include @@ -58,7 +59,8 @@ Display *dpy; int scrnum; { - unsigned char *prop, *p; + unsigned char *prop; + char *p; unsigned long bytesafter; unsigned long len; Atom actual_type; @@ -75,7 +77,7 @@ if (len == 0) return ((char**) 0); count = 0; - p = prop; + p = (char*)prop; l = 0; while (l < len) { l += strlen (p) + 1; @@ -84,7 +86,7 @@ } ret = (char**) malloc ((count + 1) * sizeof (char*)); - p = prop; + p = (char*)prop; l = 0; i = 0; while (l < len) { @@ -125,7 +127,7 @@ if (_XA_WM_CURRENTWORKSPACE == None) return (0); XChangeProperty (dpy, RootWindow (dpy, scrnum), _XA_WM_CURRENTWORKSPACE, XA_STRING, 8, - PropModeReplace, (unsigned char *) workspace, strlen (workspace)); + PropModeReplace, (unsigned char*)workspace, strlen(workspace)); XFlush (dpy); return (1); } @@ -134,7 +136,8 @@ Display *dpy; Window window; { - unsigned char *prop, *p; + unsigned char *prop; + char *p; unsigned long bytesafter; unsigned long len; Atom actual_type; @@ -151,7 +154,7 @@ if (len == 0) return ((char**) 0); count = 0; - p = prop; + p = (char*)prop; l = 0; while (l < len) { l += strlen (p) + 1; @@ -160,7 +163,7 @@ } ret = (char**) malloc ((count + 1) * sizeof (char*)); - p = prop; + p = (char*)prop; l = 0; i = 0; while (l < len) { @@ -198,7 +201,7 @@ occupation++; } XChangeProperty (dpy, window, _XA_WM_OCCUPATION, XA_STRING, 8, - PropModeReplace, (unsigned char *) occup, len - 1); + PropModeReplace, occup, len - 1); XFlush (dpy); free (occup); return (1); @@ -208,13 +211,13 @@ Display *dpy; Window window; { - unsigned char *prop; + char *prop; unsigned long bytesafter; unsigned long len; Atom actual_type; int actual_format; XWindowAttributes attr; - unsigned char *currentw; + char *currentw; if (! XGetWindowAttributes (dpy, window, &attr)) return (0); Index: list.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/list.c,v retrieving revision 1.1.1.4 retrieving revision 1.7 diff -u -r1.1.1.4 -r1.7 --- list.c 2 Apr 2005 23:00:28 -0000 1.1.1.4 +++ list.c 3 Apr 2005 16:35:58 -0000 1.7 @@ -72,17 +72,19 @@ #ifdef VMS #include #endif -#include "twm.h" +/* #include "twm.h" */ #include "screen.h" #include "gram.h" +#include "list.h" +#include "util.h" +#include "parse.h" + #ifdef USE_GNU_REGEX # include #endif /* USE_GNU_REGEX */ -extern int twmrc_error_prefix(); - /*********************************************************************** * * Procedure: @@ -102,9 +104,6 @@ *********************************************************************** */ -int match (); -int is_pattern (); - void AddToList(list_head, name, ptr) name_list **list_head; @@ -435,7 +434,7 @@ char *p, *t; { register int mat; - register nextp; + register int nextp; while ((*p == '?') || (*p == '*')) { if (*p == '?') { Index: list.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/list.h,v retrieving revision 1.1.1.1 retrieving revision 1.4 diff -u -r1.1.1.1 -r1.4 --- list.h 7 Nov 1995 15:57:03 -0000 1.1.1.1 +++ list.h 11 Mar 1998 04:32:40 -0000 1.4 @@ -64,22 +64,25 @@ #ifndef _LIST_ #define _LIST_ -typedef struct name_list_struct name_list; +#include "typedefs.h" +#include +#include -struct name_list_struct +struct name_list { name_list *next; /* pointer to the next name */ char *name; /* the name of the window */ char *ptr; /* list dependent data */ }; -extern void AddToList(); -extern char* LookInList(); -extern char* LookInNameList(); -extern char* LookPatternInList(); -extern char* LookPatternInNameList(); -extern int GetColorFromList(); -extern void FreeList(); +void AddToList (name_list **list_hd, char *name, char *ptr); +char* LookInList (name_list *list_hd, char *name, XClassHint *c); +char* LookInNameList (name_list *list_hd, char *name); +char* LookPatternInList (name_list *list_hd, char *name, XClassHint *c); +char* LookPatternInNameList (name_list *list_hd, char *name); +int GetColorFromList (name_list *list_hd, char *name, XClassHint *c, Pixel *ptr); +void FreeList (name_list **list); +int match (char *p, char *t); #endif /* _LIST_ */ Index: menus.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/menus.c,v retrieving revision 1.1.1.12 retrieving revision 1.16 diff -u -r1.1.1.12 -r1.16 --- menus.c 2 Apr 2005 23:00:29 -0000 1.1.1.12 +++ menus.c 3 Apr 2005 16:35:58 -0000 1.16 @@ -98,6 +98,7 @@ #include "add_window.h" #include "workmgr.h" #include "cursor.h" +#include "session.h" #ifdef VMS #include #include @@ -112,6 +113,9 @@ #include #endif +#include "otp.h" +#include "iconmgr.h" + #if defined(MACH) || defined(__MACH__) || defined(sony_news) || defined(NeXT) #define lrand48 random #endif @@ -119,19 +123,10 @@ #define lrand48 rand #endif -#ifndef VMS -#define MAX(x,y) ((x)>(y)?(x):(y)) -#define MIN(x,y) ((x)<(y)?(x):(y)) -#endif -#define ABS(x) ((x)<0?-(x):(x)) - #ifdef SOUNDS -extern int toggle_sound(); -extern int reread_sounds(); +#include "sound.h" #endif -extern XEvent Event; - int RootFunction = 0; MenuRoot *ActiveMenu = NULL; /* the active menu */ MenuItem *ActiveItem = NULL; /* the active menu item */ @@ -142,9 +137,6 @@ int AlternateKeymap; Bool AlternateContext; -extern int captive; -extern char *captivename; - int ConstMove = FALSE; /* constrained move variables */ int ConstMoveDir; int ConstMoveX; @@ -167,20 +159,30 @@ static Cursor LastCursor; static Bool addingdefaults = False; -void WarpAlongRing(), WarpToWindow(); -void DisplayPosition (); -void packwindow(), fillwindow(); -void jump (); -int FindConstraint (); -int CreateFonts(); /* in ctwm.c */ -int match (); /* in list.c */ - -extern char *Action; -extern int Context; -extern TwmWindow *ButtonWindow, *Tmp_win; -extern XEvent Event, ButtonEvent; -extern char *InitFile; -static void Identify(); +static void jump (TwmWindow *tmp_win, int direction, char *action); +static void WarpAlongRing (XButtonEvent *ev, Bool forward); +static void packwindow (TwmWindow *tmp_win, char *direction); +static void fillwindow (TwmWindow *tmp_win, char *direction); +static int FindConstraint (TwmWindow *tmp_win, int direction); +static void Paint3DEntry(MenuRoot *mr, MenuItem *mi, int exposure); +static void PaintNormalEntry(MenuRoot *mr, MenuItem *mi, int exposure); +static void MakeMenu (MenuRoot *mr); +static void DestroyMenu (MenuRoot *menu); +static void MosaicFade (TwmWindow *tmp_win, Window blanket); +static void SendSaveYourselfMessage (TwmWindow *tmp, Time timestamp); +static void SendDeleteWindowMessage (TwmWindow *tmp, Time timestamp); +static void HideIconManager (void); +static void ShowIconManager (void); +static void BumpWindowColormap (TwmWindow *tmp, int inc); +static void Identify (TwmWindow *t); +static int WarpToScreen (int n, int inc); +static void Execute (char *s); +static int NeedToDefer (MenuRoot *root); +static int DeferExecution(int context, int func, Cursor cursor); +static void ZoomInWindow (TwmWindow *tmp_win, Window blanket); +static void ZoomOutWindow (TwmWindow *tmp_win, Window blanket); +static void SweepWindow (TwmWindow *tmp_win, Window blanket); +static void waitamoment (float timeout); #define SHADOWWIDTH 5 /* in pixels */ @@ -510,10 +512,7 @@ } -PaintEntry(mr, mi, exposure) -MenuRoot *mr; -MenuItem *mi; -int exposure; +void PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) { if (Scr->use3Dmenus) Paint3DEntry (mr, mi, exposure); @@ -522,10 +521,7 @@ if (mi->state) mr->lastactive = mi; } -Paint3DEntry(mr, mi, exposure) -MenuRoot *mr; -MenuItem *mi; -int exposure; +static void Paint3DEntry(MenuRoot *mr, MenuItem *mi, int exposure) { int y_offset; int text_y; @@ -622,10 +618,7 @@ -PaintNormalEntry(mr, mi, exposure) -MenuRoot *mr; -MenuItem *mi; -int exposure; +static void PaintNormalEntry(MenuRoot *mr, MenuItem *mi, int exposure) { int y_offset; int text_y; @@ -736,9 +729,7 @@ } } -PaintMenu(mr, e) -MenuRoot *mr; -XEvent *e; +void PaintMenu (MenuRoot *mr, XEvent *e) { MenuItem *mi; @@ -764,7 +755,8 @@ -void MakeWorkspacesMenu () { +void MakeWorkspacesMenu (void) +{ static char **actions = NULL; WorkSpace *wlist; char **act; @@ -798,7 +790,7 @@ static Bool fromMenu; -UpdateMenu() +void UpdateMenu (void) { MenuItem *mi; int i, x, y, x_root, y_root, entry; @@ -832,7 +824,7 @@ if ((! ActiveMenu) || Cancel) { menuFromFrameOrWindowOrTitlebar = FALSE; fromMenu = FALSE; - return (0); + return; } if (Event.type != MotionNotify) @@ -954,7 +946,6 @@ char *name; { MenuRoot *tmp; - static MenuRoot *tmpRoot; #define UNUSED_PIXEL ((unsigned long) (~0)) /* more than 24 bits */ @@ -1150,7 +1141,7 @@ } -MakeMenus() +void MakeMenus (void) { MenuRoot *mr; @@ -1166,8 +1157,7 @@ -MakeMenu(mr) -MenuRoot *mr; +static void MakeMenu (MenuRoot *mr) { MenuItem *start, *end, *cur, *tmp; XColor f1, f2, f3; @@ -1343,7 +1333,7 @@ mr->pmenu = NULL; if (Scr->Monochrome == MONOCHROME || !Scr->InterpolateMenuColors) - return 0; + return; start = mr->first; while (TRUE) @@ -1506,7 +1496,7 @@ if (strcmp (ws->name, CurrentSelectedWorkspace) == 0) break; } } - if (!Scr->currentvs) return; + if (!Scr->currentvs) return False; if (!ws) ws = Scr->currentvs->wsw->currentwspc; WindowNameOffset=(char *)Scr->TwmRoot.next->name - @@ -1749,12 +1739,11 @@ *********************************************************************** */ -PopDownMenu() +void PopDownMenu (void) { MenuRoot *tmp; - if (ActiveMenu == NULL) - return (1); + if (ActiveMenu == NULL) return; if (ActiveItem) { @@ -1779,10 +1768,9 @@ -HideMenu (menu) -MenuRoot *menu; +void HideMenu (MenuRoot *menu) { - if (!menu) return False; + if (!menu) return; if (Scr->Shadow) { XUnmapWindow (dpy, menu->shadow); @@ -1852,11 +1840,6 @@ */ -extern int AddingX; -extern int AddingY; -extern int AddingW; -extern int AddingH; - void resizeFromCenter(w, tmp_win) Window w; TwmWindow *tmp_win; @@ -1998,7 +1981,6 @@ int moving_icon = FALSE; Bool fromtitlebar = False; Bool from3dborder = False; - extern int ConstrainedMoveTime; TwmWindow *t; RootFunction = 0; @@ -2055,9 +2037,6 @@ break; case F_RESTART: { -#ifdef X11R6 - extern SmcConn smcConn; -#endif StopAnimation (); XSync (dpy, 0); Reborder (eventp->xbutton.time); @@ -2123,7 +2102,7 @@ case F_SHOWWORKMGR: if (! Scr->workSpaceManagerActive) break; DeIconify (Scr->currentvs->wsw->twm_win); - RaiseWindow(Scr->currentvs->wsw->twm_win); + OtpRaise(Scr->currentvs->wsw->twm_win, WinWin); break; case F_HIDEWORKMGR: @@ -2139,7 +2118,7 @@ eventp->xbutton.y_root - 5); else { DeIconify (Scr->currentvs->wsw->twm_win); - RaiseWindow(Scr->currentvs->wsw->twm_win); + OtpRaise(Scr->currentvs->wsw->twm_win, WinWin); } break; @@ -2166,7 +2145,7 @@ MenuRoot *menu; if (ActiveMenu->pmenu == NULL) { - menu = (MenuRoot*) malloc (sizeof (struct MenuRoot)); + menu = (MenuRoot*) malloc (sizeof (MenuRoot)); *menu = *ActiveMenu; menu->pinned = True; menu->mapped = NEVER_MAPPED; @@ -2409,7 +2388,7 @@ else { DeIconify(tmp_win); - RaiseWindow (tmp_win); + OtpRaise (tmp_win, WinWin); } break; @@ -2419,7 +2398,7 @@ if (! tmp_win) break; if (Scr->WarpUnmapped || tmp_win->mapped) { if (!tmp_win->mapped) DeIconify (tmp_win); - if (!Scr->NoRaiseWarp) RaiseWindow (tmp_win); + if (!Scr->NoRaiseWarp) OtpRaise (tmp_win, WinWin); WarpToWindow (tmp_win); } break; @@ -2436,7 +2415,7 @@ break; } if (tmp_win->OpaqueResize) { - int sw, ss; + unsigned int sw, ss; sw = tmp_win->frame_width * tmp_win->frame_height; ss = Scr->rootw * Scr->rooth; @@ -2564,7 +2543,6 @@ case F_HYPERMOVE: { Bool cont = True; Window root = RootWindow (dpy, Scr->screen); - Window croot; Cursor cursor; CaptiveCTWM cctwm0, cctwm; @@ -2583,8 +2561,6 @@ ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, root, cursor, CurrentTime); while (cont) { - Window child; - XMaskEvent (dpy, ButtonPressMask | ButtonMotionMask | ButtonReleaseMask, &Event); switch (Event.xany.type) { @@ -2813,6 +2789,10 @@ Cursor cur; if (Scr->OpaqueMove) XMoveWindow (dpy, DragWindow, origDragX, origDragY); + if (moving_icon) { + tmp_win->icon->w_x = origDragX; + tmp_win->icon->w_y = origDragY; + } else MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0); DragWindow = None; @@ -2890,9 +2870,18 @@ DragWindow = w; - if (!Scr->NoRaiseMove && Scr->OpaqueMove && !WindowMoved) - RaiseFrame(DragWindow); - + if (!Scr->NoRaiseMove && Scr->OpaqueMove && !WindowMoved) { + if (XFindContext(dpy, DragWindow, TwmContext, (caddr_t *) &t) == XCNOENT) + fprintf(stderr, "ERROR: menus.c:2331\n"); + + if (DragWindow == t->frame) { + OtpRaise(t, WinWin); + } else if (t->icon && DragWindow == t->icon->w) { + OtpRaise(t, IconWin); + } else { + fprintf(stderr, "ERROR: menus.c:2338\n"); + } + } WindowMoved = TRUE; if (ConstMove) @@ -2951,6 +2940,10 @@ tmp_win->frame_width, tmp_win->frame_height, -1); } else { XMoveWindow(dpy, DragWindow, xl, yt); + if (moving_icon) { + tmp_win->icon->w_x = xl; + tmp_win->icon->w_y = yt; + } } WMapSetupWindow (tmp_win, xl, yt, -1, -1); } @@ -2996,6 +2989,10 @@ tmp_win->frame_width, tmp_win->frame_height, -1); } else { XMoveWindow(dpy, DragWindow, xl, yt); + if (moving_icon) { + tmp_win->icon->w_x = xl; + tmp_win->icon->w_y = yt; + } } if (! moving_icon) WMapSetupWindow (tmp_win, xl, yt, -1, -1); } @@ -3012,6 +3009,39 @@ UninstallRootColormap(); break; } + + case F_PRIORITYSWITCHING: + case F_SWITCHPRIORITY: + case F_SETPRIORITY: + case F_CHANGEPRIORITY: + { + WinType wintype; + + if (DeferExecution(context, func, Scr->SelectCursor)) + return TRUE; + + if (tmp_win->icon && w == tmp_win->icon->w) { + wintype = IconWin; + } else { + wintype = WinWin; + } + switch (func) { + case F_PRIORITYSWITCHING: + OtpToggleSwitching(tmp_win, wintype); + break; + case F_SETPRIORITY: + OtpSetPriority(tmp_win, wintype, atoi(action)); + break; + case F_CHANGEPRIORITY: + OtpChangePriority(tmp_win, wintype, atoi(action)); + break; + case F_SWITCHPRIORITY: + OtpSwitchPriority(tmp_win, wintype); + break; + } + } + break; + case F_FUNCTION: { MenuRoot *mroot; @@ -3064,6 +3094,13 @@ Squeeze (tmp_win); break; + case F_UNSQUEEZE: + if (DeferExecution(context, func, Scr->SelectCursor)) + return TRUE; + + if (tmp_win->squeezed) Squeeze(tmp_win); + break; + case F_SHOWBGRD: ShowBackground (Scr->currentvs); break; @@ -3074,23 +3111,63 @@ if (!WindowMoved) { if (tmp_win->icon && w == tmp_win->icon->w) { - RaiseLowerFrame(w, ONTOP_DEFAULT); + OtpRaiseLower(tmp_win, IconWin); } else { - RaiseLower(tmp_win); + OtpRaiseLower(tmp_win, WinWin); WMapRaiseLower (tmp_win); } } break; + case F_TINYRAISE: + if (DeferExecution(context, func, Scr->SelectCursor)) + return TRUE; + + /* check to make sure raise is not from the WindowFunction */ + if (tmp_win->icon && (w == tmp_win->icon->w) && Context != C_ROOT) + OtpTinyRaise(tmp_win, IconWin); + else { + OtpTinyRaise(tmp_win, WinWin); + WMapRaise (tmp_win); + } + break; + + case F_TINYLOWER: + if (DeferExecution(context, func, Scr->SelectCursor)) + return TRUE; + + /* check to make sure raise is not from the WindowFunction */ + if (tmp_win->icon && (w == tmp_win->icon->w) && Context != C_ROOT) + OtpTinyLower(tmp_win, IconWin); + else { + OtpTinyLower(tmp_win, WinWin); + WMapRaise (tmp_win); + } + break; + + case F_RAISEORSQUEEZE: + if (DeferExecution(context, func, Scr->SelectCursor)) + return TRUE; + + /* FIXME using the same double-click ConstrainedMoveTime here */ + /* fuck that I don't care, this is my hack */ + if ( (eventp->xbutton.time - last_time) < ConstrainedMoveTime ) + { + Squeeze (tmp_win); + break; + } + last_time = eventp->xbutton.time; + /* intentional fall-thru into raiselower */ + case F_RAISE: if (DeferExecution(context, func, Scr->SelectCursor)) return TRUE; /* check to make sure raise is not from the WindowFunction */ if (tmp_win->icon && (w == tmp_win->icon->w) && Context != C_ROOT) - XRaiseWindow(dpy, tmp_win->icon->w); + OtpRaise(tmp_win, IconWin); else { - RaiseWindow (tmp_win); + OtpRaise(tmp_win, WinWin); WMapRaise (tmp_win); } break; @@ -3100,9 +3177,9 @@ return TRUE; if (tmp_win->icon && (w == tmp_win->icon->w)) - XLowerWindow(dpy, tmp_win->icon->w); + OtpLower(tmp_win, IconWin); else { - LowerWindow(tmp_win); + OtpLower(tmp_win, WinWin); WMapLower (tmp_win); } break; @@ -3110,7 +3187,7 @@ case F_RAISEICONS: for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { if (t->icon && t->icon->w) { - XRaiseWindow (dpy, t->icon->w); + OtpRaise(t, IconWin); } } break; @@ -3332,7 +3409,7 @@ if (t) { if (Scr->WarpUnmapped || t->mapped) { if (!t->mapped) DeIconify (t); - if (!Scr->NoRaiseWarp) RaiseWindow (t); + if (!Scr->NoRaiseWarp) OtpRaise(t, WinWin); WarpToWindow (t); } } else { @@ -3343,24 +3420,24 @@ case F_WARPTOICONMGR: { - TwmWindow *t; + TwmWindow *t, *raise_win = NULL; int len; - Window raisewin = None, iconwin = None; + Window iconwin = None; len = strlen(action); if (len == 0) { if (tmp_win && tmp_win->list) { - raisewin = tmp_win->list->iconmgr->twm_win->frame; + raise_win = tmp_win->list->iconmgr->twm_win; iconwin = tmp_win->list->icon; } else if (Scr->iconmgr->active) { - raisewin = Scr->iconmgr->twm_win->frame; + raise_win = Scr->iconmgr->twm_win; iconwin = Scr->iconmgr->active->w; } } else { for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { if (strncmp (action, t->icon_name, len) == 0) { if (t->list && t->list->iconmgr->twm_win->mapped) { - raisewin = t->list->iconmgr->twm_win->frame; + raise_win = t->list->iconmgr->twm_win; iconwin = t->list->icon; break; } @@ -3368,8 +3445,8 @@ } } - if (raisewin) { - RaiseFrame(raisewin); + if (raise_win) { + OtpRaise(raise_win, WinWin); XWarpPointer (dpy, None, iconwin, 0,0,0,0, 5, 5); } else { XBell (dpy, 0); @@ -3583,25 +3660,16 @@ *********************************************************************** */ -int -DeferExecution(context, func, cursor) -int context, func; -Cursor cursor; +static int DeferExecution(int context, int func, Cursor cursor) { if ((context == C_ROOT) || (context == C_ALTERNATE)) { LastCursor = cursor; - if (func == F_ADOPTWINDOW) { - XGrabPointer(dpy, Scr->Root, True, - ButtonPressMask | ButtonReleaseMask, - GrabModeAsync, GrabModeAsync, - None, cursor, CurrentTime); - } else { - int status = XGrabPointer(dpy, Scr->Root, True, + XGrabPointer(dpy, Scr->Root, True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, - Scr->Root, cursor, CurrentTime); - } + (func == F_ADOPTWINDOW) ? None : Scr->Root, + cursor, CurrentTime); RootFunction = func; return (TRUE); @@ -3620,7 +3688,7 @@ *********************************************************************** */ -ReGrab() +void ReGrab (void) { XGrabPointer(dpy, Scr->Root, True, ButtonPressMask | ButtonReleaseMask, @@ -3642,8 +3710,7 @@ *********************************************************************** */ -NeedToDefer(root) -MenuRoot *root; +static int NeedToDefer (MenuRoot *root) { MenuItem *mitem; @@ -3692,9 +3759,7 @@ *********************************************************************** */ -void -Execute(s) - char *s; +static void Execute (char *s) { #ifdef VMS createProcess(s); @@ -3772,10 +3837,14 @@ SigProc sig; sig = signal (SIGALRM, SIG_IGN); + XUngrabPointer(dpy, CurrentTime); + XFlush(dpy); (void) system (s); signal (SIGALRM, sig); } #else /* USE_SIGNALS */ + XUngrabPointer(dpy, CurrentTime); + XFlush(dpy); (void) system (s); #endif /* USE_SIGNALS */ @@ -3788,148 +3857,6 @@ } - -Window lowerontop = -1; - -void PlaceTransients (tmp_win, where) -TwmWindow *tmp_win; -int where; -{ - int sp, sc; - TwmWindow *t; - XWindowChanges xwc; - xwc.stack_mode = where; - - sp = tmp_win->frame_width * tmp_win->frame_height; - for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { - if ((t->transient && t->transientfor == tmp_win->w) || - ((tmp_win->group == tmp_win->w) && (tmp_win->group == t->group) && - (tmp_win->group != t->w))) { - if (t->frame) { - sc = t->frame_width * t->frame_height; - if (sc < ((sp * Scr->TransientOnTop) / 100)) { - xwc.sibling = tmp_win->frame; - XConfigureWindow(dpy, t->frame, CWSibling | CWStackMode, &xwc); - if (lowerontop == t->frame) { - lowerontop = -1; - } - } - } - } - } -} - -#include - -void PlaceOntop (ontop, where) -int ontop; -int where; -{ - TwmWindow *t; - XWindowChanges xwc; - xwc.stack_mode = where; - - lowerontop = -1; - - for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { - if (t->ontoppriority > ontop) { - XConfigureWindow(dpy, t->frame, CWStackMode, &xwc); - PlaceTransients(t, Above); - if (lowerontop == -1) { - lowerontop = t->frame; - } - } - } -} - -void MapRaised (tmp_win) -TwmWindow *tmp_win; -{ - XMapWindow(dpy, tmp_win->frame); - RaiseWindow(tmp_win); -} - -void RaiseWindow (tmp_win) -TwmWindow *tmp_win; -{ - XWindowChanges xwc; - int xwcm; - - if (tmp_win->ontoppriority == ONTOP_MAX) { - XRaiseWindow(dpy, tmp_win->frame); - if (lowerontop == -1) { - lowerontop = tmp_win->frame; - } else if (lowerontop == tmp_win->frame) { - lowerontop = -1; - } - } else { - if (lowerontop == -1) { - PlaceOntop(tmp_win->ontoppriority, Above); - } - xwcm = CWStackMode; - if (lowerontop != -1) { - xwc.stack_mode = Below; - xwc.sibling = lowerontop; - xwcm |= CWSibling; - } else { - xwc.stack_mode = Above; - } - XConfigureWindow(dpy, tmp_win->frame, xwcm, &xwc); - } - PlaceTransients(tmp_win, Above); -} - -void RaiseLower (tmp_win) -TwmWindow *tmp_win; -{ - XWindowChanges xwc; - - PlaceOntop(tmp_win->ontoppriority, Below); - PlaceTransients(tmp_win, Below); - lowerontop = -1; - xwc.stack_mode = Opposite; - XConfigureWindow(dpy, tmp_win->frame, CWStackMode, &xwc); - PlaceOntop(tmp_win->ontoppriority, Above); - PlaceTransients(tmp_win, Above); -} - -void RaiseLowerFrame (frame, ontop) -Window frame; -int ontop; -{ - XWindowChanges xwc; - - PlaceOntop(ontop, Below); - lowerontop = -1; - xwc.stack_mode = Opposite; - XConfigureWindow(dpy, frame, CWStackMode, &xwc); - PlaceOntop(ontop, Above); -} - -void LowerWindow (tmp_win) -TwmWindow *tmp_win; -{ - XLowerWindow(dpy, tmp_win->frame); - if (tmp_win->frame == lowerontop) { - lowerontop = -1; - } - PlaceTransients(tmp_win, Above); -} - -void RaiseFrame (frame) -Window frame; -{ - TwmWindow *tmp_win; - - if (XFindContext (dpy, frame, TwmContext, (XPointer *) &tmp_win) == XCNOENT) - tmp_win = NULL; - - if (tmp_win != NULL) { - RaiseWindow(tmp_win); - } else { - XRaiseWindow(dpy, frame); - } -} /*********************************************************************** * @@ -3947,8 +3874,7 @@ if (! Scr->ClickToFocus) Scr->FocusRoot = TRUE; } -DeIconify(tmp_win) -TwmWindow *tmp_win; +void DeIconify (TwmWindow *tmp_win) { TwmWindow *t; WList *wl; @@ -3975,11 +3901,11 @@ if (!tmp_win->squeezed) XMapWindow(dpy, tmp_win->w); tmp_win->mapped = TRUE; if (Scr->Root != Scr->CaptiveRoot) - XReparentWindow (dpy, tmp_win->frame, Scr->Root, tmp_win->frame_x, tmp_win->frame_y); - if (Scr->NoRaiseDeicon) { - XMapWindow (dpy, tmp_win->frame); - } else - MapRaised(tmp_win); + ReparentWindow (dpy, tmp_win, WinWin, Scr->Root, tmp_win->frame_x, tmp_win->frame_y); + if (!Scr->NoRaiseDeicon) + OtpRaise(tmp_win, WinWin); + XMapWindow(dpy, tmp_win->frame); + SetMapStateProp(tmp_win, NormalState); if (tmp_win->icon && tmp_win->icon->w) { @@ -4014,11 +3940,10 @@ if (!t->squeezed) XMapWindow(dpy, t->w); t->mapped = TRUE; if (Scr->Root != Scr->CaptiveRoot) - XReparentWindow (dpy, t->frame, Scr->Root, t->frame_x, t->frame_y); - if (Scr->NoRaiseDeicon) - XMapWindow(dpy, t->frame); - else - MapRaised(t); + ReparentWindow (dpy, t, WinWin, Scr->Root, t->frame_x, t->frame_y); + if (!Scr->NoRaiseDeicon) + OtpRaise(t, WinWin); + XMapWindow(dpy, t->frame); SetMapStateProp(t, NormalState); if (t->icon && t->icon->w) { @@ -4046,9 +3971,7 @@ -Iconify(tmp_win, def_x, def_y) -TwmWindow *tmp_win; -int def_x, def_y; +void Iconify (TwmWindow *tmp_win, int def_x, int def_y) { TwmWindow *t; int iconify; @@ -4085,8 +4008,10 @@ XRaiseWindow (dpy, Scr->WindowMask); XMapWindow(dpy, tmp_win->icon->w); } - else - XMapRaised(dpy, tmp_win->icon->w); + else { + OtpRaise(tmp_win, IconWin); + XMapWindow(dpy, tmp_win->icon->w); + } } } if (tmp_win->list) @@ -4191,7 +4116,7 @@ TwmWindow *tmp_win; { if (tmp_win->iconmgr) return; - if (Scr->RaiseWhenAutoUnSqueeze && tmp_win->squeezed) XRaiseWindow (dpy, tmp_win->frame); + if (Scr->RaiseWhenAutoUnSqueeze && tmp_win->squeezed) OtpRaise (tmp_win, WinWin); Squeeze (tmp_win); } void Squeeze (tmp_win) @@ -4343,6 +4268,19 @@ (void) sprintf(Info[n++], "Border width = %d", bw); (void) sprintf(Info[n++], "Depth = %d", depth); + if (t->icon != NULL) { + XGetGeometry (dpy, t->icon->w, &JunkRoot, &JunkX, &JunkY, + &wwidth, &wheight, &bw, &depth); + Info[n++][0] = '\0'; + (void) sprintf(Info[n++], "IconGeom/root = %dx%d+%d+%d", + wwidth, wheight, JunkX, JunkY); + (void) sprintf(Info[n++], "IconGeom/intern = %dx%d+%d+%d", + t->icon->w_width, t->icon->w_height, + t->icon->w_x, t->icon->w_y); + (void) sprintf(Info[n++], "IconBorder width = %d", bw); + (void) sprintf(Info[n++], "IconDepth = %d", depth); + } + if (XGetWindowProperty (dpy, t->w, _XA_WM_CLIENT_MACHINE, 0L, 64, False, XA_STRING, &actual_type, &actual_format, &nitems, &bytesafter, &prop) == Success) { @@ -4400,9 +4338,7 @@ -SetMapStateProp(tmp_win, state) -TwmWindow *tmp_win; -int state; +void SetMapStateProp(TwmWindow *tmp_win, int state) { unsigned long data[2]; /* "suggested" by ICCCM version 1 */ @@ -4444,8 +4380,7 @@ -WarpToScreen (n, inc) - int n, inc; +static int WarpToScreen (int n, int inc) { Window dumwin; int x, y, dumint; @@ -4490,22 +4425,20 @@ * BumpWindowColormap - rotate our internal copy of WM_COLORMAP_WINDOWS */ -BumpWindowColormap (tmp, inc) - TwmWindow *tmp; - int inc; +static void BumpWindowColormap (TwmWindow *tmp, int inc) { int i, j, previously_installed; ColormapWindow **cwins; - if (!tmp) return (1); + if (!tmp) return; if (inc && tmp->cmaps.number_cwins > 0) { cwins = (ColormapWindow **) malloc(sizeof(ColormapWindow *)* tmp->cmaps.number_cwins); if (cwins) { - if (previously_installed = + if ((previously_installed = /* SUPPRESS 560 */(Scr->cmapInfo.cmaps == &tmp->cmaps && - tmp->cmaps.number_cwins)) { + tmp->cmaps.number_cwins))) { for (i = tmp->cmaps.number_cwins; i-- > 0; ) tmp->cmaps.cwins[i]->colormap->state = 0; } @@ -4549,7 +4482,8 @@ if (visible (i->twm_win)) { SetMapStateProp (i->twm_win, NormalState); XMapWindow (dpy, i->twm_win->w); - MapRaised (i->twm_win); + OtpRaise(i->twm_win, WinWin); + XMapWindow (dpy, i->twm_win->frame); if (i->twm_win->icon && i->twm_win->icon->w) XUnmapWindow (dpy, i->twm_win->icon->w); } @@ -4579,8 +4513,7 @@ -DestroyMenu (menu) - MenuRoot *menu; +static void DestroyMenu (MenuRoot *menu) { MenuItem *item; @@ -4604,7 +4537,7 @@ * warping routines */ -void WarpAlongRing (ev, forward) +static void WarpAlongRing (ev, forward) XButtonEvent *ev; Bool forward; { @@ -4707,38 +4640,36 @@ XSendEvent (dpy, w, False, 0L, (XEvent *) &ev); } -SendDeleteWindowMessage (tmp, timestamp) - TwmWindow *tmp; - Time timestamp; +static void SendDeleteWindowMessage (TwmWindow *tmp, Time timestamp) { send_clientmessage (tmp->w, _XA_WM_DELETE_WINDOW, timestamp); } -SendSaveYourselfMessage (tmp, timestamp) - TwmWindow *tmp; - Time timestamp; +void SendEndAnimationMessage (Window w, Time timestamp) +{ + send_clientmessage (w, _XA_WM_END_OF_ANIMATION, timestamp); +} + +static void SendSaveYourselfMessage (TwmWindow *tmp, Time timestamp) { send_clientmessage (tmp->w, _XA_WM_SAVE_YOURSELF, timestamp); } -SendTakeFocusMessage (tmp, timestamp) - TwmWindow *tmp; - Time timestamp; +void SendTakeFocusMessage (TwmWindow *tmp, Time timestamp) { send_clientmessage (tmp->w, _XA_WM_TAKE_FOCUS, timestamp); } -MoveMenu (eventp) -XEvent *eventp; +void MoveMenu (XEvent *eventp) { int XW, YW, newX, newY, cont; Bool newev; unsigned long event_mask; XEvent ev; - if (! ActiveMenu) return (1); - if (! ActiveMenu->pinned) return (1); + if (! ActiveMenu) return; + if (! ActiveMenu->pinned) return; XW = eventp->xbutton.x_root - ActiveMenu->x; YW = eventp->xbutton.y_root - ActiveMenu->y; @@ -4853,12 +4784,10 @@ #endif } -MosaicFade (tmp_win, blanket) -TwmWindow *tmp_win; -Window blanket; +static void MosaicFade (TwmWindow *tmp_win, Window blanket) { int srect; - int i, j, usec, nrects; + int i, j, nrects; Pixmap mask; GC gc; XGCValues gcv; @@ -4896,17 +4825,13 @@ free (rectangles); } -ZoomInWindow (tmp_win, blanket) -TwmWindow *tmp_win; -Window blanket; +static void ZoomInWindow (TwmWindow *tmp_win, Window blanket) { Pixmap mask; GC gc, gcn; XGCValues gcv; int i, nsteps = 20; - int x = tmp_win->frame_x; - int y = tmp_win->frame_y; int w = tmp_win->frame_width; int h = tmp_win->frame_height; int step = (MAX (w, h)) / (2.0 * nsteps); @@ -4930,17 +4855,13 @@ } } -ZoomOutWindow (tmp_win, blanket) -TwmWindow *tmp_win; -Window blanket; +static void ZoomOutWindow (TwmWindow *tmp_win, Window blanket) { Pixmap mask; GC gc; XGCValues gcv; int i, nsteps = 20; - int x = tmp_win->frame_x; - int y = tmp_win->frame_y; int w = tmp_win->frame_width; int h = tmp_win->frame_height; int step = (MAX (w, h)) / (2.0 * nsteps); @@ -4964,43 +4885,7 @@ } } -FadeWindow (tmp_win, blanket) -TwmWindow *tmp_win; -Window blanket; -{ - Pixmap mask, stipple; - GC gc; - XGCValues gcv; - static char stipple_bits[] = { 0x0F, 0x0F, - 0xF0, 0xF0, - 0x0F, 0x0F, - 0xF0, 0xF0, - 0x0F, 0x0F, - 0xF0, 0xF0, - 0x0F, 0x0F, - 0xF0, 0xF0, - }; - int w = tmp_win->frame_width; - int h = tmp_win->frame_height; - - stipple = XCreateBitmapFromData (dpy, blanket, stipple_bits, 8, 8); - mask = XCreatePixmap (dpy, blanket, w, h, 1); - gcv.background = 0; - gcv.foreground = 1; - gcv.stipple = stipple; - gcv.fill_style = FillOpaqueStippled; - gc = XCreateGC (dpy, mask, GCBackground | GCForeground | GCFillStyle | GCStipple, &gcv); - XFillRectangle (dpy, mask, gc, 0, 0, w, h); - - XShapeCombineMask (dpy, blanket, ShapeBounding, 0, 0, mask, ShapeSet); - XFlush (dpy); - waitamoment (10.0); - XFreePixmap (dpy, stipple); -} - -SweepWindow (tmp_win, blanket) -TwmWindow *tmp_win; -Window blanket; +static void SweepWindow (TwmWindow *tmp_win, Window blanket) { float step; int i, nsteps = 20; @@ -5036,8 +4921,7 @@ } } -int waitamoment (timeout) -float timeout; +static void waitamoment (float timeout) { #ifdef VMS lib$wait (&timeout); @@ -5050,13 +4934,11 @@ #endif } -void packwindow (tmp_win, direction) -TwmWindow *tmp_win; -char *direction; +static void packwindow (TwmWindow *tmp_win, char *direction) { int cons, newx, newy; int x, y, px, py, junkX, junkY; - unsigned int junkB, junkD, junkK; + unsigned int junkK; Window junkW; if (!strcmp (direction, "left")) { @@ -5090,17 +4972,17 @@ px = x - tmp_win->frame_x + newx; py = y - tmp_win->frame_y + newy; XWarpPointer (dpy, Scr->Root, Scr->Root, 0, 0, 0, 0, px, py); - XRaiseWindow(dpy, tmp_win->frame); + OtpRaise(tmp_win, WinWin); XMoveWindow (dpy, tmp_win->frame, newx, newy); SetupWindow (tmp_win, newx, newy, tmp_win->frame_width, tmp_win->frame_height, -1); } -void fillwindow (tmp_win, direction) +static void fillwindow (tmp_win, direction) TwmWindow *tmp_win; char *direction; { int cons, newx, newy, neww, newh, save; - int x, y, i; + int i; int winx = tmp_win->frame_x; int winy = tmp_win->frame_y; int winw = tmp_win->frame_width + 2 * tmp_win->frame_bw; @@ -5202,15 +5084,12 @@ SetupWindow (tmp_win, newx, newy, neww, newh, -1); } -void jump (tmp_win, direction, action) -TwmWindow *tmp_win; -int direction; -char *action; +static void jump (TwmWindow *tmp_win, int direction, char *action) { int fx, fy, px, py, step, stat, cons; int fwidth, fheight; int junkX, junkY; - unsigned int junkB, junkD, junkK; + unsigned int junkK; Window junkW; if (! action) return; @@ -5254,7 +5133,7 @@ /* Pebl Fixme: don't warp if jump happens through iconmgr */ XWarpPointer (dpy, Scr->Root, Scr->Root, 0, 0, 0, 0, fx + px, fy + py); if (!Scr->NoRaiseMove) - XRaiseWindow (dpy, tmp_win->frame); + OtpRaise (tmp_win, WinWin); SetupWindow (tmp_win, fx, fy, tmp_win->frame_width, tmp_win->frame_height, -1); } @@ -5475,8 +5354,7 @@ } } -WarpCursorToDefaultEntry (menu) -MenuRoot *menu; +void WarpCursorToDefaultEntry (MenuRoot *menu) { MenuItem *item; Window root; @@ -5487,7 +5365,7 @@ if (item == menu->defaultitem) break; i++; } - if (!XGetGeometry (dpy, menu->w, &root, &x, &y, &w, &h, &bw, &d)) return 0; + if (!XGetGeometry (dpy, menu->w, &root, &x, &y, &w, &h, &bw, &d)) return; xl = x + (menu->width / 2); yt = y + (i + 0.5) * Scr->EntryHeight; Index: menus.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/menus.h,v retrieving revision 1.1.1.7 retrieving revision 1.8 diff -u -r1.1.1.7 -r1.8 --- menus.h 2 Apr 2005 23:00:29 -0000 1.1.1.7 +++ menus.h 3 Apr 2005 16:35:58 -0000 1.8 @@ -64,6 +64,8 @@ #ifndef _MENUS_ #define _MENUS_ +#include "typedefs.h" + #define TWM_ROOT "bLoB_GoOp" /* my private root menu */ #define TWM_WINDOWS "TwmWindows" /* for f.menu "TwmWindows" */ #define TWM_ICONS "TwmIcons" /* for f.menu "TwmIcons" */ @@ -80,12 +82,12 @@ #define MAX_FILE_SIZE 4096 /* max chars to read from file for cut */ -typedef struct MenuItem +struct MenuItem { - struct MenuItem *next; /* next menu item */ - struct MenuItem *prev; /* prev menu item */ - struct MenuRoot *sub; /* MenuRoot of a pull right menu */ - struct MenuRoot *root; /* back pointer to my MenuRoot */ + MenuItem *next; /* next menu item */ + MenuItem *prev; /* prev menu item */ + MenuRoot *sub; /* MenuRoot of a pull right menu */ + MenuRoot *root; /* back pointer to my MenuRoot */ char *item; /* the character string displayed */ char *action; /* action to be performed */ ColorPair normal; /* unhiglight colors */ @@ -97,16 +99,16 @@ short strlen; /* strlen(item) */ short user_colors; /* colors were specified */ short separated; /* separated from the next item */ -} MenuItem; +}; -typedef struct MenuRoot +struct MenuRoot { - struct MenuItem *first; /* first item in menu */ - struct MenuItem *last; /* last item in menu */ - struct MenuItem *lastactive; /* last active item in menu */ - struct MenuItem *defaultitem; /* default item in menu */ - struct MenuRoot *prev; /* previous root menu if pull right */ - struct MenuRoot *next; /* next in list of root menus */ + MenuItem *first; /* first item in menu */ + MenuItem *last; /* last item in menu */ + MenuItem *lastactive; /* last active item in menu */ + MenuItem *defaultitem; /* default item in menu */ + MenuRoot *prev; /* previous root menu if pull right */ + MenuRoot *next; /* next in list of root menus */ char *name; /* name of root */ Window w; /* the window of the menu */ Window shadow; /* the shadow window */ @@ -120,36 +122,36 @@ short real_menu; /* this is a real menu */ short x, y; /* position (for pinned menus) */ short pinned; /* is this a pinned menu*/ - struct MenuRoot *pmenu; /* the associated pinned menu */ -} MenuRoot; + MenuRoot *pmenu; /* the associated pinned menu */ +}; #define NEVER_MAPPED 0 /* constants for mapped field of MenuRoot */ #define UNMAPPED 1 #define MAPPED 2 -typedef struct MouseButton +struct MouseButton { int func; /* the function number */ int mask; /* modifier mask */ MenuRoot *menu; /* menu if func is F_MENU */ MenuItem *item; /* action to perform if func != F_MENU */ -} MouseButton; +}; -typedef struct FuncButton +struct FuncButton { - struct FuncButton *next; /* next in the list of function buttons */ + FuncButton *next; /* next in the list of function buttons */ int num; /* button number */ int cont; /* context */ int mods; /* modifiers */ int func; /* the function number */ MenuRoot *menu; /* menu if func is F_MENU */ MenuItem *item; /* action to perform if func != F_MENU */ -} FuncButton; +}; -typedef struct FuncKey +struct FuncKey { - struct FuncKey *next; /* next in the list of function keys */ + FuncKey *next; /* next in the list of function keys */ char *name; /* key name */ KeySym keysym; /* X keysym */ KeyCode keycode; /* X keycode */ @@ -159,7 +161,7 @@ char *win_name; /* window name (if any) */ char *action; /* action string (if any) */ MenuRoot *menu; /* menu if func is F_MENU */ -} FuncKey; +}; extern int RootFunction; extern MenuRoot *ActiveMenu; @@ -175,6 +177,11 @@ extern int ConstMoveYT; extern int ConstMoveYB; +extern int menuFromFrameOrWindowOrTitlebar; +extern char *CurrentSelectedWorkspace; +extern Bool AlternateContext; +extern int AlternateKeymap; + #define MAXMENUDEPTH 10 /* max number of nested menus */ extern int MenuDepth; @@ -190,67 +197,52 @@ #define COLORMAP_PREV "prev" #define COLORMAP_DEFAULT "default" -extern void InitTitlebarButtons(); -extern void InitMenus(); -extern MenuRoot *NewMenuRoot(); -extern MenuItem *AddToMenu(); -extern Bool PopUpMenu(); -extern void MakeWorkspacesMenu (); -extern MenuRoot *FindMenuRoot(); -extern Bool AddFuncKey(); -extern Bool AddFuncButton(); -extern int DestroyMenu (); -extern int PopDownMenu(); -extern int HideMenu(); -extern int ExecuteFunction(); -extern int DeferExecution(); -extern int NeedToDefer(); -extern int ReGrab(); -extern int CreateTitleButton(); -extern int PaintEntry(); -extern int Paint3DEntry(); -extern int PaintNormalEntry(); -extern int PaintMenu(); -extern int UpdateMenu(); -extern int MakeMenus(); -extern int MakeMenu(); -extern int MoveMenu(); -extern int DeIconify(); -extern int Iconify(); -extern int WarpToScreen(); -extern int BumpWindowColormap(); -extern int SetMapStateProp(); -extern int SendDeleteWindowMessage (); -extern int SendSaveYourselfMessage (); -extern int SendTakeFocusMessage (); -extern int FindConstraint (); -extern MosaicFade (); -extern WarpCursorToDefaultEntry (); -extern Bool GetWMState(); -extern void PlaceTransients(); -extern void MakeWorkspacesMenu (); -extern void ModifyCurrentTB(); -extern void Execute(); -extern void ShowIconManager (); -extern void HideIconManager (); -extern void RaiseWindow(); -extern void LowerWindow(); -extern void RaiseLower(); -extern void RaiseLowerFrame(); -extern void MapRaised(); -extern void RaiseFrame(); -extern void FocusOnRoot(); -extern void TryToPack (); -extern void TryToPush (); -extern void TryToGrid (); -extern void resizeFromCenter(); -extern void WarpAlongRing (); -extern void WarpToWindow (); -extern void DisplayPosition (); -extern void packwindow (); -extern void fillwindow (); -extern Boolean TryNotToMoveOff (); -extern void AutoSqueeze (); -extern void Squeeze(); +extern int ResizeOrigX; +extern int ResizeOrigY; + +int CreateTitleButton (char *name, int func, char *action, MenuRoot *menuroot, + Bool rightside, Bool append); + +Bool AddFuncKey (char *name, int cont, int mods, int func, MenuRoot *menu, + char *win_name, char *action); + +Bool AddFuncButton (int num, int cont, int mods, int func, + MenuRoot *menu, MenuItem *item); + +MenuItem *AddToMenu(MenuRoot *menu, char *item, char *action, MenuRoot *sub, + int func, char *fore, char *back); + +int ExecuteFunction (int func, char *action, Window w, TwmWindow *tmp_win, + XEvent *eventp, int context, int pulldown); + +void DisplayPosition (TwmWindow *tmp_win, int x, int y); +void ModifyCurrentTB(int button, int func, char *action, MenuRoot *menuroot); +MenuRoot *FindMenuRoot(char *name); +MenuRoot *NewMenuRoot(char *name); +void TryToGrid (TwmWindow *tmp_win, int *x, int *y); +void TryToPack (TwmWindow *tmp_win, int *x, int *y); +void ReGrab (void); +void InitMenus (void); +void MakeMenus (void); +void InitTitlebarButtons (void); +void MakeWorkspacesMenu (void); +void SetMapStateProp(TwmWindow *tmp_win, int state); +void Squeeze (TwmWindow *tmp_win); +Bool PopUpMenu (MenuRoot *menu, int x, int y, Bool center); +void PaintMenu (MenuRoot *mr, XEvent *e); +void MoveMenu (XEvent *eventp); +void SendEndAnimationMessage (Window w, Time timestamp); +void WarpCursorToDefaultEntry (MenuRoot *menu); +void TryToPush (TwmWindow *tmp_win, int x, int y, int dir); +void WarpToWindow (TwmWindow *t); +void SendTakeFocusMessage (TwmWindow *tmp, Time timestamp); +void Iconify (TwmWindow *tmp_win, int def_x, int def_y); +void DeIconify (TwmWindow *tmp_win); +void FocusOnRoot (void); +void HideMenu (MenuRoot *menu); +void PopDownMenu (void); +void PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure); +void AutoSqueeze (TwmWindow *tmp_win); +void UpdateMenu (void); #endif /* _MENUS_ */ Index: otp.c =================================================================== RCS file: otp.c diff -N otp.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ otp.c 3 Apr 2005 16:35:58 -0000 1.8 @@ -0,0 +1,863 @@ +/* + * [ ctwm ] + * + * Copyright 1992, 2005 Stefan Monnier. + * + * Permission to use, copy, modify and distribute this software [ctwm] and + * its documentation for any purpose is hereby granted without fee, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting documen- + * tation, and that the name of Stefan Monnier not be used in adverti- + * sing or publicity pertaining to distribution of the software without + * specific, written prior permission. Stefan Monnier make no represen- + * tations about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * Stefan Monnier DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL Stefan Monnier BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: Stefan Monnier [ monnier@lia.di.epfl.ch ] + * + * $Id: otp.c,v 1.7 1998/03/11 04:32:41 monnier Exp $ + * + * handles all the OnTopPriority-related issues. + * + */ + +#include +#include +#include "otp.h" +#include "twm.h" +#include "screen.h" +#include "util.h" +#include "icons.h" +#include "list.h" + +/* number of priorities known to ctwm: [0..ONTOP_MAX] */ +#define OTP_ZERO 8 +#define OTP_MAX OTP_ZERO * 2 + +struct OtpWinList { + OtpWinList *above; + OtpWinList *below; + TwmWindow *twm_win; + WinType type; + Bool switching; + int priority; +}; + +struct OtpPreferences { + name_list *priorityL[OTP_MAX + 1]; + int priority; + name_list *switchingL; + Bool switching; +}; + +typedef struct Box { + int x; + int y; + int width; + int height; +} Box; + +static OtpWinList *bottomOwl = NULL; + +static Box BoxOfOwl (OtpWinList *owl) +{ + Box b; + + switch (owl->type) { + case IconWin: + { + Icon *icon = owl->twm_win->icon; + + b.x = icon->w_x; + b.y = icon->w_y; + b.width = icon->w_width; + b.height = icon->w_height; + break; + } + case WinWin: + { + TwmWindow *twm_win = owl->twm_win; + + b.x = twm_win->frame_x; + b.y = twm_win->frame_y; + b.width = twm_win->frame_width; + b.height = twm_win->frame_height; + break; + } + default: + assert(False); + } + return b; +} + + +static Bool BoxesIntersect (Box *b1, Box *b2) +{ + Bool interX = (b1->x + b1->width > b2->x) && (b2->x + b2->width > b1->x); + Bool interY = (b1->y + b1->height > b2->y) && (b2->y + b2->height > b1->y); + + return (interX && interY); +} + + +static Bool isIntersectingWith (OtpWinList *owl1, OtpWinList *owl2) +{ + Box b1 = BoxOfOwl(owl1); + Box b2 = BoxOfOwl(owl2); + + return BoxesIntersect(&b1, &b2); +} + + +static Bool isOnScreen (OtpWinList *owl) +{ + TwmWindow *twm_win = owl->twm_win; + + return (((owl->type == IconWin) ? twm_win->iconified : twm_win->mapped) + && OCCUPY(twm_win, Scr->currentvs->wsw->currentwspc)); +} + + +Bool isTransientOf (TwmWindow *trans, TwmWindow *main) +{ + return (trans->transient && trans->transientfor == main->w); +} + +Bool isGroupLeader (TwmWindow *twm_win) +{ + return ((twm_win->group == 0) + || (twm_win->group == twm_win->w)); +} + +Bool isGroupLeaderOf (TwmWindow *leader, TwmWindow *twm_win) +{ + return (isGroupLeader(leader) + && !isGroupLeader(twm_win) + && (leader->group == twm_win->group)); +} + +Bool isSmallTransientOf (TwmWindow *trans, TwmWindow *main) +{ + int trans_area, main_area; + + if (isTransientOf(trans, main)) { + assert(trans->frame); + trans_area = trans->frame_width * trans->frame_height; + main_area = main->frame_width * main->frame_height; + + return (trans_area < ((main_area * Scr->TransientOnTop) / 100)); + } else { + return False; + } +} + +static Window WindowOfOwl(OtpWinList *owl) +{ + return (owl->type == IconWin) + ? owl->twm_win->icon->w : owl->twm_win->frame; +} + +Bool OtpCheckConsistency () +{ + OtpWinList *owl; + TwmWindow *twm_win; + Window root, parent, *children; + unsigned int nchildren; + int priority = 0; + int stack = -1; + int nwins = 0; + int i; + + XQueryTree(dpy, Scr->Root, &root, &parent, &children, &nchildren); + + for (owl = bottomOwl; owl != NULL; owl = owl->above) { + twm_win = owl->twm_win; + + /* check the back arrows are correct */ + assert(((owl->type == IconWin) && (owl == twm_win->icon->otp)) + || ((owl->type == WinWin) && (owl == twm_win->otp))); + + /* check the doubly linked list's consistency */ + if (owl->below == NULL) { + assert(owl == bottomOwl); + } else { + assert(owl->below->above == owl); + } + + /* check the ordering of the priority */ + assert(owl->priority <= OTP_MAX); + assert(owl->priority >= priority); + priority = owl->priority; + + /* check the window's existence. */ + for (i = 0; i < nchildren && WindowOfOwl(owl) != children[i]; i++); + assert (i < nchildren); + assert (i > stack); + + /* check against the Xserver's stack */ + do { + stack++; + assert(stack < nchildren); + } while (WindowOfOwl(owl) != children[stack]); + + /* count the number of twm windows */ + if (owl->type == WinWin) nwins++; + } + + XFree(children); + + /* by decrementing nwins, check that all the wins are in our list */ + for (twm_win = Scr->TwmRoot.next; twm_win != NULL; twm_win = twm_win->next){ + nwins--; + } + /* if we just removed a win, it might still be somewhere, hence the -1 */ + assert((nwins <= 0) && (nwins >= -1)); + + return True; +} + + +static void RemoveOwl (OtpWinList *owl) +{ + if (owl->above != NULL) { + owl->above->below = owl->below; + } + if (owl->below != NULL) { + owl->below->above = owl->above; + } else { + bottomOwl = owl->above; + } + owl->below = NULL; + owl->above = NULL; +} + + +static void InsertOwlAbove (OtpWinList *owl, OtpWinList *other_owl) +{ + XWindowChanges xwc; + int xwcm; + + assert(owl->above == NULL); + assert(owl->below == NULL); + + if (other_owl == NULL) { + /* special case for the top-lowest window */ + assert(owl->priority <= bottomOwl->priority); + + /* pass the action to the Xserver */ + XLowerWindow(dpy, WindowOfOwl(owl)); + + /* update the list */ + owl->above = bottomOwl; + owl->above->below = owl; + bottomOwl = owl; + + } else { + /* general case */ + assert(owl->priority >= other_owl->priority); + if (other_owl->above != NULL) + assert(owl->priority <= other_owl->above->priority); + + /* pass the action to the Xserver */ + xwcm = CWStackMode | CWSibling; + xwc.sibling = WindowOfOwl(other_owl); + xwc.stack_mode = Above; + XConfigureWindow(dpy, WindowOfOwl(owl), xwcm, &xwc); + + /* update the list */ + owl->below = other_owl; + owl->above = other_owl->above; + owl->below->above = owl; + if (owl->above != NULL) owl->above->below = owl; + } +} + + +/* should owl stay above other_owl if other_owl was raised ? */ +static Bool shouldStayAbove (OtpWinList *owl, OtpWinList *other_owl) +{ + return ((owl->type == WinWin) + && (other_owl->type == WinWin) + && isSmallTransientOf(owl->twm_win, other_owl->twm_win)); +} + + +static void RaiseSmallTransientsOfAbove (OtpWinList *owl, OtpWinList *other_owl) +{ + OtpWinList *trans_owl, *tmp_owl; + + /* the icons have no transients and we can't have windows below NULL */ + if ((owl->type != WinWin) || other_owl == NULL) return; + + /* beware: we modify the list as we scan it. This is the reason for tmp */ + for (trans_owl = other_owl->below; trans_owl != NULL; trans_owl = tmp_owl) { + tmp_owl = trans_owl->below; + if (shouldStayAbove(trans_owl, owl)) { + RemoveOwl(trans_owl); + trans_owl->priority = owl->priority; + InsertOwlAbove(trans_owl, other_owl); + } + } +} + + +static OtpWinList *OwlRightBelow (int priority) +{ + OtpWinList *owl1, *owl2; + + /* in case there isn't anything below */ + if (priority <= bottomOwl->priority) return NULL; + + for (owl1 = bottomOwl, owl2 = owl1->above; + (owl2 != NULL) && (owl2->priority < priority); + owl1 = owl2, owl2 = owl2->above); + + assert(owl2 == owl1->above); + assert(owl1->priority < priority); + assert((owl2 == NULL) || (owl2->priority >= priority)); + + return owl1; +} + +static void InsertOwl (OtpWinList *owl, int where) +{ + OtpWinList *other_owl; + int priority; + + assert(owl->above == NULL); + assert(owl->below == NULL); + assert((where == Above) || (where == Below)); + + priority = (where == Above) ? owl->priority : owl->priority - 1; + + if (bottomOwl == NULL) { + /* for the first window: just insert it in the list */ + bottomOwl = owl; + } else { + other_owl = OwlRightBelow(priority + 1); + + /* make sure other_owl is not one of the transients */ + while ((other_owl != NULL) + && shouldStayAbove(other_owl, owl)) { + other_owl->priority = owl->priority; + other_owl = other_owl->below; + } + + /* raise the transient windows that should stay on top */ + RaiseSmallTransientsOfAbove(owl, other_owl); + + /* now go ahead and put the window where it should go */ + InsertOwlAbove(owl, other_owl); + } +} + + +static void SetOwlPriority (OtpWinList *owl, int new_pri) +{ + int old_pri; + + /* make sure the values are within bounds */ + if (new_pri < 0) new_pri = 0; + if (new_pri > OTP_MAX) new_pri = OTP_MAX; + + old_pri = owl->priority; + + RemoveOwl(owl); + owl->priority = new_pri; + InsertOwl(owl, (new_pri < old_pri) ? Below : Above); + + assert(owl->priority == new_pri); +} + + +static void TryToMoveTransientsOfTo (OtpWinList *owl, int priority) +{ + OtpWinList *other_owl, *tmp_owl; + + /* the icons have no transients */ + if (owl->type != WinWin) return; + + other_owl = OwlRightBelow(owl->priority); + other_owl = (other_owl == NULL) ? bottomOwl : other_owl->above; + assert(other_owl->priority >= owl->priority); + + /* !beware! we're changing the list as we scan it, hence the tmp_owl */ + while ((other_owl != NULL) && (other_owl->priority == owl->priority)) { + tmp_owl = other_owl->above; + if ((other_owl->type == WinWin) + && isTransientOf(other_owl->twm_win, owl->twm_win)) { + SetOwlPriority(other_owl, priority); + } + other_owl = tmp_owl; + } +} + +static void TryToSwitch (OtpWinList *owl, int where) +{ + int priority; + + if (!owl->switching) return; + + priority = OTP_MAX - owl->priority; + if (((where == Above) && (priority > owl->priority)) || + ((where == Below) && (priority < owl->priority))) { + TryToMoveTransientsOfTo(owl, priority); + owl->priority = priority; + } +} + +static void RaiseOwl (OtpWinList *owl) +{ + TryToSwitch(owl, Above); + RemoveOwl(owl); + InsertOwl(owl, Above); +} + + +static void LowerOwl (OtpWinList *owl) +{ + TryToSwitch(owl, Below); + RemoveOwl(owl); + InsertOwl(owl, Below); +} + +static Bool isHiddenBy (OtpWinList *owl, OtpWinList *other_owl) +{ + /* doesn't check that owl is on screen */ + return (isOnScreen(other_owl) + && isIntersectingWith(owl, other_owl)); +} + +static void TinyRaiseOwl (OtpWinList *owl) +{ + OtpWinList *other_owl = owl->above; + + while ((other_owl != NULL) && (other_owl->priority == owl->priority)) { + if (isHiddenBy(owl, other_owl) + && !shouldStayAbove(other_owl, owl)) { + RemoveOwl(owl); + RaiseSmallTransientsOfAbove(owl, other_owl); + InsertOwlAbove(owl, other_owl); + return; + } else { + other_owl = other_owl->above; + } + } +} + +static void TinyLowerOwl (OtpWinList *owl) +{ + OtpWinList *other_owl = owl->below; + + while ((other_owl != NULL) && (other_owl->priority == owl->priority)) { + if (isHiddenBy(owl, other_owl)) { + RemoveOwl(owl); + InsertOwlAbove(owl, other_owl->below); + return; + } else { + other_owl = other_owl->below; + } + } +} + +static void RaiseLowerOwl (OtpWinList *owl) +{ + OtpWinList *other_owl; + int priority; + + priority = MAX(owl->priority, OTP_MAX - owl->priority); + + for (other_owl = owl->above; + (other_owl != NULL) && (other_owl->priority <= priority); + other_owl = other_owl->above) { + if (isHiddenBy(owl, other_owl) + && !shouldStayAbove(other_owl, owl)) { + RaiseOwl(owl); + return; + } + } + LowerOwl(owl); +} + + +void OtpRaise (TwmWindow *twm_win, WinType wintype) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + assert(owl != NULL); + + RaiseOwl(owl); + + assert(OtpCheckConsistency()); +} + + +void OtpLower (TwmWindow *twm_win, WinType wintype) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + assert(owl != NULL); + + LowerOwl(owl); + + assert(OtpCheckConsistency()); +} + + +void OtpRaiseLower (TwmWindow *twm_win, WinType wintype) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + assert(owl != NULL); + + RaiseLowerOwl(owl); + + assert(OtpCheckConsistency()); +} + + +void OtpTinyRaise (TwmWindow *twm_win, WinType wintype) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + assert(owl != NULL); + + TinyRaiseOwl(owl); + + assert(OtpCheckConsistency()); +} + + +void OtpTinyLower (TwmWindow *twm_win, WinType wintype) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + assert(owl != NULL); + + TinyLowerOwl(owl); + + assert(OtpCheckConsistency()); +} + + +void OtpSetPriority (TwmWindow *twm_win, WinType wintype, int new_pri) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + int priority = OTP_ZERO + new_pri; + + assert(owl != NULL); + + if (ABS(new_pri) > OTP_ZERO) { + fprintf(stderr, "invalid OnTopPriority value: %d\n", new_pri); + } else { + TryToMoveTransientsOfTo(owl, priority); + SetOwlPriority (owl, priority); + } + + assert(OtpCheckConsistency()); +} + + +void OtpChangePriority (TwmWindow *twm_win, WinType wintype, int relpriority) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + int priority = owl->priority + relpriority; + + TryToMoveTransientsOfTo(owl, priority); + SetOwlPriority(owl, priority); + + assert(OtpCheckConsistency()); +} + + +void OtpSwitchPriority (TwmWindow *twm_win, WinType wintype) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + int priority = OTP_MAX - owl->priority; + + assert(owl != NULL); + + TryToMoveTransientsOfTo(owl, priority); + SetOwlPriority(owl, priority); + + assert(OtpCheckConsistency()); +} + + +void OtpToggleSwitching (TwmWindow *twm_win, WinType wintype) +{ + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + assert(owl != NULL); + + owl->switching = !owl->switching; + + assert(OtpCheckConsistency()); +} + + +void OtpForcePlacement (TwmWindow *twm_win, int where, TwmWindow *other_win) +{ + OtpWinList *owl = twm_win->otp; + OtpWinList *other_owl = other_win->otp; + + assert(twm_win->otp != NULL); + assert(other_win->otp != NULL); + + if (where == BottomIf) where = Below; + if (where != Below) where = Above; + + /* remove the owl to change it */ + RemoveOwl(owl); + + /* set the priority to keep the state consistent */ + owl->priority = other_owl->priority; + + /* put the owl back into the list */ + if (where == Below) other_owl = other_owl->below; + InsertOwlAbove(owl, other_owl); + + assert(OtpCheckConsistency()); +} + + +static void ApplyPreferences (OtpPreferences *prefs, OtpWinList *owl) +{ + int i; + TwmWindow *twm_win = owl->twm_win; + + /* check PrioritySwitch */ + if (LookInList(prefs->switchingL, twm_win->full_name, &twm_win->class)) { + owl->switching = !prefs->switching; + } + + /* check OnTopPriority */ + for (i = 0; i <= OTP_MAX; i++) { + if (LookInList(prefs->priorityL[i], + twm_win->full_name, &twm_win->class)) { + owl->priority = i; + } + } +} + +static void RecomputeOwlValues (OtpPreferences *prefs, OtpWinList *owl) +{ + int old_pri; + + old_pri = owl->priority; + ApplyPreferences(prefs, owl); + if (old_pri != owl->priority) { + RemoveOwl(owl); + InsertOwl(owl, Above); + } +} + +void OtpRecomputeValues (TwmWindow *twm_win) +{ + assert(twm_win->otp != NULL); + + RecomputeOwlValues(Scr->OTP, twm_win->otp); + if (twm_win->icon != NULL) + RecomputeOwlValues(Scr->IconOTP, twm_win->icon->otp); + + assert(OtpCheckConsistency()); +} + + +static void free_OtpWinList (OtpWinList *owl) +{ + assert(owl->above == NULL); + assert(owl->below == NULL); + free(owl); +} + + +void OtpRemove (TwmWindow *twm_win, WinType wintype) +{ + OtpWinList **owlp; + owlp = (wintype == IconWin) ? &twm_win->icon->otp : &twm_win->otp; + + assert(*owlp != NULL); + + RemoveOwl(*owlp); + free_OtpWinList(*owlp); + *owlp = NULL; + + assert(OtpCheckConsistency()); +} + + +static OtpWinList *new_OtpWinList (TwmWindow *twm_win, + WinType wintype, + Bool switching, + int priority) +{ + OtpWinList *owl = (OtpWinList*)malloc(sizeof(OtpWinList)); + + owl->above = NULL; + owl->below = NULL; + owl->twm_win = twm_win; + owl->type = wintype; + owl->switching = switching; + owl->priority = priority; + + return owl; +} + +static OtpWinList *AddNewOwl (TwmWindow *twm_win, WinType wintype, OtpWinList *parent) +{ + OtpWinList *owl; + OtpPreferences *prefs = (wintype == IconWin) ? Scr->IconOTP : Scr->OTP; + + /* make the new owl */ + owl = new_OtpWinList(twm_win, wintype, + prefs->switching, prefs->priority); + + /* inherit the default attributes from the parent window if appropriate */ + if (parent != NULL) { + owl->priority = parent->priority; + owl->switching = parent->switching; + } + + /* now see if the preferences have something to say */ + if (! (parent != NULL && twm_win->transient)) { + ApplyPreferences(prefs, owl); + } + + /* finally put the window where it should go */ + InsertOwl(owl, Above); + + return owl; +} + +void OtpAdd (TwmWindow *twm_win, WinType wintype) +{ + TwmWindow *other_win; + OtpWinList *parent = NULL; + OtpWinList **owlp; + owlp = (wintype == IconWin) ? &twm_win->icon->otp : &twm_win->otp; + + assert(*owlp == NULL); + + /* in case it's a transient, find the parent */ + if (wintype == WinWin && (twm_win->transient || !isGroupLeader(twm_win))) { + other_win = Scr->TwmRoot.next; + while (other_win != NULL + && !isTransientOf(twm_win, other_win) + && !isGroupLeaderOf(other_win, twm_win)) + other_win = other_win->next; + if (other_win != NULL) + parent = other_win->otp; + } + + /* make the new owl */ + *owlp = AddNewOwl(twm_win, wintype, parent); + + assert(*owlp != NULL); + assert(OtpCheckConsistency()); +} + + +name_list **OtpScrSwitchingL (ScreenInfo *Scr, WinType wintype) +{ + OtpPreferences *prefs = (wintype == IconWin) ? Scr->IconOTP : Scr->OTP; + + assert(prefs != NULL); + + return &(prefs->switchingL); +} + + +void OtpScrSetSwitching (ScreenInfo *Scr, WinType wintype, Bool switching) +{ + OtpPreferences *prefs = (wintype == IconWin) ? Scr->IconOTP : Scr->OTP; + + assert(prefs != NULL); + + Scr->OTP->switching = switching; +} + + +void OtpScrSetZero (ScreenInfo *Scr, WinType wintype, int priority) +{ + OtpPreferences *prefs = (wintype == IconWin) ? Scr->IconOTP : Scr->OTP; + + assert(prefs != NULL); + + if (ABS(priority) > OTP_ZERO) { + fprintf(stderr, "invalid OnTopPriority value: %d\n", priority); + return; + } + + prefs->priority = priority + OTP_ZERO; +} + + +name_list **OtpScrPriorityL (ScreenInfo *Scr, WinType wintype, int priority) +{ + OtpPreferences *prefs = (wintype == IconWin) ? Scr->IconOTP : Scr->OTP; + + assert(prefs != NULL); + + if (ABS(priority) > OTP_ZERO) { + fprintf(stderr, "invalid OnTopPriority value: %d\n", priority); + priority = 0; + } + return &(prefs->priorityL[priority + OTP_ZERO]); +} + + +static OtpPreferences *new_OtpPreferences (void) +{ + OtpPreferences *pref = (OtpPreferences*)malloc(sizeof(OtpPreferences)); + int i; + + /* initialize default values */ + for (i = 0; i <= OTP_MAX; i++) + pref->priorityL[i] = NULL; + pref->priority = OTP_ZERO; + pref->switchingL = NULL; + pref->switching = False; + + return pref; +} + +static void free_OtpPreferences (OtpPreferences *pref) +{ + int i; + + FreeList(&pref->switchingL); + for (i = 0; i <= OTP_MAX; i++) + FreeList(&pref->priorityL[i]); + + free(pref); +} + +void OtpScrInitData (ScreenInfo *Scr) +{ + if (Scr->OTP != NULL) + free_OtpPreferences(Scr->OTP); + if (Scr->IconOTP != NULL) + free_OtpPreferences(Scr->IconOTP); + Scr->OTP = new_OtpPreferences(); + Scr->IconOTP = new_OtpPreferences(); +} + +int ReparentWindow(Display *display, TwmWindow *twm_win, WinType wintype, + Window parent, int x, int y) +{ + int result; + OtpWinList *owl = (wintype == IconWin) ? twm_win->icon->otp : twm_win->otp; + assert(owl != NULL); + + result = XReparentWindow(display, WindowOfOwl(owl), parent, x, y); + /* The raise was already done by XReparentWindow, so this call + just re-places the window at the right spot in the list + and enforces priority settings. */ + RemoveOwl(owl); + InsertOwl(owl, Above); + assert(OtpCheckConsistency()); + return result; +} Index: otp.h =================================================================== RCS file: otp.h diff -N otp.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ otp.h 3 Apr 2005 16:35:58 -0000 1.6 @@ -0,0 +1,79 @@ +/* + * [ ctwm ] + * + * Copyright 1992, 2005 Stefan Monnier. + * + * Permission to use, copy, modify and distribute this software [ctwm] and + * its documentation for any purpose is hereby granted without fee, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting documen- + * tation, and that the name of Stefan Monnier not be used in adverti- + * sing or publicity pertaining to distribution of the software without + * specific, written prior permission. Stefan Monnier make no represen- + * tations about the suitability of this software for any purpose. It is + * provided "as is" without express or implied warranty. + * + * Stefan Monnier DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL Stefan Monnier BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: Stefan Monnier [ monnier@lia.di.epfl.ch ] + * + * $Id: otp.h,v 1.5 1996/05/14 09:36:19 monnier Exp $ + * + * handles all the OnTopPriority-related issues. + * + */ + +#ifndef _OTP_ +#define _OTP_ + +/* only needed to define Bool. Pathetic ! */ +#include + +#include "typedefs.h" + +/* kind of window */ +typedef enum WinType { WinWin, IconWin } WinType; + +/* Wrapper functions to maintain the internal list uptodate. */ +extern int ReparentWindow(Display *display, TwmWindow *twm_win, + WinType wintype, Window parent, int x, int y); + +/* misc functions that are not specific to OTP */ +extern Bool isTransientOf(TwmWindow*, TwmWindow*); +extern Bool isSmallTransientOf(TwmWindow*, TwmWindow*); +extern Bool isGroupLeaderOf(TwmWindow*, TwmWindow*); +extern Bool isGroupLeader(TwmWindow*); + +/* functions to "move" windows */ +extern void OtpRaise(TwmWindow*, WinType); +extern void OtpLower(TwmWindow*, WinType); +extern void OtpRaiseLower(TwmWindow*, WinType); +extern void OtpTinyRaise(TwmWindow*, WinType); +extern void OtpTinyLower(TwmWindow*, WinType); + +/* functions to change a window's OTP value */ +extern void OtpSetPriority(TwmWindow*, WinType, int); +extern void OtpChangePriority(TwmWindow*, WinType, int); +extern void OtpSwitchPriority(TwmWindow*, WinType); +extern void OtpToggleSwitching(TwmWindow*, WinType); +extern void OtpRecomputeValues(TwmWindow*); +extern void OtpForcePlacement(TwmWindow*, int, TwmWindow*); + +/* functions to manage the preferences. The second arg specifies icon prefs */ +extern void OtpScrInitData(ScreenInfo*); +extern name_list **OtpScrSwitchingL(ScreenInfo*, WinType); +extern name_list **OtpScrPriorityL(ScreenInfo*, WinType, int); +extern void OtpScrSetSwitching(ScreenInfo*, WinType, Bool); +extern void OtpScrSetZero(ScreenInfo*, WinType, int); + +/* functions to inform OTP-manager of window creation/destruction */ +extern void OtpAdd(TwmWindow*, WinType); +extern void OtpRemove(TwmWindow*, WinType); + +#endif /* _OTP_ */ Index: parse.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/parse.c,v retrieving revision 1.1.1.13 retrieving revision 1.13 diff -u -r1.1.1.13 -r1.13 --- parse.c 2 Apr 2005 23:00:29 -0000 1.1.1.13 +++ parse.c 3 Apr 2005 16:35:58 -0000 1.13 @@ -68,6 +68,7 @@ ***********************************************************************/ #include +#include #if defined(sony_news) || defined __QNX__ # include #endif @@ -78,14 +79,8 @@ #else #include #include +#include #endif -#include "twm.h" -#include "screen.h" -#include "menus.h" -#include "util.h" -#include "gram.h" -#include "parse.h" -#include "version.h" #ifdef VMS #include #else @@ -100,6 +95,16 @@ #include #endif +#include "twm.h" +#include "screen.h" +#include "menus.h" +#include "util.h" +#include "gram.h" +#include "parse.h" +#include "version.h" +#include "list.h" +#include "deftwmrc.h" + #if defined(ultrix) #define NOSTEMP #endif @@ -115,7 +120,7 @@ static int ParseRandomPlacement (); static int ParseButtonStyle (); -extern int yyparse(),twmrc_error_prefix(); +extern int yyparse(); static FILE *twmrc; static int ptr = 0; @@ -131,26 +136,23 @@ #endif extern int twmrc_lineno; -extern int mods; int ConstrainedMoveTime = 400; /* milliseconds, event times */ +int ParseError; /* error parsing the .twmrc file */ int RaiseDelay = 0; /* msec, for AutoRaise */ -static int twmFileInput(), twmStringListInput(); +static int twmStringListInput(); #ifdef USEM4 -static int m4twmFileInput (); +static int m4twmFileInput (void); +#else +static int twmFileInput(void); #endif void twmUnput(); int (*twmInputFunc)(); -extern char *defTwmrc[]; /* default bindings */ - -extern int captive; -extern char *captivename; - #ifdef SOUNDS -extern int set_sound_host(); +#include "sound.h" #endif /*********************************************************************** @@ -203,7 +205,6 @@ char tmpfilename[257]; #ifdef USEM4 static FILE *raw; - extern int GoThroughM4; #endif /* @@ -405,7 +406,7 @@ static int include_file = 0; -static int twmFileInput() +static int twmFileInput(void) { if (overflowlen) return (int) overflowbuff[--overflowlen]; @@ -461,7 +462,7 @@ /* If you're going to use m4, use this version instead. Much simpler. * m4 ism's credit to Josh Osborne (stripes) */ -static int m4twmFileInput() +static int m4twmFileInput(void) { int line; extern char *keepM4_filename; @@ -504,7 +505,7 @@ #endif /* USEM4 */ -static int twmStringListInput() +static int twmStringListInput(void) { if (overflowlen) return (int) overflowbuff[--overflowlen]; @@ -603,6 +604,7 @@ #define kw0_StartInMapState 28 #define kw0_NoShowOccupyAll 29 #define kw0_AutoOccupy 30 +#define kw0_AutoPriority 330 #define kw0_TransientHasOccupation 31 #define kw0_DontPaintRootWindow 32 #define kw0_Use3DMenus 33 @@ -736,6 +738,8 @@ { "autofocustotransients", KEYWORD, kw0_AutoFocusToTransients }, /* kai */ { "autolower", AUTO_LOWER, 0 }, { "autooccupy", KEYWORD, kw0_AutoOccupy }, + { "autopopup", AUTO_POPUP, 0 }, + { "autopriority", KEYWORD, kw0_AutoPriority }, { "autoraise", AUTO_RAISE, 0 }, { "autoraiseicons", KEYWORD, kw0_AutoRaiseIcons }, { "autorelativeresize", KEYWORD, kw0_AutoRelativeResize }, @@ -791,6 +795,7 @@ { "f.backmapiconmgr", FKEYWORD, F_BACKMAPICONMGR }, { "f.beep", FKEYWORD, F_BEEP }, { "f.bottomzoom", FKEYWORD, F_BOTTOMZOOM }, + { "f.changepriority", FSKEYWORD, F_CHANGEPRIORITY }, { "f.changesize", FSKEYWORD, F_CHANGESIZE }, { "f.circledown", FKEYWORD, F_CIRCLEDOWN }, { "f.circleup", FKEYWORD, F_CIRCLEUP }, @@ -852,10 +857,12 @@ { "f.pin", FKEYWORD, F_PIN }, { "f.previconmgr", FKEYWORD, F_PREVICONMGR }, { "f.prevworkspace", FKEYWORD, F_PREVWORKSPACE }, + { "f.priorityswitching", FKEYWORD, F_PRIORITYSWITCHING }, { "f.quit", FKEYWORD, F_QUIT }, { "f.raise", FKEYWORD, F_RAISE }, { "f.raiseicons", FKEYWORD, F_RAISEICONS }, { "f.raiselower", FKEYWORD, F_RAISELOWER }, + { "f.raiseorsqueeze", FKEYWORD, F_RAISEORSQUEEZE }, { "f.refresh", FKEYWORD, F_REFRESH }, { "f.removefromworkspace", FSKEYWORD, F_REMOVEFROMWORKSPACE }, #ifdef SOUNDS @@ -873,6 +880,7 @@ { "f.separator", FKEYWORD, F_SEPARATOR }, { "f.setbuttonsstate", FKEYWORD, F_SETBUTTONSTATE }, { "f.setmapstate", FKEYWORD, F_SETMAPSTATE }, + { "f.setpriority", FSKEYWORD, F_SETPRIORITY }, { "f.showbackground", FKEYWORD, F_SHOWBGRD }, { "f.showiconmgr", FKEYWORD, F_SHOWLIST }, { "f.showworkspacemgr", FKEYWORD, F_SHOWWORKMGR }, @@ -883,6 +891,9 @@ { "f.squeeze", FKEYWORD, F_SQUEEZE }, { "f.startanimation", FKEYWORD, F_STARTANIMATION }, { "f.stopanimation", FKEYWORD, F_STOPANIMATION }, + { "f.switchpriority", FKEYWORD, F_SWITCHPRIORITY }, + { "f.tinylower", FKEYWORD, F_TINYLOWER }, + { "f.tinyraise", FKEYWORD, F_TINYRAISE }, { "f.title", FKEYWORD, F_TITLE }, { "f.toggleoccupation", FSKEYWORD, F_TOGGLEOCCUPATION }, #ifdef SOUNDS @@ -894,6 +905,7 @@ { "f.trace", FSKEYWORD, F_TRACE }, { "f.twmrc", FKEYWORD, F_RESTART }, { "f.unfocus", FKEYWORD, F_UNFOCUS }, + { "f.unsqueeze", FKEYWORD, F_UNSQUEEZE }, { "f.upiconmgr", FKEYWORD, F_UPICONMGR }, { "f.upworkspace", FKEYWORD, F_UPWORKSPACE }, { "f.vanish", FKEYWORD, F_VANISH }, @@ -998,6 +1010,7 @@ { "nowarptomenutitle", KEYWORD, kw0_NoWarpToMenuTitle }, { "occupy", OCCUPYLIST, 0 }, { "occupyall", OCCUPYALL, 0 }, + { "ontoppriority", ON_TOP_PRIORITY, 0 }, { "opaquemove", OPAQUEMOVE, 0 }, { "opaquemovethreshold", NKEYWORD, kwn_OpaqueMoveThreshold }, { "opaqueresize", OPAQUERESIZE, 0 }, @@ -1006,6 +1019,8 @@ { "packnewwindows", KEYWORD, kw0_PackNewWindows }, { "pixmapdirectory", SKEYWORD, kws_PixmapDirectory }, { "pixmaps", PIXMAPS, 0 }, + { "prioritynotswitching", PRIORITY_NOT_SWITCHING, 0 }, + { "priorityswitching", PRIORITY_SWITCHING, 0 }, { "r", ROOT, 0 }, { "raisedelay", NKEYWORD, kwn_RaiseDelay }, { "raiseonclick", KEYWORD, kw0_RaiseOnClick }, @@ -1068,6 +1083,7 @@ { "w", WINDOW, 0 }, { "wait", WAITC, 0 }, { "warpcursor", WARP_CURSOR, 0 }, + { "warpondeiconify", WARPONDEICONIFY, 0 }, { "warpringonscreen", KEYWORD, kw0_WarpRingOnScreen }, { "warptodefaultmenuentry", KEYWORD, kw0_WarpToDefaultMenuEntry }, { "warpunmapped", KEYWORD, kw0_WarpUnmapped }, @@ -1226,6 +1242,10 @@ Scr->AutoOccupy = TRUE; return 1; + case kw0_AutoPriority: + Scr->AutoPriority = TRUE; + return 1; + case kw0_TransientHasOccupation: Scr->TransientHasOccupation = TRUE; return 1; @@ -1868,7 +1888,7 @@ /* * put_pixel_on_root() Save a pixel value in twm root window color property. */ -put_pixel_on_root(pixel) +static void put_pixel_on_root(pixel) Pixel pixel; { int i, addPixel = 1; @@ -2061,7 +2081,7 @@ return (-1); } -do_squeeze_entry (list, name, justify, num, denom) +int do_squeeze_entry (list, name, justify, num, denom) name_list **list; /* squeeze or dont-squeeze list */ char *name; /* window name */ int justify; /* left, center, right */ @@ -2125,8 +2145,6 @@ exit(23); } if (fres == 0) { - extern Display *dpy; - extern char *display_name; char *tmp_file; /* Child */ @@ -2207,7 +2225,6 @@ Display *display; char *host; { - extern int KeepTmpFile; Screen *screen; Visual *visual; char client[MAXHOSTNAME], server[MAXHOSTNAME], *colon; Index: parse.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/parse.h,v retrieving revision 1.1.1.9 retrieving revision 1.11 diff -u -r1.1.1.9 -r1.11 --- parse.h 2 Apr 2005 23:00:29 -0000 1.1.1.9 +++ parse.h 3 Apr 2005 16:35:58 -0000 1.11 @@ -64,10 +64,29 @@ #ifndef _PARSE_ #define _PARSE_ +#include "list.h" + extern int ParseTwmrc(), ParseStringList(); extern int (*twmInputFunc)(); extern void twmUnput(); extern void TwmOutput(); +extern void twmrc_error_prefix (void); +extern void assign_var_savecolor (void); +int do_single_keyword (int keyword); +int do_string_keyword (int keyword, char *s); +int do_number_keyword (int keyword, int num); +name_list **do_colorlist_keyword (int keyword, int colormode, char *s); +int do_color_keyword (int keyword, int colormode, char *s); +int do_string_savecolor(int colormode, char *s); +int do_var_savecolor(int key); +int do_squeeze_entry (name_list **l, char *n, int justify, int num, int denom); +int parse_keyword (char *s, int *nump); + +extern int ParseError; /* error parsing the .twmrc file */ +extern unsigned int mods_used; +extern int mods; +extern int ConstrainedMoveTime; +extern int RaiseDelay; #define F_NOP 0 #define F_BEEP 1 @@ -191,6 +210,15 @@ #define F_MOVETOPREVWORKSPACEANDFOLLOW 127 #define F_CHANGESIZE 128 /* string */ +#define F_SETPRIORITY 150 /* string (but should be number) */ +#define F_CHANGEPRIORITY 151 /* string (but should be number) */ +#define F_SWITCHPRIORITY 152 +#define F_PRIORITYSWITCHING 153 +#define F_TINYRAISE 154 +#define F_TINYLOWER 155 +#define F_UNSQUEEZE 156 +#define F_RAISEORSQUEEZE 157 + #define D_NORTH 1 #define D_SOUTH 2 #define D_EAST 3 Index: resize.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/resize.c,v retrieving revision 1.1.1.10 retrieving revision 1.11 diff -u -r1.1.1.10 -r1.11 --- resize.c 2 Apr 2005 23:00:29 -0000 1.1.1.10 +++ resize.c 3 Apr 2005 16:35:58 -0000 1.11 @@ -72,9 +72,11 @@ #include "parse.h" #include "events.h" #include "util.h" +#include "otp.h" #include "resize.h" #include "add_window.h" #include "screen.h" +#include "iconmgr.h" #define MINHEIGHT 0 /* had been 32 */ #define MINWIDTH 0 /* had been 60 */ @@ -101,8 +103,7 @@ static unsigned int resizeGrabMask; -extern Cursor TopRightCursor, TopLeftCursor, BottomRightCursor, BottomLeftCursor, - LeftCursor, RightCursor, TopCursor, BottomCursor; +static void DisplaySize (TwmWindow *tmp_win, int width, int height); static void do_auto_clamp (tmp_win, evp) TwmWindow *tmp_win; @@ -569,11 +570,7 @@ *********************************************************************** */ -void -DisplaySize(tmp_win, width, height) -TwmWindow *tmp_win; -int width; -int height; +static void DisplaySize (TwmWindow *tmp_win, int width, int height) { char str[100]; int dwidth; @@ -674,9 +671,10 @@ } if (!Scr->NoRaiseResize) { - RaiseWindow(tmp_win); + OtpRaise(tmp_win, WinWin); WMapRaise (tmp_win); } + UninstallRootColormap(); ResizeWindow = None; @@ -733,9 +731,7 @@ * ***********************************************************************/ -ConstrainSize (tmp_win, widthp, heightp) - TwmWindow *tmp_win; - int *widthp, *heightp; +void ConstrainSize (TwmWindow *tmp_win, int *widthp, int *heightp) { #define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) ) #define _min(a,b) (((a) < (b)) ? (a) : (b)) @@ -989,6 +985,7 @@ frame_mask = 0; if (bw != tmp_win->frame_bw) { frame_wc.border_width = tmp_win->frame_bw = bw; + if (bw == 0) tmp_win->frame_bw3D = 0; frame_mask |= CWBorderWidth; } tmp_win->frame_x = x; @@ -1219,7 +1216,7 @@ } if (!Scr->NoRaiseResize) - RaiseWindow(tmp_win); + OtpRaise(tmp_win, WinWin); ConstrainSize(tmp_win, &dragWidth, &dragHeight); #ifdef BETTERZOOM @@ -1271,8 +1268,7 @@ SetupWindow (tmp_win, x, y, w, h, -1); } -SetFrameShape (tmp) - TwmWindow *tmp; +void SetFrameShape (TwmWindow *tmp) { /* * see if the titlebar needs to move @@ -1350,9 +1346,7 @@ } } -ChangeSize (in_string, tmp_win) - char *in_string; - TwmWindow *tmp_win; +void ChangeSize (char *in_string, TwmWindow *tmp_win) { int i=0, j=0, change=0, size=0; char tmp_string[10]; Index: resize.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/resize.h,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -u -r1.1.1.3 -r1.2 --- resize.h 28 Oct 1997 21:12:26 -0000 1.1.1.3 +++ resize.h 11 Mar 1998 04:32:41 -0000 1.2 @@ -64,22 +64,37 @@ #ifndef _RESIZE_ #define _RESIZE_ -extern void MenuStartResize(); -extern void StartResize(); -extern void AddStartResize(); -extern void MenuDoResize(); -extern void DoResize(); -extern void DisplaySize(); -extern void EndResize(); -extern void MenuEndResize(); -extern void AddEndResize(); -extern void SetupWindow(); -extern void SetupFrame(); -extern ConstrainSize (); +/* extern void MenuStartResize(); */ +/* extern void StartResize(); */ +/* extern void AddStartResize(); */ +/* extern void MenuDoResize(); */ +/* extern void DoResize(); */ +/* extern void DisplaySize(); */ +/* extern void EndResize(); */ +/* extern void MenuEndResize(); */ +/* extern void AddEndResize(); */ +/* extern void SetupWindow(); */ +/* extern void SetupFrame(); */ + +/* extern void fullzoom(); */ +/* extern void savegeometry (); */ +/* extern void restoregeometry (); */ + +void SetFrameShape (TwmWindow *t); +void ConstrainSize (TwmWindow *t, int *widthp, int *heightp); +void AddStartResize (TwmWindow *t, int x, int y, int w, int h); +void AddEndResize (TwmWindow *t); +void DoResize (int x_root, int y_root, TwmWindow *t); +void SetupFrame (TwmWindow *t, int x, int y, int w, int h, int bw, Bool se); +void SetupWindow (TwmWindow *t, int x, int y, int w, int h, int bw); +void StartResize (XEvent *e, TwmWindow *t, Bool ftb, Bool f3db); +void EndResize (void); +void MenuStartResize (TwmWindow *t, int x, int y, int w, int h); +void MenuEndResize (TwmWindow *t); +void MenuDoResize (int x_root, int y_root, TwmWindow *t); +void fullzoom (TwmWindow *t, int flag); +void savegeometry (TwmWindow *t); +void restoregeometry (TwmWindow *t); -extern void fullzoom(); -extern void savegeometry (); -extern void restoregeometry (); -extern int SetFrameShape (); #endif /* _RESIZE_ */ Index: screen.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/screen.h,v retrieving revision 1.1.1.12 retrieving revision 1.11 diff -u -r1.1.1.12 -r1.11 --- screen.h 2 Apr 2005 23:00:29 -0000 1.1.1.12 +++ screen.h 3 Apr 2005 16:35:58 -0000 1.11 @@ -67,6 +67,9 @@ #include #endif +#include "typedefs.h" +#include "workmgr.h" + #ifdef GNOME # include "gnome.h" #endif /* GNOME */ @@ -82,25 +85,25 @@ #define ICONIFY_ZOOMOUT 3 #define ICONIFY_SWEEP 4 -typedef struct _StdCmap { - struct _StdCmap *next; /* next link in chain */ +struct StdCmap { + StdCmap *next; /* next link in chain */ Atom atom; /* property from which this came */ int nmaps; /* number of maps below */ XStandardColormap *maps; /* the actual maps */ -} StdCmap; +}; #define SIZE_HINDENT 10 #define SIZE_VINDENT 2 -typedef struct _TitlebarPixmaps { +struct TitlebarPixmaps { Pixmap xlogo; Pixmap resize; Pixmap question; Pixmap menu; Pixmap delete; -} TitlebarPixmaps; +}; -typedef struct ScreenInfo +struct ScreenInfo { int screen; /* the default screen */ int d_depth; /* copy of DefaultDepth(dpy, screen) */ @@ -251,6 +254,7 @@ short WMgrButtonShadowDepth; short BeNiceToColormap; short BorderCursors; + short AutoPopup; short BorderShadowDepth; short TitleButtonShadowDepth; short TitleShadowDepth; @@ -268,6 +272,9 @@ short AutoFocusToTransients; /* kai */ short PackNewWindows; + OtpPreferences *OTP; + OtpPreferences *IconOTP; + name_list *BorderColorL; name_list *IconBorderColorL; name_list *BorderTileForegroundL; @@ -279,16 +286,17 @@ name_list *IconManagerFL; name_list *IconManagerBL; name_list *IconMgrs; + name_list *AutoPopupL; /* list of window the popup when changed */ name_list *NoBorder; /* list of window without borders */ name_list *NoIconTitle; /* list of window names with no icon title */ name_list *NoTitle; /* list of window names with no title bar */ name_list *MakeTitle; /* list of window names with title bar */ name_list *AutoRaise; /* list of window names to auto-raise */ + name_list *WarpOnDeIconify; /* list of window names to warp on deiconify */ name_list *AutoLower; /* list of window names to auto-lower */ name_list *IconNames; /* list of window names and icon names */ name_list *NoHighlight; /* list of windows to not highlight */ name_list *NoStackModeL; /* windows to ignore stack mode requests */ - name_list *AlwaysOnTopL; /* windows to keep on top */ name_list *NoTitleHighlight;/* list of windows to not highlight the TB*/ name_list *DontIconify; /* don't iconify by unmapping */ name_list *IconMgrNoShow; /* don't show in the icon manager */ @@ -380,6 +388,7 @@ short ShowWorkspaceManager; /* display the workspace manager */ short IconManagerDontShow; /* show nothing in the icon manager */ short AutoOccupy; /* Do we automatically change occupation when name changes */ + short AutoPriority; /* Do we automatically change priority when name changes */ short TransientHasOccupation; /* Do transient-for windows have their own occupation */ short DontPaintRootWindow; /* don't paint anything on the root window */ short BackingStore; /* use backing store for menus */ @@ -387,10 +396,10 @@ short RandomPlacement; /* randomly place windows that no give hints */ short OpaqueMove; /* move the window rather than outline */ short DoOpaqueMove; /* move the window rather than outline */ - short OpaqueMoveThreshold; /* */ + unsigned short OpaqueMoveThreshold; /* */ short DoOpaqueResize; /* resize the window rather than outline */ short OpaqueResize; /* resize the window rather than outline */ - short OpaqueResizeThreshold; /* */ + unsigned short OpaqueResizeThreshold; /* */ short Highlight; /* should we highlight the window borders */ short StackMode; /* should we honor stack mode requests */ short TitleHighlight; /* should we highlight the titlebar */ @@ -430,7 +439,7 @@ #ifdef GNOME GnomeData *gnomedata; #endif /* GNOME */ -} ScreenInfo; +}; extern int MultiScreen; extern int NumScreens; @@ -448,7 +457,4 @@ #define RP_ALL 1 #define RP_UNMAPPED 2 -#define ONTOP_MAX 16 -#define ONTOP_DEFAULT 8 - #endif /* _SCREEN_ */ Index: session.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/session.c,v retrieving revision 1.1.1.3 retrieving revision 1.3 diff -u -r1.1.1.3 -r1.3 --- session.c 7 Oct 1999 17:32:41 -0000 1.1.1.3 +++ session.c 7 Oct 1999 19:09:10 -0000 1.3 @@ -99,6 +99,9 @@ * **********************************************************************/ +#include "session.h" +#include "list.h" + #include #ifdef X11R6 @@ -157,7 +160,6 @@ Atom actual_type; int actual_format; unsigned long nitems; - unsigned long nbytes; unsigned long bytes_after; unsigned char *prop = NULL; @@ -950,7 +952,6 @@ SmPropValue prop1val, prop2val, prop3val; char discardCommand[PATH_MAX + 4]; int numVals, i; - char yes = 1; static int first_time = 1; if (first_time) Index: session.h =================================================================== RCS file: session.h diff -N session.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ session.h 11 Mar 1998 04:32:42 -0000 1.2 @@ -0,0 +1,21 @@ +/* copyright 1998 Stefan Monnier */ + +#ifndef _SESSION_H_ +#define _SESSION_H_ + +#include "typedefs.h" +#include +#include + +extern SmcConn smcConn; + +int GetWindowConfig (TwmWindow *theWindow, short *x, short *y, + unsigned short *width, unsigned short *height, + Bool *iconified, Bool *icon_info_present, short *icon_x, + short *icon_y, Bool *width_ever_changed_by_user, + Bool *height_ever_changed_by_user, int *occupation); + +void ReadWinConfigFile (char *name); +void ConnectToSessionManager (char *previous_id); + +#endif Index: sound.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/sound.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- sound.c 6 Feb 1997 22:40:38 -0000 1.1.1.2 +++ sound.c 11 Mar 1998 04:32:42 -0000 1.2 @@ -169,12 +169,12 @@ rplay_perror ("create"); } -play_startup_sound() +void play_startup_sound (void) { play_sound(startup_sound); } -play_exit_sound() +void play_exit_sound (void) { play_sound(exit_sound); } @@ -182,7 +182,7 @@ /* * Toggle the sound on/off */ -toggle_sound () +void toggle_sound (void) { sound_state ^= 1; } @@ -191,7 +191,7 @@ /* * Re-read the sounds mapping file */ -reread_sounds () +void reread_sounds (void) { sound_init (); } @@ -199,8 +199,7 @@ /* * Set the SoundHost and force the sound_fd to be re-opened. */ -set_sound_host(host) -char *host; +void set_sound_host (char *host) { strcpy(hostname, host); if (sound_fd != 0) Index: sound.h =================================================================== RCS file: sound.h diff -N sound.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sound.h 11 Mar 1998 17:22:25 -0000 1.1 @@ -0,0 +1,10 @@ +#ifndef _SOUND_H_ +#define _SOUND_H_ + +void toggle_sound (void); +void reread_sounds (void); +void play_startup_sound (void); +void play_exit_sound (void); +void set_sound_host (char *host); + +#endif Index: twm.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/twm.h,v retrieving revision 1.1.1.8 retrieving revision 1.10 diff -u -r1.1.1.8 -r1.10 --- twm.h 2 Apr 2005 22:55:32 -0000 1.1.1.8 +++ twm.h 3 Apr 2005 16:35:58 -0000 1.10 @@ -87,8 +87,8 @@ # include #endif #endif -#include "list.h" -#include "util.h" + +#include "typedefs.h" #ifndef WithdrawnState #define WithdrawnState 0 @@ -189,7 +189,7 @@ #define MinSize(a, b) (((a) > (b)) ? (b) : (a)) #endif -typedef struct MyFont +struct MyFont { #ifdef I18N char *basename; /* name of the font */ @@ -202,43 +202,43 @@ #endif int height; /* height of the font */ int y; /* Y coordinate to draw characters */ -} MyFont; +}; -typedef struct ColorPair +struct ColorPair { Pixel fore, back, shadc, shadd; -} ColorPair; +}; typedef enum {on, off} ButtonState; -typedef struct _TitleButtonFunc { - int func; /* function to execute */ - char *action; /* optional action arg */ - struct MenuRoot *menuroot; /* menu to pop on F_MENU */ -} TitleButtonFunc; - -typedef struct _TitleButton { - struct _TitleButton *next; /* next link in chain */ - char *name; /* bitmap name in case of deferal */ - Image *image; /* image to display in button */ - int srcx, srcy; /* from where to start copying */ - unsigned int width, height; /* size of pixmap */ - int dstx, dsty; /* to where to start copying */ - Bool rightside; /* t: on right, f: on left */ - TitleButtonFunc funs[MAX_BUTTONS]; /* funcs assoc'd to each button */ -} TitleButton; - -typedef struct _TBWindow { - Window window; /* which window in this frame */ - Image *image; /* image to display in button */ - TitleButton *info; /* description of this window */ -} TBWindow; +struct TitleButtonFunc { + int func; /* function to execute */ + char *action; /* optional action arg */ + MenuRoot *menuroot; /* menu to pop on F_MENU */ +}; + +struct TitleButton { + TitleButton *next; /* next link in chain */ + char *name; /* bitmap name in case of deferal */ + Image *image; /* image to display in button */ + int srcx, srcy; /* from where to start copying */ + unsigned int width, height; /* size of pixmap */ + int dstx, dsty; /* to where to start copying */ + Bool rightside; /* t: on right, f: on left */ + TitleButtonFunc funs[MAX_BUTTONS]; /* funcs assoc'd to each button */ +}; + +struct TBWindow { + Window window; /* which window in this frame */ + Image *image; /* image to display in button */ + TitleButton *info; /* description of this window */ +}; -typedef struct _SqueezeInfo { +struct SqueezeInfo { int justify; /* left, center, right */ int num; /* signed pixel count or numerator */ int denom; /* 0 for pix count or denominator */ -} SqueezeInfo; +}; #define J_UNDEF 0 #define J_LEFT 1 @@ -251,51 +251,51 @@ /* Colormap window entry for each window in WM_COLORMAP_WINDOWS * ICCCM property. */ -typedef struct TwmColormap +struct TwmColormap { Colormap c; /* Colormap id */ int state; /* install(ability) state */ unsigned long install_req; /* request number which installed it */ Window w; /* window causing load of color table */ int refcnt; -} TwmColormap; +}; #define CM_INSTALLABLE 1 #define CM_INSTALLED 2 #define CM_INSTALL 4 -typedef struct ColormapWindow +struct ColormapWindow { Window w; /* Window id */ TwmColormap *colormap; /* Colormap for this window */ int visibility; /* Visibility of this window */ int refcnt; -} ColormapWindow; +}; -typedef struct Colormaps +struct Colormaps { ColormapWindow **cwins; /* current list of colormap windows */ int number_cwins; /* number of elements in current list */ char *scoreboard; /* conflicts between installable colortables */ -} Colormaps; +}; #define ColormapsScoreboardLength(cm) ((cm)->number_cwins * \ ((cm)->number_cwins - 1) / 2) -typedef struct WindowRegion { - struct WindowRegion *next; +struct WindowRegion { + WindowRegion *next; int x, y, w, h; int grav1, grav2; - name_list *clientlist; - struct WindowEntry *entries; -} WindowRegion; + name_list *clientlist; + WindowEntry *entries; +}; -typedef struct WindowEntry { - struct WindowEntry *next; +struct WindowEntry { + WindowEntry *next; int x, y, w, h; - struct TwmWindow *twm_win; + TwmWindow *twm_win; short used; -} WindowEntry; +}; typedef struct _WindowBox { struct _WindowBox *next; @@ -309,10 +309,11 @@ /* for each window that is on the display, one of these structures * is allocated and linked into a list */ -typedef struct TwmWindow +struct TwmWindow { - struct TwmWindow *next; /* next twm window */ - struct TwmWindow *prev; /* previous twm window */ + TwmWindow *next; /* next twm window */ + TwmWindow *prev; /* previous twm window */ + OtpWinList *otp; /* OnTopPriority info for the window */ Window w; /* the child window */ int old_bw; /* border width before reparenting */ Window frame; /* the frame window */ @@ -323,8 +324,8 @@ Window lolite_wr; /* the right lolite window */ Cursor curcurs; /* current resize cursor */ Pixmap gray; - struct Icon *icon; /* the curent icon */ - name_list *iconslist; /* the current list of icons */ + Icon *icon; /* the curent icon */ + name_list *iconslist; /* the current list of icons */ int frame_x; /* x position of frame */ int frame_y; /* y position of frame */ int frame_width; /* width of frame */ @@ -352,7 +353,7 @@ XWMHints *wmhints; /* WM hints */ Window group; /* group ID */ XClassHint class; - struct WList *list; + WList *list; /*********************************************************************** * color definitions per window **********************************************************************/ @@ -371,14 +372,13 @@ short icon_moved; /* user explicitly moved the icon */ short highlight; /* should highlight this window */ short stackmode; /* honor stackmode requests */ - short ontoppriority; /* how much on top should that be */ short iconify_by_unmapping; /* unmap window to iconify it */ short iconmgr; /* this is an icon manager window */ short wspmgr; /* this is a workspace manager manager window */ short transient; /* this is a transient window */ Window transientfor; /* window contained in XA_XM_TRANSIENT_FOR */ short titlehighlight; /* should I highlight the title bar */ - struct IconMgr *iconmgrp; /* pointer to it if this is an icon manager */ + IconMgr *iconmgrp; /* pointer to it if this is an icon manager */ int save_frame_x; /* x position of frame */ int save_frame_y; /* y position of frame */ int save_frame_width; /* width of frame */ @@ -390,7 +390,7 @@ TBWindow *titlebuttons; SqueezeInfo *squeeze_info; /* should the title be squeezed? */ struct { - struct TwmWindow *next, *prev; + TwmWindow *next, *prev; Bool cursor_valid; int curs_x, curs_y; } ring; @@ -404,8 +404,8 @@ short DontSetInactive; Bool hasfocusvisible; /* The window has visivle focus*/ int occupation; - Image *HiliteImage; /* focus highlight window background */ - Image *LoliteImage; /* focus lowlight window background */ + Image *HiliteImage; /* focus highlight window background */ + Image *LoliteImage; /* focus lowlight window background */ WindowRegion *wr; WindowBox *winbox; Bool iswinbox; @@ -424,12 +424,12 @@ Bool heightEverChangedByUser; #endif -} TwmWindow; +}; #ifdef X11R6 -typedef struct TWMWinConfigEntry +struct TWMWinConfigEntry { - struct TWMWinConfigEntry *next; + TWMWinConfigEntry *next; int tag; char *client_id; char *window_role; @@ -451,7 +451,7 @@ int occupation; /* ====================================================================== */ -} TWMWinConfigEntry; +}; #endif #define DoesWmTakeFocus (1L << 0) @@ -525,9 +525,18 @@ extern char *Home; extern int HomeLen; -extern int ParseError; extern int HandlingEvents; +extern char *captivename; +extern int captive; +extern Cursor TopCursor, TopLeftCursor, LeftCursor, BottomLeftCursor, + BottomCursor, BottomRightCursor, RightCursor, TopRightCursor; +extern int KeepTmpFile; +extern char *display_name; +extern int GoThroughM4; +extern int ShapeEventBase; +void RestoreWithdrawnLocation (TwmWindow *tmp); +void CreateFonts (void); extern Window JunkRoot; extern Window JunkChild; @@ -562,6 +571,7 @@ extern Atom _XA_WM_TAKE_FOCUS; extern Atom _XA_WM_SAVE_YOURSELF; extern Atom _XA_WM_DELETE_WINDOW; +extern Atom _XA_WM_END_OF_ANIMATION; extern Atom _XA_WM_CLIENT_MACHINE; #ifdef X11R6 extern Atom _XA_SM_CLIENT_ID; Index: typedefs.h =================================================================== RCS file: typedefs.h diff -N typedefs.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ typedefs.h 3 Apr 2005 16:35:58 -0000 1.4 @@ -0,0 +1,63 @@ +/* $Id: typedefs.h,v 1.3 1997/10/29 00:51:44 monnier Exp $ */ + +/* */ + +#ifndef TYPEDEFS_H +#define TYPEDEFS_H + +/* from list.h */ +typedef struct name_list name_list; + +/* from twm.h */ +typedef struct TwmWindow TwmWindow; +typedef struct MyFont MyFont; +typedef struct ColorPair ColorPair; +typedef struct TitleButtonFunc TitleButtonFunc; +typedef struct TitleButton TitleButton; +typedef struct TBWindow TBWindow; +typedef struct SqueezeInfo SqueezeInfo; +typedef struct TwmColormap TwmColormap; +typedef struct ColormapWindow ColormapWindow; +typedef struct Colormaps Colormaps; +typedef struct WindowRegion WindowRegion; +typedef struct WindowEntry WindowEntry; +typedef struct TWMWinConfigEntry TWMWinConfigEntry; + +/* from menus.h */ +typedef struct MenuItem MenuItem; +typedef struct MenuRoot MenuRoot; +typedef struct MouseButton MouseButton; +typedef struct FuncButton FuncButton; +typedef struct FuncKey FuncKey; + +/* from util.h */ +typedef struct Image Image; + +/* from otp */ +typedef struct OtpWinList OtpWinList; +typedef struct OtpPreferences OtpPreferences; + +/* from icons.h */ +typedef struct Icon Icon; +typedef struct IconRegion IconRegion; +typedef struct IconEntry IconEntry; + +/* from iconmgr.h */ +typedef struct WList WList; +typedef struct IconMgr IconMgr; + +/* from screen.h */ +typedef struct StdCmap StdCmap; +typedef struct TitlebarPixmaps TitlebarPixmaps; +typedef struct ScreenInfo ScreenInfo; + +/* +typedef struct ; +typedef struct ; +typedef struct ; +typedef struct ; +typedef struct ; +typedef struct ; +*/ + +#endif /* TYPEDEFS_H */ Index: util.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/util.c,v retrieving revision 1.1.1.14 retrieving revision 1.11 diff -u -r1.1.1.14 -r1.11 --- util.c 2 Apr 2005 23:00:30 -0000 1.1.1.14 +++ util.c 4 Apr 2005 19:56:29 -0000 1.11 @@ -82,7 +82,11 @@ #include "add_window.h" #include "gram.h" #include "screen.h" +#include "events.h" #include "icons.h" +#include "list.h" +#include "siconify.bm" +#include "iconmgr.h" #include #ifdef VMS #include @@ -117,6 +121,7 @@ # define R_OK 4 #endif #else +#include #include #include #include @@ -168,50 +173,43 @@ #define MAXANIMATIONSPEED 20 -extern int captive; -extern Atom _XA_WM_WORKSPACESLIST; - -static Image *LoadBitmapImage (); -static Image *GetBitmapImage (); +/* static Image *LoadBitmapImage (); */ +/* static Image *GetBitmapImage (); */ #if !defined(VMS) || defined(HAVE_XWDFILE_H) -static Image *LoadXwdImage (); -static Image *GetXwdImage (); -#endif -#ifdef XPM -static Image *LoadXpmImage (); -static Image *GetXpmImage (); -static void xpmErrorMessage (); -#endif -#ifdef IMCONV -static Image *GetImconvImage (); +/* static Image *LoadXwdImage (); */ +static Image *GetXwdImage (char *name, ColorPair cp); #endif -static Pixmap CreateXLogoPixmap(), CreateResizePixmap(); -static Pixmap CreateQuestionPixmap(), CreateMenuPixmap(); -static Pixmap CreateDotPixmap (); -static Image *Create3DMenuImage (); -static Image *Create3DDotImage (); -static Image *Create3DResizeImage (); -static Image *Create3DZoomImage (); -static Image *Create3DBarImage (); -static Image *Create3DVertBarImage (); -static Image *Create3DResizeAnimation (); -static Image *Create3DCrossImage (); -static Image *Create3DIconifyImage (); -static Image *Create3DSunkenResizeImage (); -static Image *Create3DBoxImage (); +static Pixmap CreateXLogoPixmap (unsigned int *w, unsigned int *h); +static Pixmap CreateResizePixmap (unsigned int *w, unsigned int *h); +static Pixmap CreateQuestionPixmap (unsigned int *w, unsigned int *h); +static Pixmap CreateDotPixmap (unsigned int *w, unsigned int *h); +static Pixmap CreateMenuPixmap (unsigned int *w, unsigned int *h); +/* static Image *Create3DMenuImage (); */ +/* static Image *Create3DDotImage (); */ +/* static Image *Create3DResizeImage (); */ +/* static Image *Create3DZoomImage (); */ +/* static Image *Create3DBarImage (); */ +/* static Image *Create3DVertBarImage (); */ +/* static Image *Create3DResizeAnimation (); */ +/* static Image *Create3DCrossImage (); */ +/* static Image *Create3DIconifyImage (); */ +/* static Image *Create3DSunkenResizeImage (); */ +/* static Image *Create3DBoxImage (); */ +static void PaintTitleButtons (TwmWindow *tmp_win); +static void PaintAllDecoration (void); +static void xpmErrorMessage (int status, char *name, char *fullname); -extern FILE *tracefile; +static void FreeImage (); -void FreeImage (); - -int _swapshort (); -int _swaplong (); +static void _swapshort (char *bp, unsigned n); +static void _swaplong (char *bp, unsigned n); static int reportfilenotfound = 1; static Colormap AlternateCmap = None; int HotX, HotY; +int Animating = 0; int AnimationSpeed = 0; Bool AnimationActive = False; Bool MaybeAnimate = True; @@ -414,7 +412,7 @@ len = 0; p = path; - while (colon = strchr (p, ':')) { + while ((colon = strchr (p, ':'))) { len += colon - p + 1; if (*p == '~') len += HomeLen - 1; p = colon + 1; @@ -425,7 +423,7 @@ *ret = 0; p = path; - while (colon = strchr (p, ':')) { + while ((colon = strchr (p, ':'))) { *colon = '\0'; if (*p == '~') { strcat (ret, Home); @@ -473,7 +471,7 @@ newname = (char *) malloc (HomeLen + strlen(name) + 1); if (!newname) { fprintf (stderr, - "%s: unable to allocate %d bytes to expand filename %s%s\n", + "%s: unable to allocate %ld bytes to expand filename %s%s\n", ProgramName, HomeLen + strlen(name) + 1, Home, &name[1]); } else { (void) sprintf (newname, "%s%s", Home, &name[1]); @@ -482,7 +480,7 @@ newname = (char *) malloc (HomeLen + strlen(name) + 2); if (!newname) { fprintf (stderr, - "%s: unable to allocate %d bytes to expand filename %s/%s\n", + "%s: unable to allocate %ld bytes to expand filename %s/%s\n", ProgramName, HomeLen + strlen(name) + 2, Home, &name[1]); } else { (void) sprintf (newname, "%s/%s", Home, &name[1]); @@ -534,7 +532,7 @@ else if (Scr->PixmapDirectory) { char *p = Scr->PixmapDirectory; - while (colon = strchr (p, ':')) { + while ((colon = strchr (p, ':'))) { *colon = '\0'; ret = (char *) malloc (strlen (p) + strlen (name) + 2); sprintf (ret, "%s/%s", p, name); @@ -690,7 +688,7 @@ bm = FindBitmap (name, &width, &height); if (bm == None) return (None); - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); image->pixmap = XCreatePixmap (dpy, Scr->Root, width, height, Scr->d_depth); gcvalues.background = cp.back; gcvalues.foreground = cp.fore; @@ -761,7 +759,7 @@ fullname = ExpandPixmapPath (name); if (! fullname) return (None); - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (image == None) return (None); attributes.valuemask = 0; @@ -780,7 +778,6 @@ overrides[2].pixel = cp.shadd; overrides[3].pixel = cp.shadc; - attributes.colormap = AlternateCmap ? AlternateCmap : stdcmap; attributes.depth = Scr->d_depth; attributes.visual = Scr->d_visual; @@ -950,7 +947,8 @@ Scr->WelcomeImage->width, Scr->WelcomeImage->height, x, y); } -UnmaskScreen () { +void UnmaskScreen (void) +{ #ifdef VMS float timeout; #else @@ -967,7 +965,7 @@ #ifdef VMS timeout = 0.017; #else - usec = 10000; + usec = 6000; timeout.tv_usec = usec % (unsigned long) 1000000; timeout.tv_sec = usec / (unsigned long) 1000000; #endif @@ -1097,7 +1095,8 @@ #define TIMID 12L -void StartAnimation () { +void StartAnimation (void) +{ if (AnimationSpeed > MAXANIMATIONSPEED) AnimationSpeed = MAXANIMATIONSPEED; if (AnimationSpeed <= 0) return; if (AnimationActive) return; @@ -1113,7 +1112,8 @@ AnimationActive = True; } -void StopAnimation () { +void StopAnimation (void) +{ if (AnimationSpeed <= 0) return; if (! AnimationActive) return; AnimationActive = False; @@ -1167,7 +1167,8 @@ #endif #ifndef USE_SIGNALS -void TryToAnimate () { +void TryToAnimate (void) +{ struct timeval tp; struct timezone tzp; static unsigned long lastsec; @@ -1177,7 +1178,7 @@ gettimeofday (&tp, &tzp); gap = ((tp.tv_sec - lastsec) * 1000000) + (tp.tv_usec - lastusec); if (tracefile) { - fprintf (tracefile, "Time = %u, %d, %u, %d, %u\n", lastsec, lastusec, + fprintf (tracefile, "Time = %lu, %ld, %lu, %ld, %lu\n", lastsec, lastusec, tp.tv_sec, tp.tv_usec, gap); fflush (tracefile); } @@ -1193,7 +1194,8 @@ } #endif /* USE_SIGNALS */ -void StartAnimation () { +void StartAnimation (void) +{ #ifdef USE_SIGNALS struct itimerval tv; #endif @@ -1233,7 +1235,8 @@ AnimationActive = True; } -void StopAnimation () { +void StopAnimation (void) +{ #ifdef USE_SIGNALS struct itimerval tv; @@ -1309,7 +1312,8 @@ #endif #endif /* VMS */ -void Animate () { +void Animate (void) +{ TwmWindow *t; int scrnum; ScreenInfo *scr; @@ -1354,6 +1358,10 @@ } } MaybeAnimate |= AnimateRoot (); + if (MaybeAnimate) { + Animating++; + SendEndAnimationMessage(scr->currentvs->wsw->w, LastTimestamp()); + } XFlush (dpy); return; } @@ -1375,7 +1383,7 @@ if (!sc) { /* no existing, allocate new */ sc = (StdCmap *) malloc (sizeof (StdCmap)); if (!sc) { - fprintf (stderr, "%s: unable to allocate %d bytes for StdCmap\n", + fprintf (stderr, "%s: unable to allocate %ld bytes for StdCmap\n", ProgramName, sizeof (StdCmap)); return; } @@ -1564,7 +1572,6 @@ register int i; int ascent; int descent; - XFontStruct *xf; int fnum; char *basename2; @@ -1936,7 +1943,7 @@ point = 4; midpoint = h/2; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (struct Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2002,7 +2009,7 @@ if (!(h & 1)) h--; point = ((h/2-2) * 2+1) / 3; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2033,7 +2040,7 @@ h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (!(h & 1)) h--; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2062,7 +2069,7 @@ h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (! (h & 1)) h--; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2089,7 +2096,7 @@ h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (!(h & 1)) h--; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2117,7 +2124,7 @@ h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (!(h & 1)) h--; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2146,7 +2153,7 @@ h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (!(h & 1)) h--; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2174,7 +2181,7 @@ h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (!(h & 1)) h--; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2199,7 +2206,7 @@ h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (!(h & 1)) h--; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2225,7 +2232,7 @@ h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (!(h & 1)) h--; - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (! image) return (None); image->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (image->pixmap == None) return (None); @@ -2285,8 +2292,6 @@ return (colori->pix); } -#include "siconify.bm" - Pixmap Create3DIconManagerIcon (cp) ColorPair cp; { @@ -2325,7 +2330,7 @@ image = im1 = None; for (i = (in ? 0 : (h/4)-1); (i < h/4) && (i >= 0); i += (in ? 1 : -1)) { - im = (Image*) malloc (sizeof (struct _Image)); + im = (Image*) malloc (sizeof (Image)); if (! im) return (None); im->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (im->pixmap == None) { @@ -2389,7 +2394,7 @@ image = im1 = None; for (j = (up ? 4 : 0); j != (up ? -1 : 5); j+= (up ? -1 : 1)) { - im = (Image*) malloc (sizeof (struct _Image)); + im = (Image*) malloc (sizeof (Image)); if (! im) return (None); im->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); if (im->pixmap == None) { @@ -2445,7 +2450,7 @@ image = im1 = None; for (j = (out ? -1 : 1) ; j < (in ? 2 : 0); j += 2){ for(k = (j > 0 ? 0 : n-1) ; (k >= 0) && (k < n); k += j){ - im = (Image*) malloc (sizeof (struct _Image)); + im = (Image*) malloc (sizeof (Image)); im->pixmap = XCreatePixmap (dpy, Scr->Root, h, h, Scr->d_depth); Draw3DBorder (im->pixmap, 0, 0, h, h, Scr->TitleButtonShadowDepth, cp, off, True, False); for (i = 2 + k; i < (h / 2); i += n) { @@ -2521,8 +2526,7 @@ } -static Pixmap CreateMenuPixmap (widthp, heightp) - int *widthp, *heightp; +static Pixmap CreateMenuPixmap (unsigned int *widthp, unsigned int *heightp) { return (CreateMenuIcon (Scr->TBInfo.width - Scr->TBInfo.border * 2,widthp,heightp)); } @@ -2764,7 +2768,8 @@ return; } -void PaintAllDecoration () { +static void PaintAllDecoration (void) +{ TwmWindow *tmp_win; virtualScreen *vs; @@ -2772,10 +2777,8 @@ if (! visible (tmp_win)) continue; if (tmp_win->mapped == TRUE) { if (tmp_win->frame_bw3D) - if (tmp_win->highlight && tmp_win == Scr->Focus) - PaintBorders (tmp_win, True); - else - PaintBorders (tmp_win, False); + PaintBorders (tmp_win, + tmp_win->highlight && tmp_win == Scr->Focus); if (tmp_win->title_w) PaintTitle (tmp_win); if (tmp_win->titlebuttons) PaintTitleButtons (tmp_win); } @@ -3045,8 +3048,7 @@ return; } -void PaintTitleButtons (tmp_win) -TwmWindow *tmp_win; +static void PaintTitleButtons (TwmWindow *tmp_win) { int i; TBWindow *tbw; @@ -3057,7 +3059,8 @@ } } -void adoptWindow () { +void adoptWindow (void) +{ unsigned long data [2]; Window localroot, w; unsigned char *prop; @@ -3140,9 +3143,6 @@ } } -extern Cursor TopRightCursor, TopLeftCursor, BottomRightCursor, BottomLeftCursor, - LeftCursor, RightCursor, TopCursor, BottomCursor; - void SetBorderCursor (tmp_win, x, y) TwmWindow *tmp_win; int x, y; @@ -3358,7 +3358,7 @@ else if (name [0] == ':') { int i, width, height; - Pixmap pm; + Pixmap pm = None; XGCValues gcvalues; static struct { char *name; @@ -3390,7 +3390,7 @@ fprintf (stderr, "%s: no such built-in bitmap \"%s\"\n", ProgramName, name); return (None); } - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); image->pixmap = XCreatePixmap (dpy, Scr->Root, width, height, Scr->d_depth); if (Scr->rootGC == (GC) 0) Scr->rootGC = XCreateGC (dpy, Scr->Root, 0, &gcvalues); gcvalues.background = cp.back; @@ -3592,7 +3592,7 @@ if (w > Scr->rootw) w = Scr->rootw; if (h > Scr->rooth) h = Scr->rooth; - ret = (Image*) malloc (sizeof (struct _Image)); + ret = (Image*) malloc (sizeof (Image)); if (! ret) { fprintf (stderr, "unable to allocate memory for image : %s\n", filename); free (image); @@ -3909,7 +3909,7 @@ ret->height = h; } XFree (image); - ret = (Image*) malloc (sizeof (struct _Image)); + ret = (Image*) malloc (sizeof (Image)); ret->pixmap = pixret; ret->mask = None; ret->next = None; @@ -3942,9 +3942,7 @@ #endif -_swapshort (bp, n) - register char *bp; - register unsigned n; +static void _swapshort (char *bp, unsigned n) { register char c; register char *ep = bp + n; @@ -3957,9 +3955,7 @@ } } -_swaplong (bp, n) - register char *bp; - register unsigned n; +static void _swaplong (char *bp, unsigned n) { register char c; register char *ep = bp + n; @@ -4205,12 +4201,11 @@ int g, i, a; int bpix; GC gc; - XGCValues gcvalues; fullname = ExpandPixmapPath (name); if (! fullname) return (None); - image = (Image*) malloc (sizeof (struct _Image)); + image = (Image*) malloc (sizeof (Image)); if (image == None) return (None); if ((infile = fopen (fullname, "rb")) == NULL) { Index: util.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/util.h,v retrieving revision 1.1.1.5 retrieving revision 1.7 diff -u -r1.1.1.5 -r1.7 --- util.h 7 Oct 1999 17:32:42 -0000 1.1.1.5 +++ util.h 7 Oct 1999 19:09:11 -0000 1.7 @@ -64,57 +64,110 @@ #ifndef _UTIL_ #define _UTIL_ +#include "typedefs.h" +#include + #if defined(VMS) || defined(ultrix) || defined(sequent) || defined(sony_news) || defined(riscix) # define strdup(s) ((char*) strcpy ((char*) malloc (strlen (s) + 1), s)) #endif -extern void Zoom(); -extern void MoveOutline(); -extern Pixmap GetBitmap(), FindBitmap(); -extern void GetUnknownIcon(); -extern char *ExpandFilename(); -extern char *ExpandFilePath(); - -void MaskScreen (); -int UnmaskScreen (); -void StartAnimation (); -void StopAnimation (); -void SetAnimationSpeed (); -void ModifyAnimationSpeed (); -void Animate (); -void InsertRGBColormap (); -void RemoveRGBColormap (); -void LocateStandardColormaps (); -void GetColor (); -void GetShadeColors (); -void GetFont(); -void SetFocusVisualAttributes (); -void SetFocus (); -Pixmap Create3DMenuIcon (); -Pixmap Create3DIconManagerIcon (); -void Draw3DBorder (); -void Draw3DCorner (); -void PaintBorders (); -void PaintAllDecoration (); -void PaintTitle (); -void PaintIcon (); -void PaintTitleButton (); -void PaintTitleButtons (); -void adoptWindow (); -void DebugTrace (); -void SetBorderCursor (); -void ChangeFocusGrab (); -Cursor CalculateBorderCursor (); +#ifndef MAX +#define MAX(x,y) ((x)>(y)?(x):(y)) +#endif +#ifndef MIN +#define MIN(x,y) ((x)<(y)?(x):(y)) +#endif +#ifndef ABS +#define ABS(x) ((x)<0?-(x):(x)) +#endif + +extern int Animating; +extern Bool AnimationActive; +extern Bool MaybeAnimate; +extern int AnimationSpeed; +#ifdef USE_SIGNALS +extern Bool AnimationPending; +#else +extern struct timeval AnimateTimeout; +#endif /* USE_SIGNALS */ + +void Zoom(); +void MoveOutline(); +Pixmap GetBitmap(), FindBitmap(); +void GetUnknownIcon(); +char *ExpandFilename(); +char *ExpandFilePath(); + +#ifndef USE_SIGNALS +void TryToAnimate (void); +#endif +void Animate (void); +void SetAnimationSpeed (int speed); +void DebugTrace (char *file); +void adoptWindow (void); +void ModifyAnimationSpeed (int incr); +void GetFont (MyFont *font); +void StopAnimation (void); +void StartAnimation (void); +void MaskScreen (char *file); +void LocateStandardColormaps (void); +void InsertRGBColormap (Atom a, XStandardColormap *m, int nmaps, Bool replace); +void RemoveRGBColormap (Atom a); +void UnmaskScreen (void); +void GetColor (int kind, Pixel *what, char *name); +void GetShadeColors (ColorPair *cp); +Pixmap Create3DIconManagerIcon (ColorPair cp); +void SetFocusVisualAttributes (TwmWindow *tmp_win, Bool focus); +void SetBorderCursor (TwmWindow *tmp_win, int x, int y); +void SetFocus (TwmWindow *tmp_win, Time time); +void PaintTitleButton (TwmWindow *tmp_win, TBWindow *tbw); +void PaintIcon (TwmWindow *tmp_win); +void PaintTitle (TwmWindow *tmp_win); +void PaintBorders (TwmWindow *tmp_win, Bool focus); +void Draw3DBorder (Window w, int x, int y, int width, int h, int bw, + ColorPair cp, int state, int fill, int forcebw); + + +/* void MaskScreen (); */ +/* void StartAnimation (); */ +/* void StopAnimation (); */ +/* void SetAnimationSpeed (); */ +/* void ModifyAnimationSpeed (); */ +/* void Animate (); */ +/* void TryToAnimate(void); */ +/* void InsertRGBColormap (); */ +/* void RemoveRGBColormap (); */ +/* void LocateStandardColormaps (); */ +/* void GetColor (int kind, Pixel *what, char *name); */ +/* void GetShadeColors (); */ +/* void GetFont(); */ +/* void SetFocusVisualAttributes (); */ +/* void SetFocus (); */ +/* Pixmap Create3DMenuIcon (); */ +/* Pixmap Create3DIconManagerIcon (); */ +/* void Draw3DBorder (); */ +/* void Draw3DCorner (); */ +/* void PaintBorders (); */ +/* void PaintAllDecoration (); */ +/* void PaintTitle (); */ +/* void PaintIcon (); */ +/* void PaintTitleButton (); */ +/* void PaintTitleButtons (); */ +/* void adoptWindow (); */ +/* void DebugTrace (); */ +/* void SetBorderCursor (); */ +/* void ChangeFocusGrab (); */ +/* Cursor CalculateBorderCursor (); */ extern int HotX, HotY; -typedef struct _Image { +struct Image { Pixmap pixmap; Pixmap mask; int width; int height; - struct _Image *next; -} Image; + Image *next; +}; extern Image *GetImage (); Index: vscreen.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/vscreen.c,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -u -r1.1.1.2 -r1.2 --- vscreen.c 2 Apr 2005 23:00:30 -0000 1.1.1.2 +++ vscreen.c 3 Apr 2005 16:35:59 -0000 1.2 @@ -28,6 +28,7 @@ #include #include "twm.h" #include "screen.h" +#include "parse.h" void InitVirtualScreens (ScreenInfo *scr) { Cursor cursor; @@ -78,7 +79,8 @@ virtualScreen *vs; char *geometry = (char*) nptr->name; int x, y, w, h; - unsigned int mask = XParseGeometry (geometry, &x, &y, &w, &h); + + XParseGeometry (geometry, &x, &y, &w, &h); if ((x < 0) || (y < 0) || (w > scr->rootw) || (h > scr->rooth)) { twmrc_error_prefix (); Index: windowbox.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/windowbox.c,v retrieving revision 1.1.1.2 retrieving revision 1.3 diff -u -r1.1.1.2 -r1.3 --- windowbox.c 2 Apr 2005 22:55:32 -0000 1.1.1.2 +++ windowbox.c 3 Apr 2005 16:35:59 -0000 1.3 @@ -34,6 +34,9 @@ #endif #include "screen.h" #include "windowbox.h" +#include "add_window.h" +#include "list.h" +#include "resize.h" name_list **addWindowBox (boxname, geometry) char *boxname, *geometry; Index: workmgr.c =================================================================== RCS file: /u/monnier/cvsroot/ctwm/workmgr.c,v retrieving revision 1.1.1.10 retrieving revision 1.11 diff -u -r1.1.1.10 -r1.11 --- workmgr.c 2 Apr 2005 23:00:30 -0000 1.1.1.10 +++ workmgr.c 3 Apr 2005 16:35:59 -0000 1.11 @@ -24,9 +24,8 @@ * Author: Claude Lecommandeur [ lecom@sic.epfl.ch ][ April 1992 ] */ #include -#if defined(sony_news) || defined __QNX__ -# include -#endif +#include + #include "twm.h" #include "util.h" #include "parse.h" @@ -35,10 +34,14 @@ #include "resize.h" #include "add_window.h" #include "events.h" +#include "otp.h" #include "gram.h" +#include "iconmgr.h" +#include "list.h" + +#include #include "clicktofocus.h" #ifdef VMS -#include #include #include #include @@ -63,7 +66,7 @@ extern Atom _XA_WIN_STATE; #endif /* GNOME */ -extern int twmrc_error_prefix (); /* in ctwm.c */ +/* extern int twmrc_error_prefix (); /\* in ctwm.c *\/ */ extern int match (); /* in list.c */ extern char *captivename; @@ -86,7 +89,7 @@ #define OCCUPYBUTTON 2 static void Vanish (); -static void DisplayWin (); +static void DisplayWin (virtualScreen *vs, TwmWindow *tmp_win); static void CreateWorkSpaceManagerWindow (); static void CreateOccupyWindow (); static unsigned int GetMaskFromResource (); @@ -151,7 +154,7 @@ /* dl: I split ConfigureWSM into two functions to make vscreens work properly */ -ConfigureWorkSpaceManager1 () { +void ConfigureWorkSpaceManager1 () { virtualScreen *vs; for (vs = Scr->vScreenList; vs != NULL; vs = vs->next) { WorkSpaceWindow *wsw = (WorkSpaceWindow*) malloc (sizeof (WorkSpaceWindow)); @@ -162,7 +165,7 @@ } } -ConfigureWorkSpaceManager2 () { +void ConfigureWorkSpaceManager2 () { virtualScreen *vs; for (vs = Scr->vScreenList; vs != NULL; vs = vs->next) { vs->wsw->curColors.back = Scr->Black; @@ -182,7 +185,6 @@ void CreateWorkSpaceManager () { - WorkSpace *wlist; char wrkSpcList [512]; virtualScreen *vs; WorkSpace *ws; @@ -394,7 +396,7 @@ GotoWorkSpace (vs, ws); } -ShowBackground (vs) +void ShowBackground (vs) virtualScreen *vs; { static int state = 0; @@ -430,7 +432,6 @@ XWindowAttributes winattrs; unsigned long eventMask; IconMgr *iconmgr; - Window cachew; Window oldw; Window neww; unsigned long valuemask; @@ -467,6 +468,7 @@ XClearWindow (dpy, vs->window); } focuswindow = (TwmWindow*)0; + assert(OtpCheckConsistency()); for (twmWin = &(Scr->TwmRoot); twmWin != NULL; twmWin = twmWin->next) { if (twmWin->vs == vs) { if (!OCCUPY (twmWin, newws)) { @@ -491,6 +493,7 @@ last_twmWin = twmWin; } /* Iconise in reverse order */ + assert(OtpCheckConsistency()); for (twmWin = last_twmWin; twmWin != NULL; twmWin = twmWin->prev) { if (OCCUPY (twmWin, newws) && !twmWin->vs) DisplayWin (vs, twmWin); } @@ -847,15 +850,13 @@ unsigned long nitems, bytesafter; Atom actual_type; int actual_format; - int state; char **cliargv = NULL; int cliargc; Bool status; char *str_type; XrmValue value; - int len; int ret; - Atom _XA_WM_CTWMSLIST, _XA_WM_CTWM_ROOT; + Atom _XA_WM_CTWM_ROOT; char *atomname; Window newroot; XWindowAttributes wa; @@ -953,13 +954,15 @@ Scr->workSpaceMgr.occupyWindow->twm_win->occupation = twm_win->occupation; if (Scr->Root != Scr->CaptiveRoot) - XReparentWindow (dpy, Scr->workSpaceMgr.occupyWindow->twm_win->frame, Scr->Root, x, y); + ReparentWindow (dpy, Scr->workSpaceMgr.occupyWindow->twm_win, WinWin, + Scr->Root, x, y); else XMoveWindow (dpy, Scr->workSpaceMgr.occupyWindow->twm_win->frame, x, y); SetMapStateProp (Scr->workSpaceMgr.occupyWindow->twm_win, NormalState); XMapWindow (dpy, Scr->workSpaceMgr.occupyWindow->w); - XMapRaised (dpy, Scr->workSpaceMgr.occupyWindow->twm_win->frame); + OtpForcePlacement (Scr->workSpaceMgr.occupyWindow->twm_win, Above, twm_win); + XMapWindow (dpy, Scr->workSpaceMgr.occupyWindow->twm_win->frame); Scr->workSpaceMgr.occupyWindow->twm_win->mapped = TRUE; Scr->workSpaceMgr.occupyWindow->x = x; Scr->workSpaceMgr.occupyWindow->y = y; @@ -971,7 +974,7 @@ { WorkSpace *ws; OccupyWindow *occupyW; - Window buttonW, obuttonw; + Window buttonW; if (! Scr->workSpaceManagerActive) return; if (occupyWin == (TwmWindow*) 0) return; @@ -1154,7 +1157,7 @@ GotoWorkSpace(vs, wlist1); - RaiseWindow(twm_win); + OtpRaise(twm_win, WinWin); } @@ -1162,7 +1165,6 @@ virtualScreen *vs; TwmWindow *twm_win; { - int newoccupation, oldoccupation; WorkSpace *wlist1, *wlist2; if (! Scr->workSpaceManagerActive) return; @@ -1190,7 +1192,6 @@ virtualScreen *vs; TwmWindow *twm_win; { - int newoccupation, oldoccupation; WorkSpace *wlist1, *wlist2; if (! Scr->workSpaceManagerActive) return; @@ -1213,8 +1214,7 @@ ToggleOccupation(wlist2->name, twm_win); } GotoWorkSpace(vs,wlist1); - RaiseWindow(twm_win); - + OtpRaise(twm_win, WinWin); } static WorkSpace *GetWorkspace (wname) @@ -1270,7 +1270,6 @@ virtualScreen *vs; TwmWindow *tmp_win; { - TwmWindow *t; XWindowAttributes winattrs; unsigned long eventMask; @@ -1295,9 +1294,7 @@ tmp_win->vs = NULL; } -static void DisplayWin (vs, tmp_win) -virtualScreen *vs; -TwmWindow *tmp_win; +static void DisplayWin (virtualScreen *vs, TwmWindow *tmp_win) { XWindowAttributes winattrs; unsigned long eventMask; @@ -1305,11 +1302,12 @@ if (vs && tmp_win->vs) return; tmp_win->vs = vs; + assert(OtpCheckConsistency()); if (!tmp_win->mapped) { if (tmp_win->isicon) { if (tmp_win->icon_on) { if (tmp_win->icon && tmp_win->icon->w) { - if (vs) XReparentWindow (dpy, tmp_win->icon->w, vs->window, 0, 0); + if (vs) ReparentWindow (dpy, tmp_win, IconWin, vs->window, 0, 0); IconUp (tmp_win); XMapWindow (dpy, tmp_win->icon->w); return; @@ -1318,9 +1316,10 @@ } return; } + assert(OtpCheckConsistency()); if (tmp_win->UnmapByMovingFarAway) { - if (vs) XReparentWindow (dpy, tmp_win->frame, vs->window, - tmp_win->frame_x, tmp_win->frame_y); + if (vs) ReparentWindow (dpy, tmp_win, WinWin, vs->window, + tmp_win->frame_x, tmp_win->frame_y); else XMoveWindow (dpy, tmp_win->frame, tmp_win->frame_x, tmp_win->frame_y); } else { if (!tmp_win->squeezed) { @@ -1331,10 +1330,11 @@ XSelectInput (dpy, tmp_win->w, eventMask); } if (vs != tmp_win->oldvs) - XReparentWindow (dpy, tmp_win->frame, vs->window, tmp_win->frame_x, tmp_win->frame_y); + ReparentWindow (dpy, tmp_win, WinWin, vs->window, tmp_win->frame_x, tmp_win->frame_y); XMapWindow (dpy, tmp_win->frame); SetMapStateProp (tmp_win, NormalState); } + assert(OtpCheckConsistency()); } void ChangeOccupation (tmp_win, newoccupation) @@ -1550,7 +1550,7 @@ } if (! tw->mapped) DeIconify (tw); - if (! Scr->NoRaiseWarp) RaiseWindow (tw); + if (! Scr->NoRaiseWarp) OtpRaise(tw, WinWin); WarpToWindow (tw); } @@ -2046,13 +2046,8 @@ int strWid, strHei, hspace, vspace; #ifdef I18N XFontSetExtents *font_extents; - XFontStruct **xfonts; - char **font_names; - register int i; - int descent; XRectangle inc_rect; XRectangle logical_rect; - int fnum; #endif occwin = Scr->workSpaceMgr.occupyWindow; @@ -2217,6 +2212,7 @@ return (mask | win->occupation); case 2 : return (win->occupation & ~mask); + default : abort(); } } @@ -2540,7 +2536,7 @@ if (win->frame != children [i]) continue; /* skip icons */ if (! OCCUPY (win, ws)) continue; if (tracefile) { - fprintf (tracefile, "WMapRestack : w = %x, win = %x\n", children [i], win); + fprintf (tracefile, "WMapRestack : w = %lx, win = %p\n", children [i], win); fflush (tracefile); } for (wl = vs->wsw->mswl [ws->number]->wl; wl != NULL; wl = wl->next) { @@ -2675,7 +2671,6 @@ unsigned int button; unsigned int modifier; XSetWindowAttributes attrs; - unsigned long eventMask; float wf, hf; Boolean alreadyvivible, realmovemode, startincurrent; Time etime; @@ -2949,7 +2944,7 @@ occupation = (win->occupation | (1 << newws->number)) & ~(1 << oldws->number); ChangeOccupation (win, occupation); if (newws == vs->wsw->currentwspc) { - RaiseWindow (win); + OtpRaise(win, WinWin); WMapRaise (win); } else WMapRestack (newws); @@ -2962,7 +2957,7 @@ occupation = win->occupation | (1 << newws->number); ChangeOccupation (win, occupation); if (newws == vs->wsw->currentwspc) { - RaiseWindow (win); + OtpRaise(win, WinWin); WMapRaise (win); } else WMapRestack (newws); @@ -3454,14 +3449,9 @@ int scrnum; char **clist; { - unsigned char *prop, *p; - unsigned long bytesafter; unsigned long len; - Atom actual_type; - int actual_format; char **cl; char *s, *slist; - int i; Window root = RootWindow (dpy, scrnum); _XA_WM_CTWMSLIST = XInternAtom (dpy, "WM_CTWMSLIST", False); @@ -3554,7 +3544,7 @@ } void RemoveFromCaptiveList () { - int i, count; + int count; char **clist, **cl, **newclist; Atom _XA_WM_CTWM_ROOT; char *atomname; @@ -3610,8 +3600,6 @@ unsigned long len; Atom actual_type; int actual_format; - int scrnum = Scr->screen; - Window root = RootWindow (dpy, scrnum); Window ret; Atom _XA_WM_CTWM_ROOT; @@ -3667,8 +3655,6 @@ unsigned long len; Atom actual_type; int actual_format; - int scrnum = Scr->screen; - Window root = RootWindow (dpy, scrnum); Atom _XA_WM_NOREDIRECT; _XA_WM_NOREDIRECT = XInternAtom (dpy, "WM_NOREDIRECT", True); Index: workmgr.h =================================================================== RCS file: /u/monnier/cvsroot/ctwm/workmgr.h,v retrieving revision 1.1.1.6 retrieving revision 1.5 diff -u -r1.1.1.6 -r1.5 --- workmgr.h 2 Apr 2005 23:00:30 -0000 1.1.1.6 +++ workmgr.h 3 Apr 2005 16:35:59 -0000 1.5 @@ -26,6 +26,9 @@ #ifndef _WORKMGR_ #define _WORKMGR_ +#include "twm.h" +#include "vscreen.h" + #define MAXWORKSPACE 32 #define MAPSTATE 0 #define BUTTONSSTATE 1 @@ -36,7 +39,7 @@ #define STYLE_STYLE3 3 void InitWorkSpaceManager (); -int ConfigureWorkSpaceManager (); +void ConfigureWorkSpaceManager (void); void CreateWorkSpaceManager (); void GotoWorkSpaceByName (); void GotoWorkSpaceByNumber (); @@ -216,4 +219,8 @@ CaptiveCTWM GetCaptiveCTWMUnderPointer (); void SetNoRedirect (); +extern Atom _XA_WM_WORKSPACESLIST; +extern Atom _XA_WM_CURRENTWORKSPACE; +extern Atom _XA_WM_OCCUPATION; + #endif