From 22e912f7338ee41bd0f84f4330f4e8bc0c7501d9 Mon Sep 17 00:00:00 2001 From: Kaleb Keithley Date: Mon, 17 Nov 2003 19:03:47 +0000 Subject: merge XFree86 4.3.0.1 to -CURRENT --- man/twm.man | 25 +++--- src/add_window.c | 92 ++++++++++++--------- src/add_window.h | 22 +++-- src/cursor.c | 9 +- src/events.c | 151 +++++++++++++++++----------------- src/events.h | 72 ++++++++++------ src/gc.c | 5 +- src/gc.h | 3 +- src/gram.y | 46 ++++++----- src/iconmgr.c | 10 ++- src/iconmgr.h | 29 +++---- src/icons.c | 40 ++++++--- src/icons.h | 10 +++ src/lex.l | 15 ++-- src/list.c | 8 +- src/list.h | 19 +++-- src/menus.c | 184 +++++++++++++++++++++++++---------------- src/menus.h | 50 +++++++++--- src/parse.c | 40 +++++---- src/parse.h | 33 +++++++- src/resize.c | 30 ++++--- src/resize.h | 25 +++--- src/screen.h | 3 +- src/session.c | 75 +++++++++++------ src/system.twmrc | 4 + src/twm.c | 67 +++++++++------ src/twm.h | 51 +++++++----- src/util.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++----- src/util.h | 36 ++++++-- 29 files changed, 956 insertions(+), 442 deletions(-) diff --git a/man/twm.man b/man/twm.man index c14f676..3f96b1b 100644 --- a/man/twm.man +++ b/man/twm.man @@ -24,6 +24,9 @@ .\" not be used in advertising or otherwise to promote the sale, use or .\" other dealings in this Software without prior written authorization .\" from The Open Group. +.\" +.\" $XFree86: xc/programs/twm/twm.man,v 1.10 2002/10/12 16:06:46 herrb Exp $ +.\" .de EX \"Begin example .ne 5 .if n .sp 1 @@ -38,7 +41,7 @@ .if t .sp .5 .. .ta .3i .6i .9i 1.2i 1.5i 1.8i -.TH TWM 1 "Release 6.4" "X Version 11" +.TH TWM 1 __xorgversion__ .SH NAME twm \- Tab Window Manager for the X Window System .SH SYNTAX @@ -133,12 +136,11 @@ differing visual types. .B "$HOME/.twmrc" This is the usual name for an individual user's startup file. .TP 8 -.B "/lib/X11/twm/system.twmrc" +.B __projectroot__/lib/X11/twm/system.twmrc If neither of the preceding files are found, \fItwm\fP will look in this file for a default configuration. This is often tailored by the site administrator to -provide convenient menus or familiar bindings for novice users. -refers to the root of the X11 install tree. +provide convenient menus or familiar bindings for novice users. .PP If no startup files are found, \fItwm\fP will use the built-in defaults described above. The only resource used by \fItwm\fP is @@ -330,7 +332,8 @@ Shapes from the \fBcursor\fP font may be specified directly as: .EE where \fIcursorname\fP is one of the cursor names listed below, and \fIstring\fP is the name of a glyph as found in the file -/include/X11/cursorfont.h (without the ``XC_'' prefix). +.I __projectroot__/include/X11/cursorfont.h +(without the ``XC_'' prefix). If the cursor is to be defined from bitmap files, the following syntax is used instead: .EX 0 @@ -1096,8 +1099,10 @@ This function displays an outline of the selected window. Crossing a border rubber band until the invoking button is released. To abort a resize, press another button before releasing the first button. .IP "\fBf.restart\fP" 8 - This function kills and restarts \fItwm\fP. +.IP "\fBf.startwm\fP \fIstring\fP" 8 +This function kills \fItwm\fP and starts another window manager, as +specified by \fIstring\fP. .IP "\fBf.righticonmgr\fI" 8 This function is similar to \fBf.nexticonmgr\fP except that wrapping does not change rows. @@ -1252,9 +1257,9 @@ they may be lost if they are iconified and no bindings to .SH FILES .PP .nf - $HOME/.twmrc. - $HOME/.twmrc - /lib/X11/twm/system.twmrc +.I $HOME/.twmrc. +.I $HOME/.twmrc +.I __projectroot__/lib/X11/twm/system.twmrc .fi .SH "ENVIRONMENT VARIABLES" .IP "DISPLAY" 8 @@ -1265,7 +1270,7 @@ This variable is used as the prefix for files that begin with a tilde and for locating the \fItwm\fP startup file. .SH "SEE ALSO" .PP -X(1), Xserver(1), xdm(1), xrdb(1) +X(__miscmansuffix__), Xserver(1), xdm(1), xrdb(1) .SH AUTHORS Tom LaStrange, Solbourne Computer; Jim Fulton, MIT X Consortium; Steve Pitschke, Stardent Computer; Keith Packard, MIT X Consortium; diff --git a/src/add_window.c b/src/add_window.c index 8a2059a..85dae57 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/twm/add_window.c,v 1.12 2002/12/10 22:28:07 tsi Exp $ */ /*****************************************************************************/ /* @@ -64,7 +65,6 @@ in this Software without prior written authorization from The Open Group. #include #include "twm.h" #include -#include "add_window.h" #include "util.h" #include "resize.h" #include "parse.h" @@ -73,6 +73,8 @@ in this Software without prior written authorization from The Open Group. #include "menus.h" #include "screen.h" #include "iconmgr.h" +#include "session.h" +#include "add_window.h" #define gray_width 2 #define gray_height 2 @@ -86,7 +88,11 @@ int AddingH; static int PlaceX = 50; static int PlaceY = 50; -static void CreateWindowTitlebarButtons(); + +static void do_add_binding ( int button, int context, int modifier, int func ); +static Window CreateHighlightWindow ( TwmWindow *tmp_win ); +static void CreateWindowTitlebarButtons ( TwmWindow *tmp_win ); + char NoName[] = "Untitled"; /* name if no name is specified */ @@ -99,7 +105,7 @@ char NoName[] = "Untitled"; /* name if no name is specified */ * ************************************************************************ */ - +void GetGravityOffsets (tmp, xp, yp) TwmWindow *tmp; /* window from which to get gravity */ int *xp, *yp; /* return values */ @@ -161,9 +167,6 @@ IconMgr *iconp; unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ int width, height; /* tmp variable */ - Atom actual_type; - int actual_format; - unsigned long nitems, bytesafter; int ask_user; /* don't know where to put the window */ int gravx, gravy; /* gravity signs for positioning */ int namelen; @@ -175,6 +178,7 @@ IconMgr *iconp; int restoredFromPrevSession; Bool width_ever_changed_by_user; Bool height_ever_changed_by_user; + char *name; #ifdef DEBUG fprintf(stderr, "AddWindow: w = 0x%x\n", w); @@ -198,7 +202,8 @@ IconMgr *iconp; XGetWindowAttributes(dpy, tmp_win->w, &tmp_win->attr); - XFetchName(dpy, tmp_win->w, &tmp_win->name); + if (!I18N_FetchName(dpy, tmp_win->w, &name)) + name = NULL; tmp_win->class = NoClass; XGetClassHint(dpy, tmp_win->w, &tmp_win->class); FetchWmProtocols (tmp_win); @@ -272,29 +277,33 @@ IconMgr *iconp; tmp_win->transient = Transient(tmp_win->w, &tmp_win->transientfor); tmp_win->nameChanged = 0; - if (tmp_win->name == NULL) - tmp_win->name = NoName; + if (name == NULL) + tmp_win->name = strdup(NoName); + else { + tmp_win->name = strdup(name); + free(name); + } if (tmp_win->class.res_name == NULL) tmp_win->class.res_name = NoName; if (tmp_win->class.res_class == NULL) tmp_win->class.res_class = NoName; - tmp_win->full_name = tmp_win->name; + tmp_win->full_name = strdup(tmp_win->name); namelen = strlen (tmp_win->name); tmp_win->highlight = Scr->Highlight && - (!(short)(int) LookInList(Scr->NoHighlight, tmp_win->full_name, + (!(short)(long) LookInList(Scr->NoHighlight, tmp_win->full_name, &tmp_win->class)); tmp_win->stackmode = Scr->StackMode && - (!(short)(int) LookInList(Scr->NoStackModeL, tmp_win->full_name, + (!(short)(long) LookInList(Scr->NoStackModeL, tmp_win->full_name, &tmp_win->class)); tmp_win->titlehighlight = Scr->TitleHighlight && - (!(short)(int) LookInList(Scr->NoTitleHighlight, tmp_win->full_name, + (!(short)(long) LookInList(Scr->NoTitleHighlight, tmp_win->full_name, &tmp_win->class)); - tmp_win->auto_raise = (short)(int) LookInList(Scr->AutoRaise, + tmp_win->auto_raise = (short)(long) LookInList(Scr->AutoRaise, tmp_win->full_name, &tmp_win->class); if (tmp_win->auto_raise) Scr->NumAutoRaises++; @@ -302,11 +311,11 @@ IconMgr *iconp; if (Scr->IconifyByUnmapping) { tmp_win->iconify_by_unmapping = iconm ? FALSE : - !(short)(int) LookInList(Scr->DontIconify, tmp_win->full_name, + !(short)(long) LookInList(Scr->DontIconify, tmp_win->full_name, &tmp_win->class); } tmp_win->iconify_by_unmapping |= - (short)(int) LookInList(Scr->IconifyByUn, tmp_win->full_name, + (short)(long) LookInList(Scr->IconifyByUn, tmp_win->full_name, &tmp_win->class); if (LookInList(Scr->WindowRingL, tmp_win->full_name, &tmp_win->class)) { @@ -480,7 +489,7 @@ IconMgr *iconp; break; } - width = (SIZE_HINDENT + XTextWidth (Scr->SizeFont.font, + width = (SIZE_HINDENT + MyFont_TextWidth (&Scr->SizeFont, tmp_win->name, namelen)); height = Scr->SizeFont.height + SIZE_VINDENT * 2; @@ -488,12 +497,13 @@ IconMgr *iconp; XMapRaised(dpy, Scr->SizeWindow); InstallRootColormap(); - FBF(Scr->DefaultC.fore, Scr->DefaultC.back, - Scr->SizeFont.font->fid); - XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC, - SIZE_HINDENT, - SIZE_VINDENT + Scr->SizeFont.font->ascent, - tmp_win->name, namelen); + MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back, + &Scr->SizeFont); + MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, + Scr->NormalGC, + SIZE_HINDENT, + SIZE_VINDENT + Scr->SizeFont.ascent, + tmp_win->name, namelen); AddingW = tmp_win->attr.width + bw2; AddingH = tmp_win->attr.height + tmp_win->title_height + bw2; @@ -588,11 +598,12 @@ IconMgr *iconp; int lastx, lasty; Scr->SizeStringOffset = width + - XTextWidth(Scr->SizeFont.font, ": ", 2); + MyFont_TextWidth(&Scr->SizeFont, ": ", 2); XResizeWindow (dpy, Scr->SizeWindow, Scr->SizeStringOffset + Scr->SizeStringWidth, height); - XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC, width, - SIZE_VINDENT + Scr->SizeFont.font->ascent, + MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, + Scr->NormalGC, width, + SIZE_VINDENT + Scr->SizeFont.ascent, ": ", 2); if (0/*Scr->AutoRelativeResize*/) { int dx = (tmp_win->attr.width / 4); @@ -718,16 +729,19 @@ IconMgr *iconp; if (tmp_win->old_bw) XSetWindowBorderWidth (dpy, tmp_win->w, 0); - tmp_win->name_width = XTextWidth(Scr->TitleBarFont.font, tmp_win->name, - namelen); - - if (XGetWindowProperty (dpy, tmp_win->w, XA_WM_ICON_NAME, 0L, 200L, False, - XA_STRING, &actual_type, &actual_format, &nitems, - &bytesafter,(unsigned char **)&tmp_win->icon_name)) - tmp_win->icon_name = tmp_win->name; + tmp_win->name_width = MyFont_TextWidth(&Scr->TitleBarFont, tmp_win->name, + namelen); - if (tmp_win->icon_name == NULL) - tmp_win->icon_name = tmp_win->name; + if (!I18N_GetIconName(dpy, tmp_win->w, &name)) { + tmp_win->icon_name = strdup(tmp_win->name); + } else { + if (name == NULL) { + tmp_win->icon_name = strdup(tmp_win->name); + } else { + tmp_win->icon_name = strdup(name); + free(name); + } + } tmp_win->iconified = FALSE; tmp_win->icon = FALSE; @@ -994,6 +1008,7 @@ static void do_add_binding (button, context, modifier, func) mb->item = NULL; } +void AddDefaultBindings () { /* @@ -1208,6 +1223,7 @@ void ComputeCommonTitleOffsets () void ComputeWindowTitleOffsets (tmp_win, width, squeeze) TwmWindow *tmp_win; + int width; Bool squeeze; { tmp_win->highlightx = (Scr->TBInfo.titlex + tmp_win->name_width); @@ -1360,6 +1376,7 @@ static void CreateWindowTitlebarButtons (tmp_win) } +void SetHighlightPixmap (filename) char *filename; { @@ -1376,6 +1393,7 @@ SetHighlightPixmap (filename) } +void FetchWmProtocols (tmp) TwmWindow *tmp; { @@ -1472,7 +1490,8 @@ CreateColormapWindow(w, creating_parent, property_window) return (cwin); } - + +void FetchWmColormapWindows (tmp) TwmWindow *tmp; { @@ -1482,7 +1501,6 @@ FetchWmColormapWindows (tmp) int number_cmap_windows = 0; ColormapWindow **cwins = NULL; int previously_installed; - extern void free_cwins(); number_cmap_windows = 0; diff --git a/src/add_window.h b/src/add_window.h index 36b4428..298a133 100644 --- a/src/add_window.h +++ b/src/add_window.h @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/add_window.h,v 1.6 2001/12/14 20:01:06 dawes Exp $ */ /********************************************************************** @@ -63,15 +64,22 @@ in this Software without prior written authorization from The Open Group. #ifndef _ADD_WINDOW_ #define _ADD_WINDOW_ +#include "iconmgr.h" + extern char NoName[]; -extern TwmWindow *AddWindow(); -extern int MappedNotOverride(); -extern void GrabButtons(); -extern void GrabKeys(); -extern void UngrabButtons(); -extern void UngrabKeys(); -extern void GetWindowSizeHints(); +extern void AddDefaultBindings ( void ); +extern TwmWindow * AddWindow ( Window w, int iconm, IconMgr *iconp ); +extern ColormapWindow * CreateColormapWindow ( Window w, Bool creating_parent, Bool property_window ); +extern TwmColormap * CreateTwmColormap ( Colormap c ); +extern void FetchWmColormapWindows ( TwmWindow *tmp ); +extern void FetchWmProtocols ( TwmWindow *tmp ); +extern void GetGravityOffsets ( TwmWindow *tmp, int *xp, int *yp ); +extern void GetWindowSizeHints ( TwmWindow *tmp ); +extern void GrabButtons ( TwmWindow *tmp_win ); +extern void GrabKeys ( TwmWindow *tmp_win ); +extern int MappedNotOverride ( Window w ); +extern void SetHighlightPixmap ( char *filename ); extern int AddingX; extern int AddingY; extern int AddingW; diff --git a/src/cursor.c b/src/cursor.c index 713c236..89583ab 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -22,6 +22,7 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ +/* $XFree86: xc/programs/twm/cursor.c,v 1.5 2001/12/14 20:01:06 dawes Exp $ */ /*********************************************************************** * @@ -124,7 +125,8 @@ static struct _CursorName { {"xterm", XC_xterm, None}, }; -void NewFontCursor (cp, str) +void +NewFontCursor (cp, str) Cursor *cp; char *str; { @@ -145,9 +147,10 @@ void NewFontCursor (cp, str) ProgramName, str); } +void NewBitmapCursor(cp, source, mask) -Cursor *cp; -char *source, *mask; + Cursor *cp; + char *source, *mask; { int hotx, hoty; int sx, sy, mx, my; diff --git a/src/events.c b/src/events.c index 9b8c348..32378c9 100644 --- a/src/events.c +++ b/src/events.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/twm/events.c,v 1.12 2001/12/14 20:01:06 dawes Exp $ */ /*****************************************************************************/ /* @@ -63,6 +64,7 @@ in this Software without prior written authorization from The Open Group. #include #include "twm.h" #include +#include "iconmgr.h" #include "add_window.h" #include "menus.h" #include "events.h" @@ -71,12 +73,9 @@ in this Software without prior written authorization from The Open Group. #include "gram.h" #include "util.h" #include "screen.h" -#include "iconmgr.h" +#include "icons.h" #include "version.h" -extern int iconifybox_width, iconifybox_height; -extern unsigned int mods_used; -extern int menuFromFrameOrWindowOrTitlebar; #define MAX_X_EVENT 256 event_proc EventHandler[MAX_X_EVENT]; /* event handler jump table */ @@ -102,22 +101,21 @@ int DragHeight; int CurrentDragX; int CurrentDragY; -/* Vars to tell if the resize has moved. */ -extern int ResizeOrigX; -extern int ResizeOrigY; - static int enter_flag; static int ColortableThrashing; static TwmWindow *enter_win, *raise_win; -ScreenInfo *FindScreenInfo(); +static void free_window_names ( TwmWindow *tmp, Bool nukefull, Bool nukename, Bool nukeicon ); +static void remove_window_from_ring ( TwmWindow *tmp ); +static void do_menu ( MenuRoot *menu, Window w ); +static Bool HENQueueScanner ( Display *dpy, XEvent *ev, char *args ); +static Bool HLNQueueScanner ( Display *dpy, XEvent *ev, char *args ); +static void flush_expose ( Window w ); +static Bool UninstallRootColormapQScanner ( Display *dpy, XEvent *ev, char *args ); + int ButtonPressed = -1; int Cancel = FALSE; -void HandleCreateNotify(); - -void HandleShapeNotify (); -extern int ShapeEventBase, ShapeErrorBase; void AutoRaiseWindow (tmp) TwmWindow *tmp; @@ -352,7 +350,7 @@ Bool DispatchEvent () void HandleEvents() { - while (TRUE) + while (!TimeToYield) { if (enter_flag && !QLength(dpy)) { if (enter_win && enter_win != raise_win) { @@ -371,6 +369,12 @@ HandleEvents() else XtDispatchEvent (&Event); } + if (dpy) + { + Reborder (CurrentTime); + XCloseDisplay(dpy); + } + exit(0); } @@ -394,7 +398,6 @@ HandleColormapNotify() ColormapWindow *cwin, **cwins; TwmColormap *cmap; int lost, won, n, number_cwins; - extern TwmColormap *CreateTwmColormap(); if (XFindContext(dpy, cevent->window, ColormapContext, (caddr_t *)&cwin) == XCNOENT) return; @@ -496,7 +499,7 @@ HandleColormapNotify() ** the colormaps which are believed to be correct. */ - if (won != -1) + if (won != -1) { if (lost != -1) { /* lower diagonal index calculation */ @@ -518,8 +521,9 @@ HandleColormapNotify() */ cmap->state |= CM_INSTALLED; } - else if (lost != -1) + } else if (lost != -1) { InstallWindowColormaps(ColormapNotify, (TwmWindow *) NULL); + } } } @@ -705,7 +709,8 @@ HandleKeyPress() -static void free_window_names (tmp, nukefull, nukename, nukeicon) +static void +free_window_names (tmp, nukefull, nukename, nukeicon) TwmWindow *tmp; Bool nukefull, nukename, nukeicon; { @@ -716,17 +721,16 @@ static void free_window_names (tmp, nukefull, nukename, nukeicon) if (tmp->name == tmp->full_name) nukefull = False; if (tmp->icon_name == tmp->name) nukename = False; -#define isokay(v) ((v) && (v) != NoName) - if (nukefull && isokay(tmp->full_name)) XFree (tmp->full_name); - if (nukename && isokay(tmp->name)) XFree (tmp->name); - if (nukeicon && isokay(tmp->icon_name)) XFree (tmp->icon_name); -#undef isokay + if (nukefull && tmp->full_name) free (tmp->full_name); + if (nukename && tmp->name) free (tmp->name); + if (nukeicon && tmp->icon_name) free (tmp->icon_name); return; } -void free_cwins (tmp) +void +free_cwins (tmp) TwmWindow *tmp; { int i; @@ -766,10 +770,7 @@ void free_cwins (tmp) void HandlePropertyNotify() { - char *prop = NULL; - Atom actual = None; - int actual_format; - unsigned long nitems, bytesafter; + char *name = NULL; unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm; @@ -801,21 +802,16 @@ HandlePropertyNotify() switch (Event.xproperty.atom) { case XA_WM_NAME: - if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0L, - MAX_NAME_LEN, False, XA_STRING, &actual, - &actual_format, &nitems, &bytesafter, - (unsigned char **) &prop) != Success || - actual == None) - return; - if (!prop) prop = NoName; + if (!I18N_FetchName(dpy, Tmp_win->w, &name)) return; free_window_names (Tmp_win, True, True, False); - Tmp_win->full_name = prop; - Tmp_win->name = prop; + Tmp_win->full_name = strdup(name ? name : NoName); + Tmp_win->name = strdup(name ? name : NoName); + if (name) free(name); Tmp_win->nameChanged = 1; - Tmp_win->name_width = XTextWidth (Scr->TitleBarFont.font, + Tmp_win->name_width = MyFont_TextWidth (&Scr->TitleBarFont, Tmp_win->name, strlen (Tmp_win->name)); @@ -835,15 +831,10 @@ HandlePropertyNotify() break; case XA_WM_ICON_NAME: - if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0, - MAX_ICON_NAME_LEN, False, XA_STRING, &actual, - &actual_format, &nitems, &bytesafter, - (unsigned char **) &prop) != Success || - actual == None) - return; - if (!prop) prop = NoName; + if (!I18N_GetIconName(dpy, Tmp_win->w, &name)) return; free_window_names (Tmp_win, False, False, True); - Tmp_win->icon_name = prop; + Tmp_win->icon_name = strdup(name ? name : NoName); + if (name) free(name); RedoIconName(); break; @@ -989,7 +980,7 @@ HandlePropertyNotify() * *********************************************************************** */ - +void RedoIconName() { int x, y; @@ -1009,7 +1000,7 @@ RedoIconName() if (Tmp_win->icon_not_ours) return; - Tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font, + Tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont, Tmp_win->icon_name, strlen(Tmp_win->icon_name)); Tmp_win->icon_w_width += 6; @@ -1090,9 +1081,6 @@ HandleClientMessage() * *********************************************************************** */ - -static void flush_expose(); - void HandleExpose() { @@ -1111,14 +1099,15 @@ HandleExpose() int i; int height; - FBF(Scr->DefaultC.fore, Scr->DefaultC.back, - Scr->DefaultFont.font->fid); + MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back, + &Scr->DefaultFont); height = Scr->DefaultFont.height+2; for (i = 0; i < InfoLines; i++) { - XDrawString(dpy, Scr->InfoWindow, Scr->NormalGC, - 5, (i*height) + Scr->DefaultFont.y, Info[i], strlen(Info[i])); + MyFont_DrawString(dpy, Scr->InfoWindow, &Scr->DefaultFont, + Scr->NormalGC, 5, (i*height) + Scr->DefaultFont.y, Info[i], + strlen(Info[i])); } flush_expose (Event.xany.window); } @@ -1126,22 +1115,21 @@ HandleExpose() { if (Event.xany.window == Tmp_win->title_w) { - FBF(Tmp_win->title.fore, Tmp_win->title.back, - Scr->TitleBarFont.font->fid); + MyFont_ChangeGC(Tmp_win->title.fore, Tmp_win->title.back, + &Scr->TitleBarFont); - XDrawString (dpy, Tmp_win->title_w, Scr->NormalGC, - Scr->TBInfo.titlex, Scr->TitleBarFont.y, - Tmp_win->name, strlen(Tmp_win->name)); + MyFont_DrawString (dpy, Tmp_win->title_w, &Scr->TitleBarFont, + Scr->NormalGC, Scr->TBInfo.titlex, Scr->TitleBarFont.y, + Tmp_win->name, strlen(Tmp_win->name)); flush_expose (Event.xany.window); } else if (Event.xany.window == Tmp_win->icon_w) { - FBF(Tmp_win->iconc.fore, Tmp_win->iconc.back, - Scr->IconFont.font->fid); + MyFont_ChangeGC(Tmp_win->iconc.fore, Tmp_win->iconc.back, + &Scr->IconFont); - XDrawString (dpy, Tmp_win->icon_w, - Scr->NormalGC, - Tmp_win->icon_x, Tmp_win->icon_y, + MyFont_DrawString (dpy, Tmp_win->icon_w, &Scr->IconFont, + Scr->NormalGC, Tmp_win->icon_x, Tmp_win->icon_y, Tmp_win->icon_name, strlen(Tmp_win->icon_name)); flush_expose (Event.xany.window); return; @@ -1167,9 +1155,10 @@ HandleExpose() if (Tmp_win->list) { if (Event.xany.window == Tmp_win->list->w) { - FBF(Tmp_win->list->fore, Tmp_win->list->back, - Scr->IconManagerFont.font->fid); - XDrawString (dpy, Event.xany.window, Scr->NormalGC, + MyFont_ChangeGC(Tmp_win->list->fore, Tmp_win->list->back, + &Scr->IconManagerFont); + MyFont_DrawString (dpy, Event.xany.window, + &Scr->IconManagerFont, Scr->NormalGC, iconmgr_textx, Scr->IconManagerFont.y+4, Tmp_win->icon_name, strlen(Tmp_win->icon_name)); DrawIconManagerBorder(Tmp_win->list); @@ -1679,10 +1668,12 @@ HandleButtonRelease() case F_FORCEMOVE: ButtonPressed = -1; break; + case F_WARPTOSCREEN: + XUngrabPointer(dpy, CurrentTime); + /* fall through */ case F_CIRCLEUP: case F_CIRCLEDOWN: case F_REFRESH: - case F_WARPTOSCREEN: PopDownMenu(); break; default: @@ -1744,7 +1735,8 @@ HandleButtonRelease() -static do_menu (menu, w) +static void +do_menu (menu, w) MenuRoot *menu; /* menu to pop up */ Window w; /* invoking window or None */ { @@ -1785,6 +1777,10 @@ HandleButtonPress() unsigned int modifier; Cursor cur; + /* too much code relies on this assumption */ + if (Event.xbutton.button > MAX_BUTTONS) + return; + /* pop down the menu, if any */ if (ActiveMenu != NULL) PopDownMenu(); @@ -1799,12 +1795,13 @@ HandleButtonPress() Cancel = TRUE; CurrentDragX = origDragX; CurrentDragY = origDragY; - if (!menuFromFrameOrWindowOrTitlebar) + if (!menuFromFrameOrWindowOrTitlebar) { if (Scr->OpaqueMove && DragWindow != None) { XMoveWindow (dpy, DragWindow, origDragX, origDragY); } else { MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0); } + } XUnmapWindow(dpy, Scr->SizeWindow); if (!Scr->OpaqueMove) UninstallRootColormap(); @@ -2593,7 +2590,7 @@ static void flush_expose (w) * *********************************************************************** */ - +void InstallWindowColormaps (type, tmp) int type; TwmWindow *tmp; @@ -2703,7 +2700,7 @@ InstallWindowColormaps (type, tmp) * other colormap list would potentially be loaded anyway. *********************************************************************** */ - +void InstallRootColormap() { TwmWindow *tmp; @@ -2729,20 +2726,21 @@ UninstallRootColormapQScanner(dpy, ev, args) XEvent *ev; char *args; { - if (!*args) + if (!*args) { if (ev->type == EnterNotify) { if (ev->xcrossing.mode != NotifyGrab) *args = 1; } else if (ev->type == LeaveNotify) { if (ev->xcrossing.mode == NotifyNormal) + *args = 1; } - + } return (False); } - +void UninstallRootColormap() { char args; @@ -2766,6 +2764,7 @@ UninstallRootColormap() } #ifdef TRACE +void dumpevent (e) XEvent *e; { diff --git a/src/events.h b/src/events.h index adb15b5..1187c0d 100644 --- a/src/events.h +++ b/src/events.h @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/events.h,v 1.6 2001/12/14 20:01:07 dawes Exp $ */ /*********************************************************************** @@ -63,34 +64,49 @@ in this Software without prior written authorization from The Open Group. #ifndef _EVENTS_ #define _EVENTS_ -typedef void (*event_proc)(); +#include "screen.h" +#include "twm.h" + +typedef void (*event_proc)(void); -extern void InitEvents(); -extern Bool StashEventTime(); extern Time lastTimestamp; -extern void SimulateMapRequest(); -extern void AutoRaiseWindow(); #define LastTimestamp() lastTimestamp -extern Bool DispatchEvent(); -extern Bool DispatchEvent2(); -extern void HandleEvents(); -extern void HandleExpose(); -extern void HandleDestroyNotify(); -extern void HandleMapRequest(); -extern void HandleMapNotify(); -extern void HandleUnmapNotify(); -extern void HandleMotionNotify(); -extern void HandleButtonRelease(); -extern void HandleButtonPress(); -extern void HandleEnterNotify(); -extern void HandleLeaveNotify(); -extern void HandleConfigureRequest(); -extern void HandleClientMessage(); -extern void HandlePropertyNotify(); -extern void HandleKeyPress(); -extern void HandleColormapNotify(); -extern void HandleVisibilityNotify(); -extern void HandleUnknown(); + +extern void AutoRaiseWindow ( TwmWindow *tmp ); +extern void SetRaiseWindow ( TwmWindow *tmp ); +extern void InitEvents ( void ); +extern Bool StashEventTime ( XEvent *ev ); +extern Window WindowOfEvent ( XEvent *e ); +extern Bool DispatchEvent2 ( void ); +extern Bool DispatchEvent ( void ); +extern void HandleEvents ( void ); +extern void HandleColormapNotify ( void ); +extern void HandleVisibilityNotify ( void ); +extern void HandleKeyPress ( void ); +extern void free_cwins ( TwmWindow *tmp ); +extern void HandlePropertyNotify ( void ); +extern void RedoIconName ( void ); +extern void HandleClientMessage ( void ); +extern void HandleExpose ( void ); +extern void HandleDestroyNotify ( void ); +extern void HandleCreateNotify ( void ); +extern void HandleMapRequest ( void ); +extern void SimulateMapRequest ( Window w ); +extern void HandleMapNotify ( void ); +extern void HandleUnmapNotify ( void ); +extern void HandleMotionNotify ( void ); +extern void HandleButtonRelease ( void ); +extern void HandleButtonPress ( void ); +extern void HandleEnterNotify ( void ); +extern void HandleLeaveNotify ( void ); +extern void HandleConfigureRequest ( void ); +extern void HandleShapeNotify ( void ); +extern void HandleUnknown ( void ); +extern int Transient ( Window w, Window *propw ); +extern ScreenInfo * FindScreenInfo ( Window w ); +extern void InstallWindowColormaps ( int type, TwmWindow *tmp ); +extern void InstallRootColormap ( void ); +extern void UninstallRootColormap ( void ); extern event_proc EventHandler[]; extern Window DragWindow; @@ -106,6 +122,12 @@ extern int CurrentDragY; extern int ButtonPressed; extern int Cancel; +extern int Context; + extern XEvent Event; +extern unsigned int mods_used; + +extern int MovedFromKeyPress; + #endif /* _EVENTS_ */ diff --git a/src/gc.c b/src/gc.c index 2cdf838..4b10a52 100644 --- a/src/gc.c +++ b/src/gc.c @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/gc.c,v 1.6 2001/12/14 20:01:07 dawes Exp $ */ /********************************************************************** @@ -64,6 +65,7 @@ in this Software without prior written authorization from The Open Group. #include "twm.h" #include "util.h" #include "screen.h" +#include "gc.h" /*********************************************************************** * @@ -99,7 +101,8 @@ CreateGCs() gcm = 0; gcm |= GCForeground; gcv.foreground = Scr->MenuC.fore; gcm |= GCBackground; gcv.background = Scr->MenuC.back; - gcm |= GCFont; gcv.font = Scr->MenuFont.font->fid; + if (!use_fontset) + {gcm |= GCFont; gcv.font = Scr->MenuFont.font->fid;} Scr->MenuGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); diff --git a/src/gc.h b/src/gc.h index f8440ed..852b618 100644 --- a/src/gc.h +++ b/src/gc.h @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/gc.h,v 1.5 2001/12/14 20:01:07 dawes Exp $ */ /********************************************************************** @@ -63,6 +64,6 @@ in this Software without prior written authorization from The Open Group. #ifndef _GC_ #define _GC_ -extern void CreateGCs(); +extern void CreateGCs( void ); #endif /* _GC_ */ diff --git a/src/gram.y b/src/gram.y index 8530b09..e8a0759 100644 --- a/src/gram.y +++ b/src/gram.y @@ -60,6 +60,8 @@ in this Software without prior written authorization from The Open Group. * 11-Nov-90 Dave Sternlicht Adding SaveColors * 10-Oct-90 David M. Sternlicht Storing saved colors on root * + * $XFree86: xc/programs/twm/gram.y,v 3.9 2002/10/21 13:33:05 alanh Exp $ + * ***********************************************************************/ %{ @@ -71,6 +73,8 @@ in this Software without prior written authorization from The Open Group. #include "util.h" #include "screen.h" #include "parse.h" +#include "add_window.h" +#include "icons.h" #include #include @@ -78,11 +82,14 @@ static char *Action = ""; static char *Name = ""; static MenuRoot *root, *pull = NULL; -static MenuRoot *GetRoot(); +static MenuRoot *GetRoot ( char *name, char *fore, char *back ); +static void GotButton ( int butt, int func ); +static void GotKey ( char *key, int func ); +static void GotTitleButton ( char *bitmapname, int func, Bool rightside ); +static Bool CheckWarpScreenArg ( char *s ); +static Bool CheckWarpRingArg ( char *s ); +static Bool CheckColormapArg ( char *s ); -static Bool CheckWarpScreenArg(), CheckWarpRingArg(); -static Bool CheckColormapArg(); -static void GotButton(), GotKey(), GotTitleButton(); static char *ptr; static name_list **list; static int cont = 0; @@ -90,9 +97,6 @@ static int color; int mods = 0; unsigned int mods_used = (ShiftMask | ControlMask | Mod1Mask); -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 yylineno; %} @@ -120,7 +124,7 @@ extern int yylineno; %type string %type pixmap_list cursor_list color_list save_color_list stmt %type win_color_list iconm_list win_list icon_list function menu -%type noarg sarg error narg squeeze +%type noarg sarg error narg squeeze color_entry %type action button number signed_number full fullkey %start twmrc @@ -184,7 +188,7 @@ stmt : error root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); Scr->Mouse[$1][C_ROOT][0].item = AddToMenu(root,"x",Action, - NULLSTR,$2,NULLSTR,NULLSTR); + NULL,$2,NULLSTR,NULLSTR); } Action = ""; pull = NULL; @@ -250,7 +254,7 @@ stmt : error root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); Scr->DefaultFunction.item = AddToMenu(root,"x",Action, - NULLSTR,$2, NULLSTR, NULLSTR); + NULL,$2, NULLSTR, NULLSTR); } Action = ""; pull = NULL; @@ -259,7 +263,7 @@ stmt : error root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); Scr->WindowFunction.item = AddToMenu(root,"x",Action, - NULLSTR,$2, NULLSTR, NULLSTR); + NULL,$2, NULLSTR, NULLSTR); Action = ""; pull = NULL; } @@ -454,7 +458,7 @@ color_entry : CLKEYWORD string { if (!do_colorlist_keyword ($1, color, ParseError = 1; } } - win_color_list + win_color_list { /* No action */; } | CKEYWORD string { if (!do_color_keyword ($1, color, $2)) { twmrc_error_prefix(); @@ -560,7 +564,7 @@ function_entries: /* Empty */ | function_entries function_entry ; -function_entry : action { AddToMenu(root, "", Action, NULLSTR, $1, +function_entry : action { AddToMenu(root, "", Action, NULL, $1, NULLSTR, NULLSTR); Action = ""; } @@ -650,22 +654,25 @@ string : STRING { ptr = (char *)malloc(strlen($1)+1); RemoveDQuote(ptr); $$ = ptr; } + ; number : NUMBER { $$ = $1; } ; %% -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; + +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++) { @@ -788,7 +795,7 @@ int butt, func; { root = GetRoot(TWM_ROOT, NULLSTR, NULLSTR); Scr->Mouse[butt][i][mods].item = AddToMenu(root,"x",Action, - NULLSTR, func, NULLSTR, NULLSTR); + NULL, func, NULLSTR, NULLSTR); } } Action = ""; @@ -877,6 +884,7 @@ static Bool CheckColormapArg (s) } +void twmrc_error_prefix () { fprintf (stderr, "%s: line %d: ", ProgramName, yylineno); diff --git a/src/iconmgr.c b/src/iconmgr.c index 188495b..f7af30d 100644 --- a/src/iconmgr.c +++ b/src/iconmgr.c @@ -22,6 +22,7 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ +/* $XFree86: xc/programs/twm/iconmgr.c,v 1.6 2001/12/14 20:01:08 dawes Exp $ */ /*********************************************************************** * @@ -32,6 +33,7 @@ in this Software without prior written authorization from The Open Group. * 09-Mar-89 Tom LaStrange File Created * ***********************************************************************/ +/* $XFree86: xc/programs/twm/iconmgr.c,v 1.6 2001/12/14 20:01:08 dawes Exp $ */ #include #include "twm.h" @@ -491,6 +493,8 @@ WList *AddIconManager(tmp_win) XMapWindow(dpy, ip->twm_win->frame); } + if (Active == NULL) Active = tmp; + return (tmp); } @@ -514,7 +518,8 @@ void InsertInIconManager(ip, tmp, tmp_win) { WList *tmp1; int added; - int (*compar)() = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); + int (*compar)(const char *, const char *) + = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); added = FALSE; if (ip->first == NULL) @@ -663,7 +668,8 @@ void SortIconManager(ip) { WList *tmp1, *tmp2; int done; - int (*compar)() = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); + int (*compar)(const char *, const char *) + = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); if (ip == NULL) ip = Active->iconmgr; diff --git a/src/iconmgr.h b/src/iconmgr.h index 90c7073..1a956f0 100644 --- a/src/iconmgr.h +++ b/src/iconmgr.h @@ -22,6 +22,7 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ +/* $XFree86: xc/programs/twm/iconmgr.h,v 1.6 2001/12/14 20:01:08 dawes Exp $ */ /*********************************************************************** * @@ -74,20 +75,20 @@ typedef struct IconMgr extern int iconmgr_textx; extern WList *DownIconManager; +extern int iconifybox_width, iconifybox_height; -extern void CreateIconManagers(); -extern IconMgr *AllocateIconManager(); -extern void MoveIconManager(); -extern void JumpIconManager(); -extern WList *AddIconManager(); -extern void InsertInIconManager(); -extern void RemoveFromIconManager(); -extern void RemoveIconManager(); -extern void ActiveIconManager(); -extern void NotActiveIconManager(); -extern void DrawIconManagerBorder(); -extern void SortIconManager(); -extern void PackIconManager(); - +extern void ActiveIconManager ( WList *active ); +extern WList *AddIconManager ( TwmWindow *tmp_win ); +extern IconMgr *AllocateIconManager ( char *name, char *icon_name, char *geom, int columns ); +extern void CreateIconManagers ( void ); +extern void DrawIconManagerBorder ( WList *tmp ); +extern void InsertInIconManager ( IconMgr *ip, WList *tmp, TwmWindow *tmp_win ); +extern void JumpIconManager ( int dir ); +extern void MoveIconManager ( int dir ); +extern void NotActiveIconManager ( WList *active ); +extern void PackIconManager ( IconMgr *ip ); +extern void RemoveFromIconManager ( IconMgr *ip, WList *tmp ); +extern void RemoveIconManager ( TwmWindow *tmp_win ); +extern void SortIconManager ( IconMgr *ip ); #endif /* _ICONMGR_ */ diff --git a/src/icons.c b/src/icons.c index 32f0ce8..937096b 100644 --- a/src/icons.c +++ b/src/icons.c @@ -22,6 +22,7 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ +/* $XFree86: xc/programs/twm/icons.c,v 1.7 2002/12/10 22:29:54 tsi Exp $ */ /********************************************************************** * @@ -44,11 +45,16 @@ in this Software without prior written authorization from The Open Group. #define iconWidth(w) (Scr->IconBorderWidth * 2 + w->icon_w_width) #define iconHeight(w) (Scr->IconBorderWidth * 2 + w->icon_w_height) -static +static void splitEntry ( IconEntry *ie, int grav1, int grav2, int w, int h ); +static IconEntry * FindIconEntry ( TwmWindow *tmp_win, IconRegion **irp ); +static IconEntry * prevIconEntry ( IconEntry *ie, IconRegion *ir ); +static void mergeEntries ( IconEntry *old, IconEntry *ie ); + +static void splitEntry (ie, grav1, grav2, w, h) - IconEntry *ie; - int grav1, grav2; - int w, h; + IconEntry *ie; + int grav1, grav2; + int w, h; { IconEntry *new; @@ -98,15 +104,17 @@ splitEntry (ie, grav1, grav2, w, h) } } -roundUp (v, multiple) +int +roundUp (int v, int multiple) { return ((v + multiple - 1) / multiple) * multiple; } +void PlaceIcon(tmp_win, def_x, def_y, final_x, final_y) -TwmWindow *tmp_win; -int def_x, def_y; -int *final_x, *final_y; + TwmWindow *tmp_win; + int def_x, def_y; + int *final_x, *final_y; { IconRegion *ir; IconEntry *ie; @@ -157,6 +165,7 @@ FindIconEntry (tmp_win, irp) return 0; } +void IconUp (tmp_win) TwmWindow *tmp_win; { @@ -215,7 +224,7 @@ prevIconEntry (ie, ir) * regions together */ -static +static void mergeEntries (old, ie) IconEntry *old, *ie; { @@ -230,6 +239,7 @@ mergeEntries (old, ie) } } +void IconDown (tmp_win) TwmWindow *tmp_win; { @@ -266,9 +276,11 @@ IconDown (tmp_win) } } +void AddIconRegion(geom, grav1, grav2, stepx, stepy) char *geom; int grav1, grav2; +int stepx, stepy; { IconRegion *ir; int mask; @@ -310,6 +322,7 @@ int grav1, grav2; } #ifdef comment +void FreeIconEntries (ir) IconRegion *ir; { @@ -321,6 +334,8 @@ FreeIconEntries (ir) free ((char *) ie); } } + +void FreeIconRegions() { IconRegion *ir, *tmp; @@ -337,9 +352,10 @@ FreeIconRegions() } #endif +void CreateIconWindow(tmp_win, def_x, def_y) -TwmWindow *tmp_win; -int def_x, def_y; + TwmWindow *tmp_win; + int def_x, def_y; { unsigned long event_mask; unsigned long valuemask; /* mask for create windows */ @@ -480,7 +496,7 @@ int def_x, def_y; attributes.background_pixmap = pm; } - tmp_win->icon_w_width = XTextWidth(Scr->IconFont.font, + tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont, tmp_win->icon_name, strlen(tmp_win->icon_name)); tmp_win->icon_w_width += 6; diff --git a/src/icons.h b/src/icons.h index 43cbab9..678fe3a 100644 --- a/src/icons.h +++ b/src/icons.h @@ -22,6 +22,7 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. * */ +/* $XFree86: xc/programs/twm/icons.h,v 1.5 2001/12/14 20:01:08 dawes Exp $ */ /********************************************************************** * @@ -53,4 +54,13 @@ typedef struct IconEntry short used; }IconEntry; +extern int roundUp ( int v, int multiple ); +extern void PlaceIcon ( TwmWindow *tmp_win, int def_x, int def_y, + int *final_x, int *final_y ); +extern void IconUp ( TwmWindow *tmp_win ); +extern void IconDown ( TwmWindow *tmp_win ); +extern void AddIconRegion ( char *geom, int grav1, int grav2, + int stepx, int stepy ); +extern void CreateIconWindow ( TwmWindow *tmp_win, int def_x, int def_y ); + #endif /* ICONS_H */ diff --git a/src/lex.l b/src/lex.l index 1886f4b..93f3bd7 100644 --- a/src/lex.l +++ b/src/lex.l @@ -59,20 +59,20 @@ in this Software without prior written authorization from The Open Group. * 12-Nov-87 Thomas E. LaStrange File created * ***********************************************************************/ +/* $XFree86: xc/programs/twm/lex.l,v 3.14 2001/12/14 20:01:08 dawes Exp $ */ /* #include */ /* lex already includes stdio.h */ +#include "twm.h" #include "gram.h" +#include "list.h" #include "parse.h" -extern char *ProgramName; -extern int ParseError; #ifdef FLEX_SCANNER int yylineno; #undef YY_INPUT #define YY_INPUT(buf,result,size) ((result) = doinput((buf),(size))) -doinput (buf, size) -char *buf; +int doinput (char *buf, int size) { int c; @@ -85,6 +85,7 @@ char *buf; buf[0] = c; return (1); } +#define YY_NO_UNPUT #endif %} @@ -102,7 +103,7 @@ number [0-9]+ "-" { return MINUS; } "|" { return OR; } -[a-zA-Z\.]+ { int token = parse_keyword (yytext, +[a-zA-Z\.]+ { int token = parse_keyword ((char *)yytext, &yylval.num); if (token == ERRORTOKEN) { twmrc_error_prefix(); @@ -122,7 +123,7 @@ number [0-9]+ return (NUMBER); } \#[^\n]*\n {;} -[\n\t ] {;} +[\r\n\t ] {;} . { twmrc_error_prefix(); fprintf (stderr, @@ -132,7 +133,7 @@ number [0-9]+ } %% #ifndef yywrap -yywrap() { return(1);} +int yywrap() { return(1);} #endif #undef unput diff --git a/src/list.c b/src/list.c index e0f4774..4aabbad 100644 --- a/src/list.c +++ b/src/list.c @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/list.c,v 1.8 2002/09/24 21:00:27 tsi Exp $ */ /********************************************************************** @@ -65,6 +66,7 @@ in this Software without prior written authorization from The Open Group. #include "twm.h" #include "screen.h" #include "gram.h" +#include "util.h" struct name_list_struct { @@ -106,9 +108,9 @@ char *ptr; if (nptr == NULL) { twmrc_error_prefix(); - fprintf (stderr, "unable to allocate %d bytes for name_list\n", - sizeof(name_list)); - Done(); + fprintf (stderr, "unable to allocate %ld bytes for name_list\n", + (unsigned long)sizeof(name_list)); + Done(0); } nptr->next = *list_head; diff --git a/src/list.h b/src/list.h index 8b4cce3..123397c 100644 --- a/src/list.h +++ b/src/list.h @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/list.h,v 1.5 2001/12/14 20:01:08 dawes Exp $ */ /********************************************************************** @@ -63,13 +64,21 @@ in this Software without prior written authorization from The Open Group. #ifndef _LIST_ #define _LIST_ +#include +#include +#include + typedef struct name_list_struct name_list; -extern void AddToList(); -extern char* LookInList(); -extern char* LookInNameList(); -extern int GetColorFromList(); -extern void FreeList(); +extern void AddToList ( name_list **list_head, char *name, char *ptr ); +extern void FreeList ( name_list **list ); + +extern int GetColorFromList ( name_list *list_head, char *name, + XClassHint *class, Pixel *ptr ); +extern char * LookInList ( name_list *list_head, char *name, + XClassHint *class ); +extern char * LookInNameList ( name_list *list_head, char *name ); + #endif /* _LIST_ */ diff --git a/src/menus.c b/src/menus.c index 83fe792..5284f25 100644 --- a/src/menus.c +++ b/src/menus.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/twm/menus.c,v 1.16 2002/10/19 20:04:20 herrb Exp $ */ /*****************************************************************************/ /* @@ -71,14 +72,16 @@ in this Software without prior written authorization from The Open Group. #include "parse.h" #include "gram.h" #include "screen.h" +#include "menus.h" +#include "iconmgr.h" +#include "add_window.h" +#include "icons.h" +#include "session.h" #include -#include #include "version.h" #include #include -extern XEvent Event; - int RootFunction = 0; MenuRoot *ActiveMenu = NULL; /* the active menu */ MenuItem *ActiveItem = NULL; /* the active menu item */ @@ -107,19 +110,15 @@ static struct { } MenuOrigins[MAXMENUDEPTH]; static Cursor LastCursor; -void WarpAlongRing(), WarpToWindow(); - -extern char *Action; -extern int Context; -extern TwmWindow *ButtonWindow, *Tmp_win; -extern XEvent Event, ButtonEvent; -extern char *InitFile; -static void Identify(); +static Bool belongs_to_twm_window ( TwmWindow *t, Window w ); +static void Identify ( TwmWindow *t ); +static void send_clientmessage ( Window w, Atom a, Time timestamp ); #define SHADOWWIDTH 5 /* in pixels */ + /*********************************************************************** * * Procedure: @@ -239,8 +238,8 @@ int CreateTitleButton (name, func, action, menuroot, rightside, append) if (!tb) { fprintf (stderr, - "%s: unable to allocate %d bytes for title button\n", - ProgramName, sizeof(TitleButton)); + "%s: unable to allocate %ld bytes for title button\n", + ProgramName, (unsigned long)sizeof(TitleButton)); return 0; } @@ -372,7 +371,7 @@ void InitTitlebarButtons () } - +void PaintEntry(mr, mi, exposure) MenuRoot *mr; MenuItem *mi; @@ -399,9 +398,9 @@ int exposure; XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset, mr->width, Scr->EntryHeight); - FBF(mi->hi_fore, mi->hi_back, Scr->MenuFont.font->fid); + MyFont_ChangeGC(mi->hi_fore, mi->hi_back, &Scr->MenuFont); - XDrawString(dpy, mr->w, Scr->NormalGC, mi->x, + MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, Scr->NormalGC, mi->x, text_y, mi->item, mi->strlen); gc = Scr->NormalGC; @@ -415,14 +414,15 @@ int exposure; XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset, mr->width, Scr->EntryHeight); - FBF(mi->fore, mi->back, Scr->MenuFont.font->fid); + MyFont_ChangeGC(mi->fore, mi->back, &Scr->MenuFont); gc = Scr->NormalGC; } else gc = Scr->MenuGC; - XDrawString(dpy, mr->w, gc, mi->x, - text_y, mi->item, mi->strlen); + MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, gc, + mi->x, text_y, mi->item, mi->strlen); + } if (mi->func == F_MENU) @@ -459,15 +459,15 @@ int exposure; XDrawLine(dpy, mr->w, Scr->NormalGC, 0, y, mr->width, y); } - FBF(mi->fore, mi->back, Scr->MenuFont.font->fid); + MyFont_ChangeGC(mi->fore, mi->back, &Scr->MenuFont); /* finally render the title */ - XDrawString(dpy, mr->w, Scr->NormalGC, mi->x, + MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, Scr->NormalGC, mi->x, text_y, mi->item, mi->strlen); } } - +void PaintMenu(mr, e) MenuRoot *mr; XEvent *e; @@ -494,6 +494,7 @@ XEvent *e; static Bool fromMenu; +void UpdateMenu() { MenuItem *mi; @@ -751,7 +752,7 @@ AddToMenu(menu, item, action, sub, func, fore, back) tmp->func = func; if (!Scr->HaveFonts) CreateFonts(); - width = XTextWidth(Scr->MenuFont.font, item, tmp->strlen); + width = MyFont_TextWidth(&Scr->MenuFont, item, tmp->strlen); if (width <= 0) width = 1; if (width > menu->width) @@ -780,7 +781,7 @@ AddToMenu(menu, item, action, sub, func, fore, back) } - +void MakeMenus() { MenuRoot *mr; @@ -795,7 +796,7 @@ MakeMenus() } - +void MakeMenu(mr) MenuRoot *mr; { @@ -829,7 +830,7 @@ MenuRoot *mr; cur->x = 5; else { - cur->x = width - XTextWidth(Scr->MenuFont.font, cur->item, + cur->x = width - MyFont_TextWidth(&Scr->MenuFont, cur->item, cur->strlen); cur->x /= 2; } @@ -1000,7 +1001,8 @@ MenuRoot *mr; *********************************************************************** */ -Bool PopUpMenu (menu, x, y, center) +Bool +PopUpMenu (menu, x, y, center) MenuRoot *menu; int x, y; Bool center; @@ -1009,7 +1011,7 @@ Bool PopUpMenu (menu, x, y, center) TwmWindow **WindowNames; TwmWindow *tmp_win2,*tmp_win3; int i; - int (*compar)() = + int (*compar)(const char *, const char *) = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); if (!menu) return False; @@ -1133,7 +1135,7 @@ Bool PopUpMenu (menu, x, y, center) * *********************************************************************** */ - +void PopDownMenu() { MenuRoot *tmp; @@ -1197,7 +1199,8 @@ FindMenuRoot(name) -static Bool belongs_to_twm_window (t, w) +static Bool +belongs_to_twm_window (t, w) register TwmWindow *t; register Window w; { @@ -1228,12 +1231,8 @@ static Bool belongs_to_twm_window (t, w) */ -extern int AddingX; -extern int AddingY; -extern int AddingW; -extern int AddingH; - -void resizeFromCenter(w, tmp_win) +void +resizeFromCenter(w, tmp_win) Window w; TwmWindow *tmp_win; { @@ -1245,8 +1244,8 @@ void resizeFromCenter(w, tmp_win) bw2 = tmp_win->frame_bw * 2; AddingW = tmp_win->attr.width + bw2; AddingH = tmp_win->attr.height + tmp_win->title_height + bw2; - width = (SIZE_HINDENT + XTextWidth (Scr->SizeFont.font, - tmp_win->name, namelen)); + width = (SIZE_HINDENT + MyFont_TextWidth (&Scr->SizeFont, + tmp_win->name, namelen)); height = Scr->SizeFont.height + SIZE_VINDENT * 2; XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, (unsigned int *)&DragWidth, (unsigned int *)&DragHeight, @@ -1258,11 +1257,11 @@ void resizeFromCenter(w, tmp_win) &AddingX, &AddingY, &JunkMask); /***** Scr->SizeStringOffset = width + - XTextWidth(Scr->SizeFont.font, ": ", 2); + MyFont_TextWidth(&Scr->SizeFont, ": ", 2); XResizeWindow (dpy, Scr->SizeWindow, Scr->SizeStringOffset + Scr->SizeStringWidth, height); - XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC, width, - SIZE_VINDENT + Scr->SizeFont.font->ascent, + MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, Scr->NormalGC, + width, SIZE_VINDENT + Scr->SizeFont.ascent, ": ", 2); *****/ lastx = -10000; @@ -1358,7 +1357,6 @@ WarpThere(t) return false; } -extern int MovedFromKeyPress; int ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) @@ -1380,7 +1378,6 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) int do_next_action = TRUE; int moving_icon = FALSE; Bool fromtitlebar = False; - extern int ConstrainedMoveTime; RootFunction = 0; if (Cancel) @@ -1404,6 +1401,8 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) case F_WARPTO: case F_WARPRING: case F_WARPTOICONMGR: + case F_WARPNEXT: + case F_WARPPREV: case F_COLORMAP: break; default: @@ -1426,8 +1425,6 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) case F_RESTART: { - extern SmcConn smcConn; - XSync (dpy, 0); Reborder (eventp->xbutton.time); XSync (dpy, 0); @@ -2016,7 +2013,8 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) InstallWindowColormaps (0, tmp_win); if (tmp_win->hilite_w) XMapWindow (dpy, tmp_win->hilite_w); SetBorder (tmp_win, True); - SetFocus (tmp_win, eventp->xbutton.time); + if (!tmp_win->wmhints || tmp_win->wmhints->input) + SetFocus (tmp_win, eventp->xbutton.time); Scr->FocusRoot = FALSE; Scr->Focus = tmp_win; } @@ -2089,7 +2087,7 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) XFree (ptr); ptr = ExpandFilename(tmp); if (ptr) { - fd = open (ptr, 0); + fd = open (ptr, O_RDONLY); if (fd >= 0) { count = read (fd, buff, MAX_FILE_SIZE - 1); if (count > 0) XStoreBytes (dpy, buff, count); @@ -2135,6 +2133,40 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) } break; + case F_WARPPREV: + case F_WARPNEXT: + { + register TwmWindow *t; + static TwmWindow *savedwarp = NULL; + TwmWindow *of, *l, *n; + int c=0; + +#define wseq(w) (func == F_WARPNEXT ? (w)->next : (w)->prev) +#define nwin(w) ((w) && (n=wseq(w)) != NULL && n != &Scr->TwmRoot ? n : l) +#define bwin(w) (!(w)||(w)->iconmgr||(w)==of||!(Scr->WarpUnmapped||(w)->mapped)) + + of=(Scr->Focus ? Scr->Focus : &Scr->TwmRoot); + + for(t=Scr->TwmRoot.next; t; t=t->next) if(!bwin(t)) break; + if(!t) break; /* no windows we can use */ + + if(func == F_WARPPREV) for(l=of; l->next; l=l->next) ; + else l = Scr->TwmRoot.next; + + for(t=of; bwin(t) && c < 2; t=nwin(t)) if(t == of) c++; + + if(bwin(t) || c >= 2) Bell(XkbBI_MinorError,0,None); + else { + if(of && of == savedwarp) { + Iconify(of, 0, 0); + savedwarp = NULL; + } + if(!t->mapped) savedwarp = t; else savedwarp = NULL; + WarpThere(t); + } + break; + } + case F_WARPTO: { register TwmWindow *t; @@ -2216,7 +2248,7 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) case F_FILE: action = ExpandFilename(action); - fd = open(action, 0); + fd = open(action, O_RDONLY); if (fd >= 0) { count = read(fd, buff, MAX_FILE_SIZE - 1); @@ -2271,7 +2303,7 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) break; case F_QUIT: - Done(); + Done(0); break; case F_PRIORITY: @@ -2282,6 +2314,11 @@ ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) (void)XSyncSetPriority(dpy, tmp_win->w, atoi(action)); } break; + case F_STARTWM: + execlp("/bin/sh", "sh", "-c", action, (void *)NULL); + fprintf (stderr, "%s: unable to start: %s\n", ProgramName, *Argv); + break; + } if (ButtonPressed == -1) XUngrabPointer(dpy, CurrentTime); @@ -2334,7 +2371,7 @@ Cursor cursor; * *********************************************************************** */ - +void ReGrab() { XGrabPointer(dpy, Scr->Root, True, @@ -2356,7 +2393,7 @@ ReGrab() * *********************************************************************** */ - +Bool NeedToDefer(root) MenuRoot *root; { @@ -2406,7 +2443,8 @@ MenuRoot *root; */ #if defined(sun) && defined(SVR4) -static int System (s) +static int +System (s) char *s; { int pid, status; @@ -2486,6 +2524,7 @@ FocusOnRoot() Scr->FocusRoot = TRUE; } +void DeIconify(tmp_win) TwmWindow *tmp_win; { @@ -2563,7 +2602,7 @@ TwmWindow *tmp_win; } - +void Iconify(tmp_win, def_x, def_y) TwmWindow *tmp_win; int def_x, def_y; @@ -2657,8 +2696,9 @@ int def_x, def_y; -static void Identify (t) -TwmWindow *t; +static void +Identify (t) + TwmWindow *t; { int i, n, twidth, width, height; int x, y; @@ -2700,7 +2740,7 @@ TwmWindow *t; width = 1; for (i = 0; i < n; i++) { - twidth = XTextWidth(Scr->DefaultFont.font, Info[i], + twidth = MyFont_TextWidth(&Scr->DefaultFont, Info[i], strlen(Info[i])); if (twidth > width) width = twidth; @@ -2727,10 +2767,10 @@ TwmWindow *t; } - +void SetMapStateProp(tmp_win, state) -TwmWindow *tmp_win; -int state; + TwmWindow *tmp_win; + int state; { unsigned long data[2]; /* "suggested" by ICCCM version 1 */ @@ -2744,7 +2784,8 @@ int state; -Bool GetWMState (w, statep, iwp) +Bool +GetWMState (w, statep, iwp) Window w; int *statep; Window *iwp; @@ -2771,7 +2812,7 @@ Bool GetWMState (w, statep, iwp) } - +void WarpToScreen (n, inc) int n, inc; { @@ -2816,7 +2857,7 @@ WarpToScreen (n, inc) /* * BumpWindowColormap - rotate our internal copy of WM_COLORMAP_WINDOWS */ - +void BumpWindowColormap (tmp, inc) TwmWindow *tmp; int inc; @@ -2862,7 +2903,7 @@ BumpWindowColormap (tmp, inc) } - +void HideIconManager () { SetMapStateProp (Scr->iconmgr.twm_win, WithdrawnState); @@ -2875,7 +2916,7 @@ HideIconManager () - +void SetBorder (tmp, onoroff) TwmWindow *tmp; Bool onoroff; @@ -2894,7 +2935,7 @@ SetBorder (tmp, onoroff) } - +void DestroyMenu (menu) MenuRoot *menu; { @@ -2919,7 +2960,8 @@ DestroyMenu (menu) /* * warping routines */ -void WarpAlongRing (ev, forward) +void +WarpAlongRing (ev, forward) XButtonEvent *ev; Bool forward; { @@ -2966,7 +3008,8 @@ void WarpAlongRing (ev, forward) -void WarpToWindow (t) +void +WarpToWindow (t) TwmWindow *t; { int x, y; @@ -2996,7 +3039,8 @@ void WarpToWindow (t) * data[0] message atom * data[1] time stamp */ -static void send_clientmessage (w, a, timestamp) +static void +send_clientmessage (w, a, timestamp) Window w; Atom a; Time timestamp; @@ -3012,6 +3056,7 @@ static void send_clientmessage (w, a, timestamp) XSendEvent (dpy, w, False, 0L, (XEvent *) &ev); } +void SendDeleteWindowMessage (tmp, timestamp) TwmWindow *tmp; Time timestamp; @@ -3019,6 +3064,7 @@ SendDeleteWindowMessage (tmp, timestamp) send_clientmessage (tmp->w, _XA_WM_DELETE_WINDOW, timestamp); } +void SendSaveYourselfMessage (tmp, timestamp) TwmWindow *tmp; Time timestamp; @@ -3026,7 +3072,7 @@ SendSaveYourselfMessage (tmp, timestamp) send_clientmessage (tmp->w, _XA_WM_SAVE_YOURSELF, timestamp); } - +void SendTakeFocusMessage (tmp, timestamp) TwmWindow *tmp; Time timestamp; diff --git a/src/menus.h b/src/menus.h index f7729f9..55e1a4c 100644 --- a/src/menus.h +++ b/src/menus.h @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/menus.h,v 1.6 2001/12/14 20:01:09 dawes Exp $ */ /*********************************************************************** @@ -147,6 +148,9 @@ extern int ConstMoveXL; extern int ConstMoveXR; extern int ConstMoveYT; extern int ConstMoveYB; +extern int menuFromFrameOrWindowOrTitlebar; +extern int ResizeOrigX; +extern int ResizeOrigY; #define MAXMENUDEPTH 10 /* max number of nested menus */ extern int MenuDepth; @@ -163,16 +167,40 @@ extern int MenuDepth; #define COLORMAP_PREV "prev" #define COLORMAP_DEFAULT "default" -extern void InitTitlebarButtons(); -extern void InitMenus(); -extern MenuRoot *NewMenuRoot(); -extern MenuItem *AddToMenu(); -extern Bool PopUpMenu(); -extern MenuRoot *FindMenuRoot(); -extern Bool AddFuncKey(); -extern int ExecuteFunction(); -extern int DeferExecution(); -extern void Execute(); -extern void FocusOnRoot(); +extern void InitMenus ( void ); +extern Bool AddFuncKey ( char *name, int cont, int mods, int func, char *win_name, char *action ); +extern int CreateTitleButton ( char *name, int func, char *action, MenuRoot *menuroot, Bool rightside, Bool append ); +extern void InitTitlebarButtons ( void ); +extern void PaintEntry ( MenuRoot *mr, MenuItem *mi, int exposure ); +extern void PaintMenu ( MenuRoot *mr, XEvent *e ); +extern void UpdateMenu ( void ); +extern MenuRoot * NewMenuRoot ( char *name ); +extern MenuItem * AddToMenu ( MenuRoot *menu, char *item, char *action, MenuRoot *sub, int func, char *fore, char *back ); +extern void MakeMenus ( void ); +extern void MakeMenu ( MenuRoot *mr ); +extern Bool PopUpMenu ( MenuRoot *menu, int x, int y, Bool center ); +extern void PopDownMenu ( void ); +extern MenuRoot * FindMenuRoot ( char *name ); +extern void resizeFromCenter ( Window w, TwmWindow *tmp_win ); +extern int WarpThere ( TwmWindow * t ); +extern int ExecuteFunction ( int func, char *action, Window w, TwmWindow *tmp_win, XEvent *eventp, int context, int pulldown ); +extern int DeferExecution ( int context, int func, Cursor cursor ); +extern void ReGrab ( void ); +extern Bool NeedToDefer ( MenuRoot *root ); +extern void Execute ( char *s ); +extern void FocusOnRoot ( void ); +extern void DeIconify ( TwmWindow *tmp_win ); +extern void Iconify ( TwmWindow *tmp_win, int def_x, int def_y ); +extern void SetMapStateProp ( TwmWindow *tmp_win, int state ); +extern void WarpToScreen ( int n, int inc ); +extern void BumpWindowColormap ( TwmWindow *tmp, int inc ); +extern void HideIconManager ( void ); +extern void SetBorder ( TwmWindow *tmp, Bool onoroff ); +extern void DestroyMenu ( MenuRoot *menu ); +extern void WarpAlongRing ( XButtonEvent *ev, Bool forward ); +extern void WarpToWindow ( TwmWindow *t ); +extern void SendDeleteWindowMessage ( TwmWindow *tmp, Time timestamp ); +extern void SendSaveYourselfMessage ( TwmWindow *tmp, Time timestamp ); +extern void SendTakeFocusMessage ( TwmWindow *tmp, Time timestamp ); #endif /* _MENUS_ */ diff --git a/src/parse.c b/src/parse.c index 7281d0b..c3ebc6e 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/twm/parse.c,v 1.16 2002/12/10 22:29:55 tsi Exp $ */ /*****************************************************************************/ /* @@ -81,21 +82,20 @@ static FILE *twmrc; static int ptr = 0; static int len = 0; static char buff[BUF_LEN+1]; -static char overflowbuff[20]; /* really only need one */ +static unsigned char overflowbuff[20]; /* really only need one */ static int overflowlen; static char **stringListSource, *currentString; -static int ParseUsePPosition(); + +static int doparse ( int (*ifunc)(void), char *srctypename, char *srcname ); +static int twmFileInput ( void ); +static int twmStringListInput ( void ); +static int ParseUsePPosition ( char *s ); extern int yylineno; -extern int mods; int ConstrainedMoveTime = 400; /* milliseconds, event times */ -static int twmFileInput(), twmStringListInput(); -void twmUnput(); -int (*twmInputFunc)(); - -extern char *defTwmrc[]; /* default bindings */ +int (*twmInputFunc)(void); /*********************************************************************** @@ -110,7 +110,7 @@ extern char *defTwmrc[]; /* default bindings */ */ static int doparse (ifunc, srctypename, srcname) - int (*ifunc)(); + int (*ifunc)(void); char *srctypename; char *srcname; { @@ -264,8 +264,6 @@ static int twmFileInput() if (fgets(buff, BUF_LEN, twmrc) == NULL) return 0; - yylineno++; - ptr = 0; len = strlen(buff); } @@ -305,7 +303,7 @@ void twmUnput (c) int c; { if (overflowlen < sizeof overflowbuff) { - overflowbuff[overflowlen++] = (char) c; + overflowbuff[overflowlen++] = (unsigned char) c; } else { twmrc_error_prefix (); fprintf (stderr, "unable to unput character (%d)\n", @@ -327,6 +325,7 @@ void twmUnput (c) void TwmOutput(c) + int c; { putchar(c); } @@ -495,6 +494,7 @@ static TwmKeyword keytable[] = { { "f.showiconmgr", FKEYWORD, F_SHOWLIST }, { "f.sorticonmgr", FKEYWORD, F_SORTICONMGR }, { "f.source", FSKEYWORD, F_BEEP }, /* XXX - don't work */ + { "f.startwm", FSKEYWORD, F_STARTWM }, { "f.title", FKEYWORD, F_TITLE }, { "f.topzoom", FKEYWORD, F_TOPZOOM }, { "f.twmrc", FKEYWORD, F_RESTART }, @@ -503,6 +503,8 @@ static TwmKeyword keytable[] = { { "f.version", FKEYWORD, F_VERSION }, { "f.vlzoom", FKEYWORD, F_LEFTZOOM }, { "f.vrzoom", FKEYWORD, F_RIGHTZOOM }, + { "f.warpnext", FKEYWORD, F_WARPNEXT }, + { "f.warpprev", FKEYWORD, F_WARPPREV }, { "f.warpring", FSKEYWORD, F_WARPRING }, { "f.warpto", FSKEYWORD, F_WARPTO }, { "f.warptoiconmgr", FSKEYWORD, F_WARPTOICONMGR }, @@ -977,6 +979,7 @@ int do_color_keyword (keyword, colormode, s) /* * put_pixel_on_root() Save a pixel value in twm root window color property. */ +void put_pixel_on_root(pixel) Pixel pixel; { @@ -1003,6 +1006,7 @@ put_pixel_on_root(pixel) /* * do_string_savecolor() save a color from a string in the twmrc file. */ +void do_string_savecolor(colormode, s) int colormode; char *s; @@ -1018,6 +1022,7 @@ do_string_savecolor(colormode, s) typedef struct _cnode {int i; struct _cnode *next;} Cnode, *Cptr; Cptr chead = NULL; +void do_var_savecolor(key) int key; { @@ -1038,7 +1043,8 @@ int key; * assign_var_savecolor() traverse the var save color list placeing the pixels * in the root window property. */ -void assign_var_savecolor() +void +assign_var_savecolor() { Cptr cp = chead; while (cp != NULL) { @@ -1085,7 +1091,8 @@ void assign_var_savecolor() } } -static int ParseUsePPosition (s) +static int +ParseUsePPosition (s) register char *s; { XmuCopyISOLatin1Lowered (s, s); @@ -1103,6 +1110,7 @@ static int ParseUsePPosition (s) } +void do_squeeze_entry (list, name, justify, num, denom) name_list **list; /* squeeze or dont-squeeze list */ char *name; /* window name */ @@ -1137,8 +1145,8 @@ do_squeeze_entry (list, name, justify, num, denom) if (!sinfo) { twmrc_error_prefix(); - fprintf (stderr, "unable to allocate %d bytes for squeeze info\n", - sizeof(SqueezeInfo)); + fprintf (stderr, "unable to allocate %ld bytes for squeeze info\n", + (unsigned long)sizeof(SqueezeInfo)); return; } sinfo->justify = justify; diff --git a/src/parse.h b/src/parse.h index 68443c4..f1e096b 100644 --- a/src/parse.h +++ b/src/parse.h @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/twm/parse.h,v 1.11 2001/12/14 20:01:09 dawes Exp $ */ /*****************************************************************************/ /* @@ -63,10 +64,31 @@ in this Software without prior written authorization from The Open Group. #ifndef _PARSE_ #define _PARSE_ -extern int ParseTwmrc(), ParseStringList(); -extern int (*twmInputFunc)(); -extern void twmUnput(); -extern void TwmOutput(); +#include "list.h" + +extern void assign_var_savecolor ( void ); +extern int do_single_keyword ( int keyword ); +extern int do_string_keyword ( int keyword, char *s ); +extern int do_number_keyword ( int keyword, int num ); +extern name_list **do_colorlist_keyword ( int keyword, int colormode, + char *s ); +extern int do_color_keyword ( int keyword, int colormode, char *s ); +void put_pixel_on_root ( Pixel pixel ); +extern void do_string_savecolor ( int colormode, char *s ); +extern void do_var_savecolor ( int key ); +extern int ParseStringList ( char **sl ); +extern int ParseTwmrc ( char *filename ); +extern int parse_keyword ( char *s, int *nump ); +extern void TwmOutput ( int c ); +extern void twmUnput ( int c ); +extern void do_squeeze_entry ( name_list **list, char *name, int justify, + int num, int denom ); + + +extern int (*twmInputFunc)(void); +extern int ConstrainedMoveTime; +extern char *defTwmrc[]; +extern int mods; #define F_NOP 0 #define F_BEEP 1 @@ -116,6 +138,8 @@ extern void TwmOutput(); #define F_HIDELIST 45 #define F_MENU 101 /* string */ +#define F_WARPNEXT 112 /* string */ +#define F_WARPPREV 113 /* string */ #define F_WARPTO 102 /* string */ #define F_WARPTOICONMGR 103 /* string */ #define F_WARPRING 104 /* string */ @@ -126,6 +150,7 @@ extern void TwmOutput(); #define F_WARPTOSCREEN 109 /* string */ #define F_COLORMAP 110 /* string */ #define F_PRIORITY 111 /* string */ +#define F_STARTWM 114 /* string */ #define D_NORTH 1 #define D_SOUTH 2 diff --git a/src/resize.c b/src/resize.c index 5c07ce9..113cb45 100644 --- a/src/resize.c +++ b/src/resize.c @@ -60,13 +60,17 @@ in this Software without prior written authorization from The Open Group. * ***********************************************************************/ +/* $XFree86: xc/programs/twm/resize.c,v 1.8 2001/12/14 20:01:09 dawes Exp $ */ + #include #include "twm.h" #include "parse.h" #include "util.h" #include "resize.h" +#include "iconmgr.h" #include "add_window.h" #include "screen.h" +#include "events.h" #define MINHEIGHT 0 /* had been 32 */ #define MINWIDTH 0 /* had been 60 */ @@ -92,9 +96,8 @@ static int last_width; static int last_height; -static void do_auto_clamp (tmp_win, evp) - TwmWindow *tmp_win; - XEvent *evp; +static void +do_auto_clamp (TwmWindow *tmp_win, XEvent *evp) { Window junkRoot; int x, y, h, v, junkbw; @@ -554,11 +557,11 @@ int height; (void) sprintf (str, " %4d x %-4d ", dwidth, dheight); XRaiseWindow(dpy, Scr->SizeWindow); - FBF(Scr->DefaultC.fore, Scr->DefaultC.back, Scr->SizeFont.font->fid); - XDrawImageString (dpy, Scr->SizeWindow, Scr->NormalGC, - Scr->SizeStringOffset, - Scr->SizeFont.font->ascent + SIZE_VINDENT, - str, 13); + MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back, &Scr->SizeFont); + MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, + Scr->NormalGC, Scr->SizeStringOffset, + Scr->SizeFont.ascent + SIZE_VINDENT, + str, 13); } /*********************************************************************** @@ -618,10 +621,10 @@ TwmWindow *tmp_win; MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0); XUnmapWindow(dpy, Scr->SizeWindow); ConstrainSize (tmp_win, &dragWidth, &dragHeight); - AddingX = dragx; - AddingY = dragy; - AddingW = dragWidth + (2 * tmp_win->frame_bw); - AddingH = dragHeight + (2 * tmp_win->frame_bw); + AddingX = dragx - tmp_win->frame_bw; + AddingY = dragy - tmp_win->frame_bw; + AddingW = dragWidth;/* + (2 * tmp_win->frame_bw);*/ + AddingH = dragHeight;/* + (2 * tmp_win->frame_bw);*/ SetupWindow (tmp_win, AddingX, AddingY, AddingW, AddingH, -1); } @@ -661,7 +664,7 @@ TwmWindow *tmp_win; * borrowed from uwm's CheckConsistency routine. * ***********************************************************************/ - +void ConstrainSize (tmp_win, widthp, heightp) TwmWindow *tmp_win; int *widthp, *heightp; @@ -1080,6 +1083,7 @@ int flag; XUngrabServer (dpy); } +void SetFrameShape (tmp) TwmWindow *tmp; { diff --git a/src/resize.h b/src/resize.h index 742045e..395f2ec 100644 --- a/src/resize.h +++ b/src/resize.h @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/resize.h,v 1.5 2001/12/14 20:01:10 dawes Exp $ */ /********************************************************************** @@ -63,15 +64,19 @@ in this Software without prior written authorization from The Open Group. #ifndef _RESIZE_ #define _RESIZE_ -extern void StartResize(); -extern void AddStartResize(); -extern void DoResize(); -extern void DisplaySize(); -extern void EndResize(); -extern void AddEndResize(); -extern void SetupWindow(); -extern void SetupFrame(); +extern void AddEndResize ( TwmWindow *tmp_win ); +extern void AddStartResize ( TwmWindow *tmp_win, int x, int y, int w, int h ); +extern void ConstrainSize ( TwmWindow *tmp_win, int *widthp, int *heightp ); +extern void DisplaySize ( TwmWindow *tmp_win, int width, int height ); +extern void DoResize ( int x_root, int y_root, TwmWindow *tmp_win ); +extern void EndResize ( void ); +extern void fullzoom ( TwmWindow *tmp_win, int flag ); +extern void MenuDoResize ( int x_root, int y_root, TwmWindow *tmp_win ); +extern void MenuEndResize ( TwmWindow *tmp_win ); +extern void MenuStartResize ( TwmWindow *tmp_win, int x, int y, int w, int h ); +extern void SetFrameShape ( TwmWindow *tmp ); +extern void SetupFrame ( TwmWindow *tmp_win, int x, int y, int w, int h, int bw, Bool sendEvent ); +extern void SetupWindow ( TwmWindow *tmp_win, int x, int y, int w, int h, int bw ); +extern void StartResize ( XEvent *evp, TwmWindow *tmp_win, Bool fromtitlebar ); #endif /* _RESIZE_ */ - -extern void fullzoom(); diff --git a/src/screen.h b/src/screen.h index c47bc70..b5f7eb7 100644 --- a/src/screen.h +++ b/src/screen.h @@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group. * 11-3-88 Dave Payne, Apple Computer File created * ***********************************************************************/ +/* $XFree86: xc/programs/twm/screen.h,v 1.5 2001/12/14 20:01:10 dawes Exp $ */ #ifndef _SCREEN_ #define _SCREEN_ @@ -83,7 +84,7 @@ typedef struct ScreenInfo Pixmap UnknownPm; /* the unknown icon pixmap */ Pixmap siconifyPm; /* the icon manager iconify pixmap */ Pixmap pullPm; /* pull right menu icon */ - int pullW, pullH; /* size of pull right menu icon */ + unsigned int pullW, pullH; /* size of pull right menu icon */ Pixmap hilitePm; /* focus highlight window background */ int hilite_pm_width, hilite_pm_height; /* cache the size */ diff --git a/src/session.c b/src/session.c index 992f8f2..a4db1f6 100644 --- a/src/session.c +++ b/src/session.c @@ -25,6 +25,7 @@ in this Software without prior written authorization from The Open Group. Author: Ralph Mor, X Consortium ******************************************************************************/ +/* $XFree86: xc/programs/twm/session.c,v 3.8 2001/12/14 20:01:10 dawes Exp $ */ #include @@ -47,6 +48,9 @@ Author: Ralph Mor, X Consortium #endif #endif #endif /* PATH_MAX */ +#ifdef HAS_MKSTEMP +#include +#endif #include #include @@ -54,6 +58,7 @@ Author: Ralph Mor, X Consortium #include #include "twm.h" #include "screen.h" +#include "session.h" SmcConn smcConn = NULL; XtInputId iceInputId; @@ -64,6 +69,11 @@ Bool sent_save_done = 0; #define SAVEFILE_VERSION 2 +#ifndef HAS_MKSTEMP +static char *unique_filename ( char *path, char *prefix ); +#else +static char *unique_filename ( char *path, char *prefix, int *pFd ); +#endif char * @@ -127,11 +137,7 @@ Window window; int -write_byte (file, b) - -FILE *file; -unsigned char b; - +write_byte (FILE *file, unsigned char b) { if (fwrite ((char *) &b, 1, 1, file) != 1) return 0; @@ -140,11 +146,7 @@ unsigned char b; int -write_ushort (file, s) - -FILE *file; -unsigned short s; - +write_ushort (FILE *file, unsigned short s) { unsigned char file_short[2]; @@ -157,11 +159,7 @@ unsigned short s; int -write_short (file, s) - -FILE *file; -short s; - +write_short (FILE *file, short s) { unsigned char file_short[2]; @@ -415,12 +413,8 @@ char *windowRole; int -ReadWinConfigEntry (configFile, version, pentry) - -FILE *configFile; -unsigned short version; -TWMWinConfigEntry **pentry; - +ReadWinConfigEntry (FILE *configFile, unsigned short version, + TWMWinConfigEntry **pentry) { TWMWinConfigEntry *entry; unsigned char byte; @@ -721,13 +715,21 @@ Bool *height_ever_changed_by_user; +#ifndef HAS_MKSTEMP static char * unique_filename (path, prefix) - char *path; char *prefix; +#else +static char * +unique_filename (path, prefix, pFd) +char *path; +char *prefix; +int *pFd; +#endif { +#ifndef HAS_MKSTEMP #ifndef X_NOT_POSIX return ((char *) tempnam (path, prefix)); #else @@ -745,6 +747,19 @@ char *prefix; else return (NULL); #endif +#else + char tempFile[PATH_MAX]; + char *ptr; + + sprintf (tempFile, "%s/%sXXXXXX", path, prefix); + ptr = (char *)malloc(strlen(tempFile) + 1); + if (ptr != NULL) + { + strcpy(ptr, tempFile); + *pFd = mkstemp(ptr); + } + return ptr; +#endif } @@ -769,6 +784,9 @@ SmPointer clientData; char discardCommand[80]; int numVals, i; static int first_time = 1; +#ifdef HAS_MKSTEMP + int fd; +#endif if (first_time) { @@ -782,7 +800,7 @@ SmPointer clientData; prop1val.value = Argv[0]; prop1val.length = strlen (Argv[0]); - sprintf (userId, "%d", getuid()); + sprintf (userId, "%ld", (long)getuid()); prop2.name = SmUserID; prop2.type = SmARRAY8; prop2.num_vals = 1; @@ -813,12 +831,19 @@ SmPointer clientData; if (!path) path = "."; } - +#ifndef HAS_MKSTEMP if ((filename = unique_filename (path, ".twm")) == NULL) goto bad; if (!(configFile = fopen (filename, "wb"))) goto bad; +#else + if ((filename = unique_filename (path, ".twm", &fd)) == NULL) + goto bad; + + if (!(configFile = fdopen(fd, "wb"))) + goto bad; +#endif if (!write_ushort (configFile, SAVEFILE_VERSION)) goto bad; @@ -952,7 +977,7 @@ SmPointer clientData; { SmcCloseConnection (smcConn, 0, NULL); XtRemoveInput (iceInputId); - Done(); + Done(0); } diff --git a/src/system.twmrc b/src/system.twmrc index 421f8d5..437541d 100644 --- a/src/system.twmrc +++ b/src/system.twmrc @@ -9,6 +9,8 @@ # users were accustomed to uwm, the defaults could be set up not to decorate # any windows and to use meta-keys. # +# $XFree86: xc/programs/twm/system.twmrc,v 1.4 2001/01/17 23:45:08 dawes Exp $ +# NoGrabServer RestartPreviousState @@ -81,6 +83,8 @@ menu "defops" "Show Iconmgr" f.showiconmgr "Hide Iconmgr" f.hideiconmgr "" f.nop +"Xterm" f.exec "exec xterm &" +"" f.nop "Kill" f.destroy "Delete" f.delete "" f.nop diff --git a/src/twm.c b/src/twm.c index 900acc0..aa65e19 100644 --- a/src/twm.c +++ b/src/twm.c @@ -59,11 +59,13 @@ in this Software without prior written authorization from The Open Group. * 27-Oct-87 Thomas E. LaStrange File created * 10-Oct-90 David M. Sternlicht Storing saved colors on root ***********************************************************************/ +/* $XFree86: xc/programs/twm/twm.c,v 3.12 2001/12/14 20:01:10 dawes Exp $ */ #include #include #include #include "twm.h" +#include "iconmgr.h" #include "add_window.h" #include "gc.h" #include "parse.h" @@ -73,14 +75,18 @@ in this Software without prior written authorization from The Open Group. #include "util.h" #include "gram.h" #include "screen.h" -#include "iconmgr.h" +#include "parse.h" +#include "session.h" #include #include #include +#include +#include +#include XtAppContext appContext; /* Xt application context */ -Display *dpy; /* which display are we talking to */ +Display *dpy = NULL; /* which display are we talking to */ Window ResizeWindow; /* the window we are resizing */ int MultiScreen = TRUE; /* try for more than one screen? */ @@ -93,10 +99,11 @@ ScreenInfo **ScreenList; /* structures for each screen */ ScreenInfo *Scr = NULL; /* the cur and prev screens */ int PreviousScreen; /* last screen that we were on */ int FirstScreen; /* TRUE ==> first screen of display */ +volatile Bool TimeToYield = FALSE; /* TRUE ==> exit requested */ Bool PrintErrorMessages = False; /* controls error messages */ static int RedirectError; /* TRUE ==> another window manager running */ -static int CatchRedirectError(); /* for settting RedirectError */ -static int TwmErrorHandler(); /* for everything else */ +static int TwmErrorHandler ( Display *dpy, XErrorEvent *event ); /* for settting RedirectError */ +static int CatchRedirectError ( Display *dpy, XErrorEvent *event ); /* for everything else */ char Info[INFO_LINES][INFO_SIZE]; /* info strings to print */ int InfoLines; char *InitFile = NULL; @@ -131,16 +138,15 @@ unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; char *ProgramName; int Argc; char **Argv; -char **Environ; Bool RestartPreviousState = False; /* try to restart in previous state */ unsigned long black, white; -extern void assign_var_savecolor(); - Atom TwmAtoms[11]; +Bool use_fontset; /* use XFontSet-related functions or not */ + /* don't change the order of these strings */ static char* atom_names[11] = { "_MIT_PRIORITY_COLORS", @@ -164,10 +170,8 @@ static char* atom_names[11] = { *********************************************************************** */ -main(argc, argv, environ) - int argc; - char **argv; - char **environ; +int +main(int argc, char *argv[]) { Window root, parent, *children; unsigned int nchildren; @@ -176,15 +180,14 @@ main(argc, argv, environ) unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ int numManaged, firstscrn, lastscrn, scrnum; - extern ColormapWindow *CreateColormapWindow(); int zero = 0; char *restore_filename = NULL; char *client_id = NULL; + char *loc; ProgramName = argv[0]; Argc = argc; Argv = argv; - Environ = environ; for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { @@ -223,6 +226,14 @@ main(argc, argv, environ) exit (1); } + loc = setlocale(LC_ALL, ""); + if (!loc || !strcmp(loc, "C") || !strcmp(loc, "POSIX") || + !XSupportsLocale()) { + use_fontset = False; + } else { + use_fontset = True; + } + #define newhandler(sig) \ if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, Done) @@ -563,7 +574,7 @@ main(argc, argv, environ) (Visual *) CopyFromParent, valuemask, &attributes); - Scr->SizeStringWidth = XTextWidth (Scr->SizeFont.font, + Scr->SizeStringWidth = MyFont_TextWidth (&Scr->SizeFont, " 8888 x 8888 ", 13); valuemask = (CWBorderPixel | CWBackPixel | CWBitGravity); attributes.bit_gravity = NorthWestGravity; @@ -595,6 +606,7 @@ main(argc, argv, environ) HandlingEvents = TRUE; InitEvents(); HandleEvents(); + exit(0); } /*********************************************************************** @@ -605,6 +617,7 @@ main(argc, argv, environ) *********************************************************************** */ +void InitVariables() { FreeList(&Scr->BorderColorL); @@ -731,21 +744,27 @@ InitVariables() #define DEFAULT_FAST_FONT "fixed" Scr->TitleBarFont.font = NULL; + Scr->TitleBarFont.fontset = NULL; Scr->TitleBarFont.name = DEFAULT_NICE_FONT; Scr->MenuFont.font = NULL; + Scr->MenuFont.fontset = NULL; Scr->MenuFont.name = DEFAULT_NICE_FONT; Scr->IconFont.font = NULL; + Scr->IconFont.fontset = NULL; Scr->IconFont.name = DEFAULT_NICE_FONT; Scr->SizeFont.font = NULL; + Scr->SizeFont.fontset = NULL; Scr->SizeFont.name = DEFAULT_FAST_FONT; Scr->IconManagerFont.font = NULL; + Scr->IconManagerFont.fontset = NULL; Scr->IconManagerFont.name = DEFAULT_NICE_FONT; Scr->DefaultFont.font = NULL; + Scr->DefaultFont.fontset = NULL; Scr->DefaultFont.name = DEFAULT_FAST_FONT; } - +void CreateFonts () { GetFont(&Scr->TitleBarFont); @@ -757,7 +776,7 @@ CreateFonts () Scr->HaveFonts = TRUE; } - +void RestoreWithdrawnLocation (tmp) TwmWindow *tmp; { @@ -826,7 +845,8 @@ RestoreWithdrawnLocation (tmp) *********************************************************************** */ -void Reborder (time) +void +Reborder (time) Time time; { TwmWindow *tmp; /* temp twm window structure */ @@ -852,11 +872,10 @@ Time time; SetFocus ((TwmWindow*)NULL, time); } -SIGNAL_T Done() +SIGNAL_T +Done(int sig) { - Reborder (CurrentTime); - XCloseDisplay(dpy); - exit(0); + TimeToYield = True; SIGNAL_RETURN; } @@ -870,7 +889,8 @@ SIGNAL_T Done() Bool ErrorOccurred = False; XErrorEvent LastErrorEvent; -static int TwmErrorHandler(dpy, event) +static int +TwmErrorHandler(dpy, event) Display *dpy; XErrorEvent *event; { @@ -887,7 +907,8 @@ static int TwmErrorHandler(dpy, event) /* ARGSUSED*/ -static int CatchRedirectError(dpy, event) +static int +CatchRedirectError(dpy, event) Display *dpy; XErrorEvent *event; { diff --git a/src/twm.h b/src/twm.h index 7fe187e..516bb3b 100644 --- a/src/twm.h +++ b/src/twm.h @@ -60,6 +60,7 @@ from The Open Group. * 28-Oct-87 Thomas E. LaStrange File created * 10-Oct-90 David M. Sternlicht Storeing saved colors on root ***********************************************************************/ +/* $XFree86: xc/programs/twm/twm.h,v 3.12 2001/12/14 20:01:10 dawes Exp $ */ #ifndef _TWM_ #define _TWM_ @@ -86,7 +87,7 @@ from The Open Group. #define SIGNAL_RETURN return #endif -typedef SIGNAL_T (*SigProc)(); /* type of function returned by signal() */ +typedef SIGNAL_T (*SigProc)(int); /* type of function returned by signal() */ #define BW 2 /* border width */ #define BW2 4 /* border width * 2 */ @@ -138,12 +139,6 @@ typedef SIGNAL_T (*SigProc)(); /* type of function returned by signal() */ /* defines for zooming/unzooming */ #define ZOOM_NONE 0 -#define FBF(fix_fore, fix_back, fix_font)\ - Gcv.foreground = fix_fore;\ - Gcv.background = fix_back;\ - Gcv.font = fix_font;\ - XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv) - #define FB(fix_fore, fix_back)\ Gcv.foreground = fix_fore;\ Gcv.background = fix_back;\ @@ -153,8 +148,11 @@ typedef struct MyFont { char *name; /* name of the font */ XFontStruct *font; /* font structure */ + XFontSet fontset; /* fontset structure */ int height; /* height of the font */ int y; /* Y coordinate to draw characters */ + int ascent; + int descent; } MyFont; typedef struct ColorPair @@ -349,16 +347,15 @@ typedef struct TWMWinConfigEntry #define TBPM_QUESTION ":question" /* name of unknown titlebar pixmap */ #include -#ifndef X_NOT_STDC_ENV #include -#else -extern char *malloc(), *calloc(), *realloc(), *getenv(); -extern void free(); -#endif -extern void Reborder(); -extern SIGNAL_T Done(); -void ComputeCommonTitleOffsets(); -void ComputeWindowTitleOffsets(), ComputeTitleLocation(); +extern void InitVariables ( void ); +extern void CreateFonts ( void ); +extern void RestoreWithdrawnLocation ( TwmWindow *tmp ); +extern void Reborder( Time time); +extern SIGNAL_T Done( int sig ); +extern void ComputeCommonTitleOffsets ( void ); +extern void ComputeTitleLocation ( TwmWindow *tmp ); +extern void ComputeWindowTitleOffsets ( TwmWindow *tmp_win, int width, Bool squeeze ); extern char *ProgramName; extern Display *dpy; extern XtAppContext appContext; @@ -397,20 +394,34 @@ extern int InfoLines; extern char Info[][INFO_SIZE]; extern int Argc; extern char **Argv; -extern char **Environ; -extern void NewFontCursor(); -extern Pixmap CreateMenuIcon(); +extern void NewFontCursor ( Cursor *cp, char *str ); +extern void NewBitmapCursor ( Cursor *cp, char *source, char *mask ); +extern Pixmap CreateMenuIcon ( int height, unsigned int *widthp, unsigned int *heightp ); extern Bool ErrorOccurred; +extern volatile Bool TimeToYield; extern XErrorEvent LastErrorEvent; #define ResetError() (ErrorOccurred = False) extern Bool RestartPreviousState; -extern Bool GetWMState(); +extern Bool GetWMState ( Window w, int *statep, Window *iwp ); + +extern void twmrc_error_prefix ( void ); + +extern int yyparse ( void ); +extern int yylex ( void ); +extern void yyerror ( char *s ); +extern int doinput ( char *buf, int size ); +extern void RemoveDQuote ( char *str ); extern Atom TwmAtoms[]; +extern Bool use_fontset; + +extern int ShapeEventBase; +extern int ShapeErrorBase; + #define _XA_MIT_PRIORITY_COLORS TwmAtoms[0] #define _XA_WM_CHANGE_STATE TwmAtoms[1] #define _XA_WM_STATE TwmAtoms[2] diff --git a/src/util.c b/src/util.c index 0082a4d..5056dcc 100644 --- a/src/util.c +++ b/src/util.c @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/util.c,v 1.13 2002/09/24 21:00:28 tsi Exp $ */ /*********************************************************************** @@ -70,9 +71,17 @@ in this Software without prior written authorization from The Open Group. #include #include -static Pixmap CreateXLogoPixmap(), CreateResizePixmap(); -static Pixmap CreateQuestionPixmap(), CreateMenuPixmap(); -static Pixmap CreateDotPixmap(); +static Pixmap CreateXLogoPixmap ( unsigned int *widthp, + unsigned int *heightp ); +static Pixmap CreateResizePixmap ( unsigned int *widthp, + unsigned int *heightp ); +static Pixmap CreateDotPixmap ( unsigned int *widthp, + unsigned int *heightp ); +static Pixmap CreateQuestionPixmap ( unsigned int *widthp, + unsigned int *heightp ); +static Pixmap CreateMenuPixmap ( unsigned int *widthp, + unsigned int *heightp ); + int HotX, HotY; /*********************************************************************** @@ -286,8 +295,9 @@ char *name; newname = (char *) malloc (HomeLen + strlen(name) + 2); if (!newname) { fprintf (stderr, - "%s: unable to allocate %d bytes to expand filename %s/%s\n", - ProgramName, HomeLen + strlen(name) + 2, Home, &name[1]); + "%s: unable to allocate %ld bytes to expand filename %s/%s\n", + ProgramName, HomeLen + (unsigned long)strlen(name) + 2, + Home, &name[1]); } else { (void) sprintf (newname, "%s/%s", Home, &name[1]); } @@ -333,7 +343,8 @@ char *name; *********************************************************************** */ -Pixmap FindBitmap (name, widthp, heightp) +Pixmap +FindBitmap (name, widthp, heightp) char *name; unsigned int *widthp, *heightp; { @@ -351,7 +362,7 @@ Pixmap FindBitmap (name, widthp, heightp) int i; static struct { char *name; - Pixmap (*proc)(); + Pixmap (*proc)(unsigned int *, unsigned int *); } pmtab[] = { { TBPM_DOT, CreateDotPixmap }, { TBPM_ICONIFY, CreateDotPixmap }, @@ -412,13 +423,14 @@ Pixmap FindBitmap (name, widthp, heightp) return pm; } -Pixmap GetBitmap (name) +Pixmap +GetBitmap (name) char *name; { return FindBitmap (name, &JunkWidth, &JunkHeight); } - +void InsertRGBColormap (a, maps, nmaps, replace) Atom a; XStandardColormap *maps; @@ -436,8 +448,8 @@ InsertRGBColormap (a, maps, nmaps, replace) if (!sc) { /* no existing, allocate new */ sc = (StdCmap *) malloc (sizeof (StdCmap)); if (!sc) { - fprintf (stderr, "%s: unable to allocate %d bytes for StdCmap\n", - ProgramName, sizeof (StdCmap)); + fprintf (stderr, "%s: unable to allocate %ld bytes for StdCmap\n", + ProgramName, (unsigned long)sizeof (StdCmap)); return; } } @@ -461,6 +473,7 @@ InsertRGBColormap (a, maps, nmaps, replace) return; } +void RemoveRGBColormap (a) Atom a; { @@ -481,6 +494,7 @@ RemoveRGBColormap (a) return; } +void LocateStandardColormaps() { Atom *atoms; @@ -501,6 +515,7 @@ LocateStandardColormaps() return; } +void GetColor(kind, what, name) int kind; Pixel *what; @@ -581,6 +596,7 @@ char *name; *what = color.pixel; } +void GetColorValue(kind, what, name) int kind; XColor *what; @@ -608,10 +624,68 @@ char *name; } } +/* + * The following functions are sensible to 'use_fontset'. + * When 'use_fontset' is True, + * - XFontSet-related internationalized functions are used + * so as multibyte languages can be displayed. + * When 'use_fontset' is False, + * - XFontStruct-related conventional functions are used + * so as 8-bit characters can be displayed even when + * locale is not set properly. + */ +void GetFont(font) MyFont *font; { char *deffontname = "fixed"; + char **missing_charset_list_return; + int missing_charset_count_return; + char *def_string_return; + XFontSetExtents *font_extents; + XFontStruct **xfonts; + char **font_names; + register int i; + int ascent; + int descent; + int fnum; + char *basename2; + + if (use_fontset) { + if (font->fontset != NULL){ + XFreeFontSet(dpy, font->fontset); + } + + basename2 = (char *)malloc(strlen(font->name) + 3); + if (basename2) sprintf(basename2, "%s,*", font->name); + else basename2 = font->name; + if( (font->fontset = XCreateFontSet(dpy, basename2, + &missing_charset_list_return, + &missing_charset_count_return, + &def_string_return)) == NULL) { + fprintf (stderr, "%s: unable to open fontset \"%s\"\n", + ProgramName, font->name); + exit(1); + } + if (basename2 != font->name) free(basename2); + for(i=0; ifontset); + fnum = XFontsOfFontSet(font->fontset, &xfonts, &font_names); + for( i = 0, ascent = 0, descent = 0; iascent) ascent = (*xfonts)->ascent; + if (descent < (*xfonts)->descent) descent = (*xfonts)->descent; + xfonts++; + } + font->height = font_extents->max_logical_extent.height; + font->y = ascent; + font->ascent = ascent; + font->descent = descent; + return; + } if (font->font != NULL) XFreeFont(dpy, font->font); @@ -631,13 +705,137 @@ MyFont *font; } font->height = font->font->ascent + font->font->descent; font->y = font->font->ascent; + font->ascent = font->font->ascent; + font->descent = font->font->descent; +} + +int +MyFont_TextWidth(font, string, len) + MyFont *font; + char *string; + int len; +{ + XRectangle ink_rect; + XRectangle logical_rect; + + if (use_fontset) { + XmbTextExtents(font->fontset, string, len, + &ink_rect, &logical_rect); + return logical_rect.width; + } + return XTextWidth(font->font, string, len); } +void +MyFont_DrawImageString(dpy, d, font, gc, x, y, string, len) + Display *dpy; + Drawable d; + MyFont *font; + GC gc; + int x,y; + char *string; + int len; +{ + if (use_fontset) { + XmbDrawImageString(dpy, d, font->fontset, gc, x, y, string, len); + return; + } + XDrawImageString (dpy, d, gc, x, y, string, len); +} + +void +MyFont_DrawString(dpy, d, font, gc, x, y, string, len) + Display *dpy; + Drawable d; + MyFont *font; + GC gc; + int x,y; + char *string; + int len; +{ + if (use_fontset) { + XmbDrawString(dpy, d, font->fontset, gc, x, y, string, len); + return; + } + XDrawString (dpy, d, gc, x, y, string, len); +} + +void +MyFont_ChangeGC(fix_fore, fix_back, fix_font) + unsigned long fix_fore, fix_back; + MyFont *fix_font; +{ + Gcv.foreground = fix_fore; + Gcv.background = fix_back; + if (use_fontset) { + XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground, &Gcv); + return; + } + Gcv.font = fix_font->font->fid; + XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv); +} + +/* + * The following functions are internationalized substitutions + * for XFetchName and XGetIconName using XGetWMName and + * XGetWMIconName. + * + * Please note that the third arguments have to be freed using free(), + * not XFree(). + */ +Status +I18N_FetchName(dpy, w, winname) + Display *dpy; + Window w; + char ** winname; +{ + int status; + XTextProperty text_prop; + char **list; + int num; + + status = XGetWMName(dpy, w, &text_prop); + if (!status || !text_prop.value || !text_prop.nitems) { + *winname = NULL; + return 0; + } + status = XmbTextPropertyToTextList(dpy, &text_prop, &list, &num); + if (status < Success || !num || !*list) { + *winname = NULL; + return 0; + } + XFree(text_prop.value); + *winname = (char *)strdup(*list); + XFreeStringList(list); + return 1; +} + +Status +I18N_GetIconName(dpy, w, iconname) + Display *dpy; + Window w; + char ** iconname; +{ + int status; + XTextProperty text_prop; + char **list; + int num; + + status = XGetWMIconName(dpy, w, &text_prop); + if (!status || !text_prop.value || !text_prop.nitems) return 0; + status = XmbTextPropertyToTextList(dpy, &text_prop, &list, &num); + if (status < Success || !num || !*list) return 0; + XFree(text_prop.value); + *iconname = (char *)strdup(*list); + XFreeStringList(list); + return 1; +} /* * SetFocus - separate routine to set focus to make things more understandable * and easier to debug */ +void SetFocus (tmp_win, time) TwmWindow *tmp_win; Time time; @@ -723,7 +921,8 @@ putenv(s) #endif /* NOPUTENV */ -static Pixmap CreateXLogoPixmap (widthp, heightp) +static Pixmap +CreateXLogoPixmap (widthp, heightp) unsigned int *widthp, *heightp; { int h = Scr->TBInfo.width - Scr->TBInfo.border * 2; @@ -758,7 +957,8 @@ static Pixmap CreateXLogoPixmap (widthp, heightp) } -static Pixmap CreateResizePixmap (widthp, heightp) +static Pixmap +CreateResizePixmap (widthp, heightp) unsigned int *widthp, *heightp; { int h = Scr->TBInfo.width - Scr->TBInfo.border * 2; @@ -813,7 +1013,8 @@ static Pixmap CreateResizePixmap (widthp, heightp) } -static Pixmap CreateDotPixmap (widthp, heightp) +static Pixmap +CreateDotPixmap (widthp, heightp) unsigned int *widthp, *heightp; { int h = Scr->TBInfo.width - Scr->TBInfo.border * 2; @@ -844,7 +1045,8 @@ static Pixmap CreateDotPixmap (widthp, heightp) static char questionmark_bits[] = { 0x38, 0x7c, 0x64, 0x30, 0x18, 0x00, 0x18, 0x18}; -static Pixmap CreateQuestionPixmap (widthp, heightp) +static Pixmap +CreateQuestionPixmap (widthp, heightp) unsigned int *widthp, *heightp; { *widthp = questionmark_width; @@ -862,16 +1064,18 @@ static Pixmap CreateQuestionPixmap (widthp, heightp) } -static Pixmap CreateMenuPixmap (widthp, heightp) - int *widthp, *heightp; +static Pixmap +CreateMenuPixmap (widthp, heightp) + unsigned int *widthp, *heightp; { return CreateMenuIcon (Scr->TBInfo.width - Scr->TBInfo.border * 2, - widthp,heightp); + widthp,heightp); } -Pixmap CreateMenuIcon (height, widthp, heightp) +Pixmap +CreateMenuIcon (height, widthp, heightp) int height; - int *widthp, *heightp; + unsigned int *widthp, *heightp; { int h, w; int ih, iw; diff --git a/src/util.h b/src/util.h index bfeab2f..0554f4a 100644 --- a/src/util.h +++ b/src/util.h @@ -48,6 +48,7 @@ in this Software without prior written authorization from The Open Group. /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ /** OR PERFORMANCE OF THIS SOFTWARE. **/ /*****************************************************************************/ +/* $XFree86: xc/programs/twm/util.h,v 1.7 2001/12/14 20:01:11 dawes Exp $ */ /*********************************************************************** @@ -63,12 +64,33 @@ in this Software without prior written authorization from The Open Group. #ifndef _UTIL_ #define _UTIL_ -extern void Zoom(); -extern void MoveOutline(); -extern Pixmap GetBitmap(), FindBitmap(); -extern void GetUnknownIcon(); -extern char *ExpandFilename(); -extern int GetColor(); +extern void MoveOutline ( Window root, int x, int y, int width, int height, + int bw, int th ); +extern void Zoom ( Window wf, Window wt ); +extern char * ExpandFilename ( char *name ); +extern void GetUnknownIcon ( char *name ); +extern Pixmap FindBitmap ( char *name, unsigned int *widthp, + unsigned int *heightp ); +extern Pixmap GetBitmap ( char *name ); +extern void InsertRGBColormap ( Atom a, XStandardColormap *maps, int nmaps, + Bool replace ); +extern void RemoveRGBColormap ( Atom a ); +extern void LocateStandardColormaps ( void ); +extern void GetColor ( int kind, Pixel *what, char *name ); +extern void GetColorValue ( int kind, XColor *what, char *name ); +extern void GetFont ( MyFont *font ); +extern int MyFont_TextWidth( MyFont *font, char *string, int len); +extern void MyFont_DrawImageString( Display *dpy, Drawable d, MyFont *font, + GC gc, int x, int y, char * string, + int len); +extern void MyFont_DrawString( Display *dpy, Drawable d, MyFont *font, + GC gc, int x, int y, char * string, int len); +extern void MyFont_ChangeGC( unsigned long fix_fore, unsigned long fix_back, + MyFont *fix_font); +extern Status I18N_FetchName( Display *dpy, Window win, char **winname); +extern Status I18N_GetIconName( Display *dpy, Window win, char **iconname); +extern void SetFocus ( TwmWindow *tmp_win, Time time ); +extern void Bell ( int type, int percent, Window win ); extern int HotX, HotY; @@ -90,6 +112,4 @@ extern int HotX, HotY; #define XkbBI_MajorError 2 #endif -extern void Bell(); - #endif /* _UTIL_ */ -- cgit v1.2.3