Index: xc/ChangeLog =================================================================== RCS file: /cvs/xorg/xc/ChangeLog,v retrieving revision 1.807 diff -u -2 -0 -r1.807 ChangeLog --- xc/ChangeLog 11 Mar 2005 14:52:41 -0000 1.807 +++ xc/ChangeLog 11 Mar 2005 16:17:09 -0000 @@ -1,20 +1,42 @@ +2005-03-11 Roland Mainz + * xc/programs/twm/add_window.c + * xc/programs/twm/cursor.c + * xc/programs/twm/events.c + * xc/programs/twm/gc.c + * xc/programs/twm/gram.y + * xc/programs/twm/iconmgr.c + * xc/programs/twm/icons.c + * xc/programs/twm/list.c + * xc/programs/twm/menus.c + * xc/programs/twm/parse.c + * xc/programs/twm/resize.c + * xc/programs/twm/twm.c + * xc/programs/twm/util.c + bugzilla #2566 (https://bugs.freedesktop.org/show_bug.cgi?id=2566) + attachment #xxx (https://bugs.freedesktop.org/attachment.cgi?id=xxx) + ANSI-fy twm window manager code. + The conversion preserves the comments which annotate variables and + function arguments (these have been moved into doxygen(esque?) "stubs" + above each function. + Patch by Mike Owens . + 2005-03-11 Thomas Winischhofer * programs/Xserver/hw/xfree86/drivers/sis/* SiS driver: - MergedFB/Xinerama: Added support for non-rectangular layouts (no panning into dead areas, mouse restriced to accessible areas) - MergedFB/Xinerama: Added support for RandR. - MergedFB: Improved "physical alignment compensation" Offset by disallowing panning and mouse movements into dead areas. - Added "Reflect" feature: Reflect screen in x, y or x+y direction - Added aspect ratio detection for analog (VGA) devices. - Fixed FSTN support on SiS55x (for 320x240 xSTN panels) - Workaround for SiS76x memory access latency issues if no local framebuffer memory is present. - Fixed bug in SaveScreen() causing a sig 11 sometimes. - Minor others. 2005-03-08 Alan Coopersmith Index: xc/programs/twm/add_window.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/add_window.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 add_window.c --- xc/programs/twm/add_window.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/add_window.c 11 Mar 2005 16:17:24 -0000 @@ -80,103 +80,91 @@ #define gray_height 2 static char gray_bits[] = { 0x02, 0x01}; int AddingX; int AddingY; int AddingW; int AddingH; static int PlaceX = 50; static int PlaceY = 50; 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 */ -/************************************************************************ +/** + * map gravity to (x,y) offset signs for adding to x and y when window is + * mapped to get proper placement. * - * Procedure: - * GetGravityOffsets - map gravity to (x,y) offset signs for adding - * to x and y when window is mapped to get proper placement. + * \param tmp window from which to get gravity + * \param xp,yp return values * - ************************************************************************ */ void -GetGravityOffsets (tmp, xp, yp) - TwmWindow *tmp; /* window from which to get gravity */ - int *xp, *yp; /* return values */ +GetGravityOffsets (TwmWindow *tmp, int *xp, int *yp) { static struct _gravity_offset { int x, y; } gravity_offsets[11] = { { 0, 0 }, /* ForgetGravity */ { -1, -1 }, /* NorthWestGravity */ { 0, -1 }, /* NorthGravity */ { 1, -1 }, /* NorthEastGravity */ { -1, 0 }, /* WestGravity */ { 0, 0 }, /* CenterGravity */ { 1, 0 }, /* EastGravity */ { -1, 1 }, /* SouthWestGravity */ { 0, 1 }, /* SouthGravity */ { 1, 1 }, /* SouthEastGravity */ { 0, 0 }, /* StaticGravity */ }; register int g = ((tmp->hints.flags & PWinGravity) ? tmp->hints.win_gravity : NorthWestGravity); if (g < ForgetGravity || g > StaticGravity) { *xp = *yp = 0; } else { *xp = gravity_offsets[g].x; *yp = gravity_offsets[g].y; } } -/*********************************************************************** +/** + * add a new window to the twm list. * - * Procedure: - * AddWindow - add a new window to the twm list + * \return pointer to the TwmWindow structure * - * Returned Value: - * (TwmWindow *) - pointer to the TwmWindow structure - * - * Inputs: - * w - the window id of the window to add - * iconm - flag to tell if this is an icon manager window - * iconp - pointer to icon manager struct - * - *********************************************************************** + * \param w the window id of the window to add + * \param iconm flag to tell if this is an icon manager window + * \param iconp pointer to icon manager struct */ - TwmWindow * -AddWindow(w, iconm, iconp) -Window w; -int iconm; -IconMgr *iconp; +AddWindow(Window w, int iconm, IconMgr *iconp) { TwmWindow *tmp_win; /* new twm window structure */ int stat; XEvent event; unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ int width, height; /* tmp variable */ int ask_user; /* don't know where to put the window */ int gravx, gravy; /* gravity signs for positioning */ int namelen; int bw2; short saved_x, saved_y, restore_icon_x, restore_icon_y; unsigned short saved_width, saved_height; Bool restore_iconified = 0; Bool restore_icon_info_present = 0; int restoredFromPrevSession; Bool width_ever_changed_by_user; Bool height_ever_changed_by_user; char *name; @@ -947,158 +935,130 @@ } if (tmp_win->hilite_w) { XSaveContext(dpy, tmp_win->hilite_w, TwmContext, (caddr_t)tmp_win); XSaveContext(dpy, tmp_win->hilite_w, ScreenContext, (caddr_t)Scr); } } XUngrabServer(dpy); /* if we were in the middle of a menu activated function, regrab * the pointer */ if (RootFunction) ReGrab(); return (tmp_win); } -/*********************************************************************** - * - * Procedure: - * MappedNotOverride - checks to see if we should really - * put a twm frame on the window +/** + * checks to see if we should really put a twm frame on the window * - * Returned Value: - * TRUE - go ahead and frame the window - * FALSE - don't frame the window - * - * Inputs: - * w - the window to check - * - *********************************************************************** + * \return TRUE - go ahead and place the window + * \return FALSE - don't frame the window + * \param w the window to check */ - int -MappedNotOverride(w) - Window w; +MappedNotOverride(Window w) { XWindowAttributes wa; XGetWindowAttributes(dpy, w, &wa); return ((wa.map_state != IsUnmapped) && (wa.override_redirect != True)); } -/*********************************************************************** - * - * Procedure: - * AddDefaultBindings - attach default bindings so that naive users - * don't get messed up if they provide a minimal twmrc. +/** + * attach default bindings so that naive users don't get messed up if they + * provide a minimal twmrc. */ -static void do_add_binding (button, context, modifier, func) - int button, context, modifier; - int func; +static void do_add_binding (int button, int context, int modifier, int func) { MouseButton *mb = &Scr->Mouse[button][context][modifier]; if (mb->func) return; /* already defined */ mb->func = func; mb->item = NULL; } void AddDefaultBindings () { /* * The bindings are stored in Scr->Mouse, indexed by * Mouse[button_number][C_context][modifier]. */ #define NoModifierMask 0 do_add_binding (Button1, C_TITLE, NoModifierMask, F_MOVE); do_add_binding (Button1, C_ICON, NoModifierMask, F_ICONIFY); do_add_binding (Button1, C_ICONMGR, NoModifierMask, F_ICONIFY); do_add_binding (Button2, C_TITLE, NoModifierMask, F_RAISELOWER); do_add_binding (Button2, C_ICON, NoModifierMask, F_ICONIFY); do_add_binding (Button2, C_ICONMGR, NoModifierMask, F_ICONIFY); #undef NoModifierMask } -/*********************************************************************** - * - * Procedure: - * GrabButtons - grab needed buttons for the window +/** + * grab needed buttons for the window * - * Inputs: - * tmp_win - the twm window structure to use - * - *********************************************************************** + * \param[in] tmp_win the twm window structure to use */ - void -GrabButtons(tmp_win) -TwmWindow *tmp_win; +GrabButtons(TwmWindow *tmp_win) { int i, j; for (i = 0; i < MAX_BUTTONS+1; i++) { for (j = 0; j < MOD_SIZE; j++) { if (Scr->Mouse[i][C_WINDOW][j].func != 0) { /* twm used to do this grab on the application main window, * tmp_win->w . This was not ICCCM complient and was changed. */ XGrabButton(dpy, i, j, tmp_win->frame, True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, Scr->FrameCursor); } } } } -/*********************************************************************** +/** + * grab needed keys for the window * - * Procedure: - * GrabKeys - grab needed keys for the window - * - * Inputs: - * tmp_win - the twm window structure to use - * - *********************************************************************** + * \param[in] tmp_win the twm window structure to use */ - void -GrabKeys(tmp_win) -TwmWindow *tmp_win; +GrabKeys(TwmWindow *tmp_win) { FuncKey *tmp; IconMgr *p; for (tmp = Scr->FuncKeyRoot.next; tmp != NULL; tmp = tmp->next) { switch (tmp->cont) { case C_WINDOW: XGrabKey(dpy, tmp->keycode, tmp->mods, tmp_win->w, True, GrabModeAsync, GrabModeAsync); break; case C_ICON: if (tmp_win->icon_w) XGrabKey(dpy, tmp->keycode, tmp->mods, tmp_win->icon_w, True, GrabModeAsync, GrabModeAsync); case C_TITLE: if (tmp_win->title_w) @@ -1119,42 +1079,41 @@ /* case C_ROOT: XGrabKey(dpy, tmp->keycode, tmp->mods, Scr->Root, True, GrabModeAsync, GrabModeAsync); break; */ } } for (tmp = Scr->FuncKeyRoot.next; tmp != NULL; tmp = tmp->next) { if (tmp->cont == C_ICONMGR && !Scr->NoIconManagers) { for (p = &Scr->iconmgr; p != NULL; p = p->next) { XUngrabKey(dpy, tmp->keycode, tmp->mods, p->twm_win->w); } } } } -static Window CreateHighlightWindow (tmp_win) - TwmWindow *tmp_win; +static Window CreateHighlightWindow (TwmWindow *tmp_win) { XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm = None; GC gc; XGCValues gcv; unsigned long valuemask; int h = (Scr->TitleHeight - 2 * Scr->FramePadding); Window w; /* * If a special highlight pixmap was given, use that. Otherwise, * use a nice, even gray pattern. The old horizontal lines look really * awful on interlaced monitors (as well as resembling other looks a * little bit too closely), but can be used by putting * * Pixmaps { TitleHighlight "hline2" } * * (or whatever the horizontal line bitmap is named) in the startup * file. If all else fails, use the foreground color to look like a @@ -1205,68 +1164,64 @@ } void ComputeCommonTitleOffsets () { int buttonwidth = (Scr->TBInfo.width + Scr->TBInfo.pad); Scr->TBInfo.leftx = Scr->TBInfo.rightoff = Scr->FramePadding; if (Scr->TBInfo.nleft > 0) Scr->TBInfo.leftx += Scr->ButtonIndent; Scr->TBInfo.titlex = (Scr->TBInfo.leftx + (Scr->TBInfo.nleft * buttonwidth) - Scr->TBInfo.pad + Scr->TitlePadding); if (Scr->TBInfo.nright > 0) Scr->TBInfo.rightoff += (Scr->ButtonIndent + ((Scr->TBInfo.nright * buttonwidth) - Scr->TBInfo.pad)); return; } -void ComputeWindowTitleOffsets (tmp_win, width, squeeze) - TwmWindow *tmp_win; - int width; - Bool squeeze; +void ComputeWindowTitleOffsets (TwmWindow *tmp_win, int width, Bool squeeze) { tmp_win->highlightx = (Scr->TBInfo.titlex + tmp_win->name_width); if (tmp_win->hilite_w || Scr->TBInfo.nright > 0) tmp_win->highlightx += Scr->TitlePadding; tmp_win->rightx = width - Scr->TBInfo.rightoff; if (squeeze && tmp_win->squeeze_info) { int rx = (tmp_win->highlightx + (tmp_win->hilite_w ? Scr->TBInfo.width * 2 : 0) + (Scr->TBInfo.nright > 0 ? Scr->TitlePadding : 0) + Scr->FramePadding); if (rx < tmp_win->rightx) tmp_win->rightx = rx; } return; } -/* - * ComputeTitleLocation - calculate the position of the title window; we need - * to take the frame_bw into account since we want (0,0) of the title window - * to line up with (0,0) of the frame window. +/** + * calculate the position of the title window. We need to take the frame_bw + * into account since we want (0,0) of the title window to line up with (0,0) + * of the frame window. */ -void ComputeTitleLocation (tmp) - register TwmWindow *tmp; +void ComputeTitleLocation (register TwmWindow *tmp) { tmp->title_x = -tmp->frame_bw; tmp->title_y = -tmp->frame_bw; if (tmp->squeeze_info) { register SqueezeInfo *si = tmp->squeeze_info; int basex; int maxwidth = tmp->frame_width; int tw = tmp->title_width; /* * figure label base from squeeze info (justification fraction) */ if (si->denom == 0) { /* num is pixel based */ if ((basex = si->num) == 0) { /* look for special cases */ switch (si->justify) { case J_RIGHT: basex = maxwidth; break; case J_CENTER: @@ -1282,42 +1237,41 @@ /* * adjust for left (nop), center, right justify and clip */ switch (si->justify) { case J_CENTER: basex -= tw / 2; break; case J_RIGHT: basex -= tw - 1; break; } if (basex > maxwidth - tw + 1) basex = maxwidth - tw + 1; if (basex < 0) basex = 0; tmp->title_x = basex - tmp->frame_bw; } } -static void CreateWindowTitlebarButtons (tmp_win) - TwmWindow *tmp_win; +static void CreateWindowTitlebarButtons (TwmWindow *tmp_win) { unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ int leftx, rightx, y; TitleButton *tb; int nb; if (tmp_win->title_height == 0) { tmp_win->hilite_w = 0; return; } /* * create the title bar windows; let the event handler deal with painting * so that we don't have to spend two pixmaps (or deal with hashing) */ ComputeWindowTitleOffsets (tmp_win, tmp_win->attr.width, False); @@ -1361,102 +1315,96 @@ (unsigned int) Scr->TBInfo.border, 0, (unsigned int) CopyFromParent, (Visual *) CopyFromParent, valuemask, &attributes); tbw->info = tb; } } } tmp_win->hilite_w = (tmp_win->titlehighlight ? CreateHighlightWindow (tmp_win) : None); XMapSubwindows(dpy, tmp_win->title_w); if (tmp_win->hilite_w) XUnmapWindow(dpy, tmp_win->hilite_w); return; } void -SetHighlightPixmap (filename) - char *filename; +SetHighlightPixmap (char *filename) { Pixmap pm = GetBitmap (filename); if (pm) { if (Scr->hilitePm) { XFreePixmap (dpy, Scr->hilitePm); } Scr->hilitePm = pm; Scr->hilite_pm_width = JunkWidth; Scr->hilite_pm_height = JunkHeight; } } void -FetchWmProtocols (tmp) - TwmWindow *tmp; +FetchWmProtocols (TwmWindow *tmp) { unsigned long flags = 0L; Atom *protocols = NULL; int n; if (XGetWMProtocols (dpy, tmp->w, &protocols, &n)) { register int i; register Atom *ap; for (i = 0, ap = protocols; i < n; i++, ap++) { if (*ap == _XA_WM_TAKE_FOCUS) flags |= DoesWmTakeFocus; if (*ap == _XA_WM_SAVE_YOURSELF) flags |= DoesWmSaveYourself; if (*ap == _XA_WM_DELETE_WINDOW) flags |= DoesWmDeleteWindow; } if (protocols) XFree ((char *) protocols); } tmp->protocols = flags; } TwmColormap * -CreateTwmColormap(c) - Colormap c; +CreateTwmColormap(Colormap c) { TwmColormap *cmap; cmap = (TwmColormap *) malloc(sizeof(TwmColormap)); if (!cmap || XSaveContext(dpy, c, ColormapContext, (caddr_t) cmap)) { if (cmap) free((char *) cmap); return (NULL); } cmap->c = c; cmap->state = 0; cmap->install_req = 0; cmap->w = None; cmap->refcnt = 1; return (cmap); } ColormapWindow * -CreateColormapWindow(w, creating_parent, property_window) - Window w; - Bool creating_parent; - Bool property_window; +CreateColormapWindow(Window w, Bool creating_parent, Bool property_window) { ColormapWindow *cwin; TwmColormap *cmap; XWindowAttributes attributes; cwin = (ColormapWindow *) malloc(sizeof(ColormapWindow)); if (cwin) { if (!XGetWindowAttributes(dpy, w, &attributes) || XSaveContext(dpy, w, ColormapContext, (caddr_t) cwin)) { free((char *) cwin); return (NULL); } if (XFindContext(dpy, attributes.colormap, ColormapContext, (caddr_t *)&cwin->colormap) == XCNOENT) { cwin->colormap = cmap = CreateTwmColormap(attributes.colormap); if (!cmap) { XDeleteContext(dpy, w, ColormapContext); free((char *) cwin); return (NULL); @@ -1476,42 +1424,41 @@ cwin->refcnt = 1; /* * If this is a ColormapWindow property window and we * are not monitoring ColormapNotify or VisibilityNotify * events, we need to. */ if (property_window && (attributes.your_event_mask & (ColormapChangeMask|VisibilityChangeMask)) != (ColormapChangeMask|VisibilityChangeMask)) { XSelectInput(dpy, w, attributes.your_event_mask | (ColormapChangeMask|VisibilityChangeMask)); } } return (cwin); } void -FetchWmColormapWindows (tmp) - TwmWindow *tmp; +FetchWmColormapWindows (TwmWindow *tmp) { register int i, j; Window *cmap_windows = NULL; Bool can_free_cmap_windows = False; int number_cmap_windows = 0; ColormapWindow **cwins = NULL; int previously_installed; number_cmap_windows = 0; if (/* SUPPRESS 560 */(previously_installed = (Scr->cmapInfo.cmaps == &tmp->cmaps && tmp->cmaps.number_cwins))) { cwins = tmp->cmaps.cwins; for (i = 0; i < tmp->cmaps.number_cwins; i++) cwins[i]->colormap->state = 0; } if (XGetWMColormapWindows (dpy, tmp->w, &cmap_windows, &number_cmap_windows) && number_cmap_windows > 0) { @@ -1605,42 +1552,41 @@ tmp->cmaps.number_cwins = number_cmap_windows; if (number_cmap_windows > 1) tmp->cmaps.scoreboard = (char *) calloc(1, ColormapsScoreboardLength(&tmp->cmaps)); if (previously_installed) InstallWindowColormaps(PropertyNotify, (TwmWindow *) NULL); done: if (cmap_windows) { if (can_free_cmap_windows) free ((char *) cmap_windows); else XFree ((char *) cmap_windows); } return; } -void GetWindowSizeHints (tmp) - TwmWindow *tmp; +void GetWindowSizeHints (TwmWindow *tmp) { long supplied = 0; if (!XGetWMNormalHints (dpy, tmp->w, &tmp->hints, &supplied)) tmp->hints.flags = 0; if (tmp->hints.flags & PResizeInc) { if (tmp->hints.width_inc == 0) tmp->hints.width_inc = 1; if (tmp->hints.height_inc == 0) tmp->hints.height_inc = 1; } if (!(supplied & PWinGravity) && (tmp->hints.flags & USPosition)) { static int gravs[] = { SouthEastGravity, SouthWestGravity, NorthEastGravity, NorthWestGravity }; int right = tmp->attr.x + tmp->attr.width + 2 * tmp->old_bw; int bottom = tmp->attr.y + tmp->attr.height + 2 * tmp->old_bw; tmp->hints.win_gravity = gravs[((Scr->MyDisplayHeight - bottom < tmp->title_height) ? 0 : 2) | ((Scr->MyDisplayWidth - right < tmp->title_height) ? 0 : 1)]; tmp->hints.flags |= PWinGravity; Index: xc/programs/twm/cursor.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/cursor.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 cursor.c --- xc/programs/twm/cursor.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/cursor.c 11 Mar 2005 16:17:24 -0000 @@ -109,65 +109,61 @@ {"sizing", XC_sizing, None}, {"spider", XC_spider, None}, {"spraycan", XC_spraycan, None}, {"star", XC_star, None}, {"target", XC_target, None}, {"tcross", XC_tcross, None}, {"top_left_arrow", XC_top_left_arrow, None}, {"top_left_corner", XC_top_left_corner, None}, {"top_right_corner", XC_top_right_corner, None}, {"top_side", XC_top_side, None}, {"top_tee", XC_top_tee, None}, {"trek", XC_trek, None}, {"ul_angle", XC_ul_angle, None}, {"umbrella", XC_umbrella, None}, {"ur_angle", XC_ur_angle, None}, {"watch", XC_watch, None}, {"xterm", XC_xterm, None}, }; void -NewFontCursor (cp, str) - Cursor *cp; - char *str; +NewFontCursor (Cursor *cp, char *str) { int i; for (i = 0; i < sizeof(cursor_names)/sizeof(struct _CursorName); i++) { if (strcmp(str, cursor_names[i].name) == 0) { if (cursor_names[i].cursor == None) cursor_names[i].cursor = XCreateFontCursor(dpy, cursor_names[i].shape); *cp = cursor_names[i].cursor; return; } } fprintf (stderr, "%s: unable to find font cursor \"%s\"\n", ProgramName, str); } void -NewBitmapCursor(cp, source, mask) - Cursor *cp; - char *source, *mask; +NewBitmapCursor(Cursor *cp, char *source, char *mask) { int hotx, hoty; int sx, sy, mx, my; unsigned int sw, sh, mw, mh; Pixmap spm, mpm; spm = GetBitmap(source); if ((hotx = HotX) < 0) hotx = 0; if ((hoty = HotY) < 0) hoty = 0; mpm = GetBitmap(mask); /* make sure they are the same size */ XGetGeometry(dpy, spm, &JunkRoot, &sx, &sy, &sw, &sh, &JunkBW,&JunkDepth); XGetGeometry(dpy, mpm, &JunkRoot, &mx, &my, &mw, &mh, &JunkBW,&JunkDepth); if (sw != mw || sh != mh) { fprintf (stderr, "%s: cursor bitmaps \"%s\" and \"%s\" not the same size\n", ProgramName, source, mask); Index: xc/programs/twm/events.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/events.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 events.c --- xc/programs/twm/events.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/events.c 11 Mar 2005 16:17:25 -0000 @@ -69,184 +69,175 @@ #include "menus.h" #include "events.h" #include "resize.h" #include "parse.h" #include "gram.h" #include "util.h" #include "screen.h" #include "icons.h" #include "version.h" #define MAX_X_EVENT 256 event_proc EventHandler[MAX_X_EVENT]; /* event handler jump table */ char *Action; int Context = C_NO_CONTEXT; /* current button press context */ TwmWindow *ButtonWindow; /* button press window structure */ XEvent ButtonEvent; /* button press event */ XEvent Event; /* the current event */ TwmWindow *Tmp_win; /* the current twm window */ -/* Used in HandleEnterNotify to remove border highlight from a window +/** Used in HandleEnterNotify to remove border highlight from a window * that has not recieved a LeaveNotify event because of a pointer grab */ TwmWindow *UnHighLight_win = NULL; Window DragWindow; /* variables used in moving windows */ int origDragX; int origDragY; int DragX; int DragY; int DragWidth; int DragHeight; int CurrentDragX; int CurrentDragY; static int enter_flag; static int ColortableThrashing; static TwmWindow *enter_win, *raise_win; 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 AutoRaiseWindow (tmp) - TwmWindow *tmp; +void AutoRaiseWindow (TwmWindow *tmp) { XRaiseWindow (dpy, tmp->frame); XSync (dpy, 0); enter_win = NULL; enter_flag = TRUE; raise_win = tmp; } -void SetRaiseWindow (tmp) - TwmWindow *tmp; +void SetRaiseWindow (TwmWindow *tmp) { enter_flag = TRUE; enter_win = NULL; raise_win = tmp; XSync (dpy, 0); } -/*********************************************************************** - * - * Procedure: - * InitEvents - initialize the event jump table - * - *********************************************************************** +/** + * initialize the event jump table. */ - void InitEvents() { int i; ResizeWindow = (Window) 0; DragWindow = (Window) 0; enter_flag = FALSE; enter_win = raise_win = NULL; for (i = 0; i < MAX_X_EVENT; i++) EventHandler[i] = HandleUnknown; EventHandler[Expose] = HandleExpose; EventHandler[CreateNotify] = HandleCreateNotify; EventHandler[DestroyNotify] = HandleDestroyNotify; EventHandler[MapRequest] = HandleMapRequest; EventHandler[MapNotify] = HandleMapNotify; EventHandler[UnmapNotify] = HandleUnmapNotify; EventHandler[MotionNotify] = HandleMotionNotify; EventHandler[ButtonRelease] = HandleButtonRelease; EventHandler[ButtonPress] = HandleButtonPress; EventHandler[EnterNotify] = HandleEnterNotify; EventHandler[LeaveNotify] = HandleLeaveNotify; EventHandler[ConfigureRequest] = HandleConfigureRequest; EventHandler[ClientMessage] = HandleClientMessage; EventHandler[PropertyNotify] = HandlePropertyNotify; EventHandler[KeyPress] = HandleKeyPress; EventHandler[ColormapNotify] = HandleColormapNotify; EventHandler[VisibilityNotify] = HandleVisibilityNotify; if (HasShape) EventHandler[ShapeEventBase+ShapeNotify] = HandleShapeNotify; } Time lastTimestamp = CurrentTime; /* until Xlib does this for us */ -Bool StashEventTime (ev) - register XEvent *ev; +Bool StashEventTime (XEvent *ev) { switch (ev->type) { case KeyPress: case KeyRelease: lastTimestamp = ev->xkey.time; return True; case ButtonPress: case ButtonRelease: lastTimestamp = ev->xbutton.time; return True; case MotionNotify: lastTimestamp = ev->xmotion.time; return True; case EnterNotify: case LeaveNotify: lastTimestamp = ev->xcrossing.time; return True; case PropertyNotify: lastTimestamp = ev->xproperty.time; return True; case SelectionClear: lastTimestamp = ev->xselectionclear.time; return True; case SelectionRequest: lastTimestamp = ev->xselectionrequest.time; return True; case SelectionNotify: lastTimestamp = ev->xselection.time; return True; } return False; } -/* - * WindowOfEvent - return the window about which this event is concerned; this +/** + * return the window about which this event is concerned; this * window may not be the same as XEvent.xany.window (the first window listed * in the structure). */ -Window WindowOfEvent (e) - XEvent *e; +Window WindowOfEvent (XEvent *e) { /* * Each window subfield is marked with whether or not it is the same as * XEvent.xany.window or is different (which is the case for some of the * notify events). */ switch (e->type) { case KeyPress: case KeyRelease: return e->xkey.window; /* same */ case ButtonPress: case ButtonRelease: return e->xbutton.window; /* same */ case MotionNotify: return e->xmotion.window; /* same */ case EnterNotify: case LeaveNotify: return e->xcrossing.window; /* same */ case FocusIn: case FocusOut: return e->xfocus.window; /* same */ case KeymapNotify: return e->xkeymap.window; /* same */ case Expose: return e->xexpose.window; /* same */ case GraphicsExpose: return e->xgraphicsexpose.drawable; /* same */ case NoExpose: return e->xnoexpose.drawable; /* same */ @@ -259,149 +250,131 @@ case ReparentNotify: return e->xreparent.window; /* DIFF */ case ConfigureNotify: return e->xconfigure.window; /* DIFF */ case ConfigureRequest: return e->xconfigurerequest.window; /* DIFF */ case GravityNotify: return e->xgravity.window; /* DIFF */ case ResizeRequest: return e->xresizerequest.window; /* same */ case CirculateNotify: return e->xcirculate.window; /* DIFF */ case CirculateRequest: return e->xcirculaterequest.window; /* DIFF */ case PropertyNotify: return e->xproperty.window; /* same */ case SelectionClear: return e->xselectionclear.window; /* same */ case SelectionRequest: return e->xselectionrequest.requestor; /* DIFF */ case SelectionNotify: return e->xselection.requestor; /* same */ case ColormapNotify: return e->xcolormap.window; /* same */ case ClientMessage: return e->xclient.window; /* same */ case MappingNotify: return None; } return None; } -/*********************************************************************** - * - * Procedure: - * DispatchEvent2 - +/** * handle a single X event stored in global var Event - * this rouitine for is for a call during an f.move - * - *********************************************************************** + * this routine for is for a call during an f.move */ Bool DispatchEvent2 () { Window w = Event.xany.window; StashEventTime (&Event); if (XFindContext (dpy, w, TwmContext, (caddr_t *) &Tmp_win) == XCNOENT) Tmp_win = NULL; if (XFindContext (dpy, w, ScreenContext, (caddr_t *)&Scr) == XCNOENT) { Scr = FindScreenInfo (WindowOfEvent (&Event)); } if (!Scr) return False; if (menuFromFrameOrWindowOrTitlebar && Event.type == Expose) HandleExpose(); if (!menuFromFrameOrWindowOrTitlebar && Event.type>= 0 && Event.type < MAX_X_EVENT) { (*EventHandler[Event.type])(); } return True; } -/*********************************************************************** - * - * Procedure: - * DispatchEvent - handle a single X event stored in global var Event - * - *********************************************************************** +/** + * handle a single X event stored in global var Event */ Bool DispatchEvent () { Window w = Event.xany.window; StashEventTime (&Event); if (XFindContext (dpy, w, TwmContext, (caddr_t *) &Tmp_win) == XCNOENT) Tmp_win = NULL; if (XFindContext (dpy, w, ScreenContext, (caddr_t *)&Scr) == XCNOENT) { Scr = FindScreenInfo (WindowOfEvent (&Event)); } if (!Scr) return False; if (Event.type>= 0 && Event.type < MAX_X_EVENT) { (*EventHandler[Event.type])(); } return True; } -/*********************************************************************** - * - * Procedure: - * HandleEvents - handle X events - * - *********************************************************************** +/** + * handle X events */ - void HandleEvents() { while (TRUE) { if (enter_flag && !QLength(dpy)) { if (enter_win && enter_win != raise_win) { AutoRaiseWindow (enter_win); /* sets enter_flag T */ } else { enter_flag = FALSE; } } if (ColortableThrashing && !QLength(dpy) && Scr) { InstallWindowColormaps(ColormapNotify, (TwmWindow *) NULL); } WindowMoved = FALSE; XtAppNextEvent(appContext, &Event); if (Event.type>= 0 && Event.type < MAX_X_EVENT) (void) DispatchEvent (); else XtDispatchEvent (&Event); } } -/*********************************************************************** - * - * Procedure: - * HandleColormapNotify - colormap notify event handler +/** + * colormap notify event handler. * * This procedure handles both a client changing its own colormap, and * a client explicitly installing its colormap itself (only the window * manager should do that, so we must set it correctly). * - *********************************************************************** */ - void HandleColormapNotify() { XColormapEvent *cevent = (XColormapEvent *) &Event; ColormapWindow *cwin, **cwins; TwmColormap *cmap; int lost, won, n, number_cwins; if (XFindContext(dpy, cevent->window, ColormapContext, (caddr_t *)&cwin) == XCNOENT) return; cmap = cwin->colormap; if (cevent->new) { if (XFindContext(dpy, cevent->colormap, ColormapContext, (caddr_t *)&cwin->colormap) == XCNOENT) cwin->colormap = CreateTwmColormap(cevent->colormap); else cwin->colormap->refcnt++; @@ -513,90 +486,82 @@ ** bit back on makes sure we get back here to score ** the collision. */ cmap->state |= CM_INSTALLED; } } else if (lost != -1) { InstallWindowColormaps(ColormapNotify, (TwmWindow *) NULL); } } } else if (cevent->state == ColormapUninstalled) cmap->state &= ~CM_INSTALLED; else if (cevent->state == ColormapInstalled) cmap->state |= CM_INSTALLED; } -/*********************************************************************** - * - * Procedure: - * HandleVisibilityNotify - visibility notify event handler +/** + * visibility notify event handler. * * This routine keeps track of visibility events so that colormap * installation can keep the maximum number of useful colormaps * installed at one time. * - *********************************************************************** */ - void HandleVisibilityNotify() { XVisibilityEvent *vevent = (XVisibilityEvent *) &Event; ColormapWindow *cwin; TwmColormap *cmap; if (XFindContext(dpy, vevent->window, ColormapContext, (caddr_t *)&cwin) == XCNOENT) return; /* * when Saber complains about retreiving an from an * just type "touch vevent->state" and "cont" */ cmap = cwin->colormap; if ((cmap->state & CM_INSTALLABLE) && vevent->state != cwin->visibility && (vevent->state == VisibilityFullyObscured || cwin->visibility == VisibilityFullyObscured) && cmap->w == cwin->w) { cwin->visibility = vevent->state; InstallWindowColormaps(VisibilityNotify, (TwmWindow *) NULL); } else cwin->visibility = vevent->state; } -/*********************************************************************** - * - * Procedure: - * HandleKeyPress - key press event handler - * - *********************************************************************** - */ int MovedFromKeyPress = False; +/** + * key press event handler + */ void HandleKeyPress() { KeySym ks; FuncKey *key; int len; unsigned int modifier; if (InfoLines) XUnmapWindow(dpy, Scr->InfoWindow); Context = C_NO_CONTEXT; if (Event.xany.window == Scr->Root) Context = C_ROOT; if (Tmp_win) { if (Event.xany.window == Tmp_win->title_w) Context = C_TITLE; if (Event.xany.window == Tmp_win->w) Context = C_WINDOW; if (Event.xany.window == Tmp_win->icon_w) @@ -687,97 +652,89 @@ /* if we get here, no function key was bound to the key. Send it * to the client if it was in a window we know about. */ if (Tmp_win) { if (Event.xany.window == Tmp_win->icon_w || Event.xany.window == Tmp_win->frame || Event.xany.window == Tmp_win->title_w || (Tmp_win->list && (Event.xany.window == Tmp_win->list->w))) { Event.xkey.window = Tmp_win->w; XSendEvent(dpy, Tmp_win->w, False, KeyPressMask, &Event); } } } static void -free_window_names (tmp, nukefull, nukename, nukeicon) - TwmWindow *tmp; - Bool nukefull, nukename, nukeicon; +free_window_names (TwmWindow *tmp, Bool nukefull, Bool nukename, Bool nukeicon) { /* * XXX - are we sure that nobody ever sets these to another constant (check * twm windows)? */ if (tmp->name == tmp->full_name) nukefull = False; if (tmp->icon_name == tmp->name) nukename = False; 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) - TwmWindow *tmp; +free_cwins (TwmWindow *tmp) { int i; TwmColormap *cmap; if (tmp->cmaps.number_cwins) { for (i = 0; i < tmp->cmaps.number_cwins; i++) { if (--tmp->cmaps.cwins[i]->refcnt == 0) { cmap = tmp->cmaps.cwins[i]->colormap; if (--cmap->refcnt == 0) { XDeleteContext(dpy, cmap->c, ColormapContext); free((char *) cmap); } XDeleteContext(dpy, tmp->cmaps.cwins[i]->w, ColormapContext); free((char *) tmp->cmaps.cwins[i]); } } free((char *) tmp->cmaps.cwins); if (tmp->cmaps.number_cwins > 1) { free(tmp->cmaps.scoreboard); tmp->cmaps.scoreboard = NULL; } tmp->cmaps.number_cwins = 0; } } -/*********************************************************************** - * - * Procedure: - * HandlePropertyNotify - property notify event handler - * - *********************************************************************** +/** + * property notify event handler */ - void HandlePropertyNotify() { char *name = NULL; unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm; /* watch for standard colormap changes */ if (Event.xproperty.window == Scr->Root) { XStandardColormap *maps = NULL; int nmaps; switch (Event.xproperty.state) { case PropertyNewValue: if (XGetRGBColormaps (dpy, Scr->Root, &maps, &nmaps, Event.xproperty.atom)) { /* if got one, then replace any existing entry */ InsertRGBColormap (Event.xproperty.atom, maps, nmaps, True); } @@ -950,46 +907,42 @@ break; case XA_WM_NORMAL_HINTS: GetWindowSizeHints (Tmp_win); break; default: if (Event.xproperty.atom == _XA_WM_COLORMAP_WINDOWS) { FetchWmColormapWindows (Tmp_win); /* frees old data */ break; } else if (Event.xproperty.atom == _XA_WM_PROTOCOLS) { FetchWmProtocols (Tmp_win); break; } break; } } -/*********************************************************************** - * - * Procedure: - * RedoIconName - procedure to re-position the icon window and name - * - *********************************************************************** +/** + * procedure to re-position the icon window and name */ void RedoIconName() { int x, y; if (Tmp_win->list) { /* let the expose event cause the repaint */ XClearArea(dpy, Tmp_win->list->w, 0,0,0,0, True); if (Scr->SortIconMgr) SortIconManager(Tmp_win->list->iconmgr); } if (Tmp_win->icon_w == (Window) 0) return; if (Tmp_win->icon_not_ours) return; @@ -1017,80 +970,71 @@ y = 0; Tmp_win->icon_w_height = Tmp_win->icon_height + Scr->IconFont.height + 4; Tmp_win->icon_y = Tmp_win->icon_height + Scr->IconFont.height; XResizeWindow(dpy, Tmp_win->icon_w, Tmp_win->icon_w_width, Tmp_win->icon_w_height); if (Tmp_win->icon_bm_w) { XMoveWindow(dpy, Tmp_win->icon_bm_w, x, y); XMapWindow(dpy, Tmp_win->icon_bm_w); } if (Tmp_win->icon) { XClearArea(dpy, Tmp_win->icon_w, 0, 0, 0, 0, True); } } -/*********************************************************************** - * - * Procedure: - * HandleClientMessage - client message event handler - * - *********************************************************************** +/** + *client message event handler */ - void HandleClientMessage() { if (Event.xclient.message_type == _XA_WM_CHANGE_STATE) { if (Tmp_win != NULL) { if (Event.xclient.data.l[0] == IconicState && !Tmp_win->icon) { XEvent button; XQueryPointer( dpy, Scr->Root, &JunkRoot, &JunkChild, &(button.xmotion.x_root), &(button.xmotion.y_root), &JunkX, &JunkY, &JunkMask); ExecuteFunction(F_ICONIFY, NULLSTR, Event.xany.window, Tmp_win, &button, FRAME, FALSE); XUngrabPointer(dpy, CurrentTime); } } } } -/*********************************************************************** - * - * Procedure: - * HandleExpose - expose event handler - * - *********************************************************************** +/** + * expose event handler */ void HandleExpose() { MenuRoot *tmp; if (XFindContext(dpy, Event.xany.window, MenuContext, (caddr_t *)&tmp) == 0) { PaintMenu(tmp, &Event); return; } if (Event.xexpose.count != 0) return; if (Event.xany.window == Scr->InfoWindow && InfoLines) { int i; int height; MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back, @@ -1157,74 +1101,68 @@ Tmp_win->icon_name, strlen(Tmp_win->icon_name)); DrawIconManagerBorder(Tmp_win->list); flush_expose (Event.xany.window); return; } if (Event.xany.window == Tmp_win->list->icon) { FB(Tmp_win->list->fore, Tmp_win->list->back); XCopyPlane(dpy, Scr->siconifyPm, Tmp_win->list->icon, Scr->NormalGC, 0,0, iconifybox_width, iconifybox_height, 0, 0, 1); flush_expose (Event.xany.window); return; } } } } -static void remove_window_from_ring (tmp) - TwmWindow *tmp; +static void remove_window_from_ring (TwmWindow *tmp) { TwmWindow *prev = tmp->ring.prev, *next = tmp->ring.next; if (enter_win == tmp) { enter_flag = FALSE; enter_win = NULL; } if (raise_win == Tmp_win) raise_win = NULL; /* * 1. Unlink window * 2. If window was only thing in ring, null out ring * 3. If window was ring leader, set to next (or null) */ if (prev) prev->ring.next = next; if (next) next->ring.prev = prev; if (Scr->Ring == tmp) Scr->Ring = (next != tmp ? next : (TwmWindow *) NULL); if (!Scr->Ring || Scr->RingLeader == tmp) Scr->RingLeader = Scr->Ring; } -/*********************************************************************** - * - * Procedure: - * HandleDestroyNotify - DestroyNotify event handler - * - *********************************************************************** +/** + * DestroyNotify event handler */ - void HandleDestroyNotify() { int i; /* * Warning, this is also called by HandleUnmapNotify; if it ever needs to * look at the event, HandleUnmapNotify will have to mash the UnmapNotify * into a DestroyNotify. */ if (Tmp_win == NULL) return; if (Tmp_win == Scr->Focus) { FocusOnRoot(); } XDeleteContext(dpy, Tmp_win->w, TwmContext); XDeleteContext(dpy, Tmp_win->w, ScreenContext); @@ -1302,48 +1240,43 @@ UnHighLight_win = NULL; free((char *)Tmp_win); } void HandleCreateNotify() { #ifdef DEBUG_EVENTS fprintf(stderr, "CreateNotify w = 0x%x\n", Event.xcreatewindow.window); fflush(stderr); Bell(XkbBI_Info,0,Event.xcreatewindow.window); XSync(dpy, 0); #endif } -/*********************************************************************** - * - * Procedure: +/** * HandleMapRequest - MapRequest event handler - * - *********************************************************************** */ - void HandleMapRequest() { int stat; int zoom_save; Event.xany.window = Event.xmaprequest.window; stat = XFindContext(dpy, Event.xany.window, TwmContext, (caddr_t *)&Tmp_win); if (stat == XCNOENT) Tmp_win = NULL; /* If the window has never been mapped before ... */ if (Tmp_win == NULL) { /* Add decorations. */ Tmp_win = AddWindow(Event.xany.window, FALSE, (IconMgr *) NULL); if (Tmp_win == NULL) return; } else @@ -1390,87 +1323,77 @@ } /* If no hints, or currently an icon, just "deiconify" */ else { DeIconify(Tmp_win); SetRaiseWindow (Tmp_win); } } void SimulateMapRequest (w) Window w; { Event.xmaprequest.window = w; HandleMapRequest (); } -/*********************************************************************** - * - * Procedure: - * HandleMapNotify - MapNotify event handler - * - *********************************************************************** +/** + * MapNotify event handler */ - void HandleMapNotify() { if (Tmp_win == NULL) return; /* * Need to do the grab to avoid race condition of having server send * MapNotify to client before the frame gets mapped; this is bad because * the client would think that the window has a chance of being viewable * when it really isn't. */ XGrabServer (dpy); if (Tmp_win->icon_w) XUnmapWindow(dpy, Tmp_win->icon_w); if (Tmp_win->title_w) XMapSubwindows(dpy, Tmp_win->title_w); XMapSubwindows(dpy, Tmp_win->frame); if (Scr->Focus != Tmp_win && Tmp_win->hilite_w) XUnmapWindow(dpy, Tmp_win->hilite_w); XMapWindow(dpy, Tmp_win->frame); XUngrabServer (dpy); XFlush (dpy); Tmp_win->mapped = TRUE; Tmp_win->icon = FALSE; Tmp_win->icon_on = FALSE; } -/*********************************************************************** - * - * Procedure: - * HandleUnmapNotify - UnmapNotify event handler - * - *********************************************************************** +/** + * UnmapNotify event handler */ - void HandleUnmapNotify() { int dstx, dsty; Window dumwin; /* * The July 27, 1988 ICCCM spec states that a client wishing to switch * to WithdrawnState should send a synthetic UnmapNotify with the * event field set to (pseudo-)root, in case the window is already * unmapped (which is the case for twm for IconicState). Unfortunately, * we looked for the TwmContext using that field, so try the window * field also. */ if (Tmp_win == NULL) { Event.xany.window = Event.xunmap.window; if (XFindContext(dpy, Event.xany.window, TwmContext, (caddr_t *)&Tmp_win) == XCNOENT) Tmp_win = NULL; @@ -1499,78 +1422,69 @@ if (Tmp_win->old_bw) XSetWindowBorderWidth (dpy, Event.xunmap.window, Tmp_win->old_bw); if (Tmp_win->wmhints && (Tmp_win->wmhints->flags & IconWindowHint)) XUnmapWindow (dpy, Tmp_win->wmhints->icon_window); } else { XReparentWindow (dpy, Event.xunmap.window, Tmp_win->attr.root, dstx, dsty); RestoreWithdrawnLocation (Tmp_win); } XRemoveFromSaveSet (dpy, Event.xunmap.window); XSelectInput (dpy, Event.xunmap.window, NoEventMask); HandleDestroyNotify (); /* do not need to mash event before */ } /* else window no longer exists and we'll get a destroy notify */ XUngrabServer (dpy); XFlush (dpy); } -/*********************************************************************** - * - * Procedure: - * HandleMotionNotify - MotionNotify event handler - * - *********************************************************************** +/** + * MotionNotify event handler */ - void HandleMotionNotify() { if (ResizeWindow != (Window) 0) { XQueryPointer( dpy, Event.xany.window, &(Event.xmotion.root), &JunkChild, &(Event.xmotion.x_root), &(Event.xmotion.y_root), &(Event.xmotion.x), &(Event.xmotion.y), &JunkMask); /* Set WindowMoved appropriately so that f.deltastop will work with resize as well as move. */ if (abs (Event.xmotion.x - ResizeOrigX) >= Scr->MoveDelta || abs (Event.xmotion.y - ResizeOrigY) >= Scr->MoveDelta) WindowMoved = TRUE; XFindContext(dpy, ResizeWindow, TwmContext, (caddr_t *)&Tmp_win); DoResize(Event.xmotion.x_root, Event.xmotion.y_root, Tmp_win); } } -/*********************************************************************** - * - * Procedure: - * HandleButtonRelease - ButtonRelease event handler - * - *********************************************************************** +/** + * ButtonRelease event handler */ void HandleButtonRelease() { int xl, xr, yt, yb, w, h; unsigned mask; if (InfoLines) /* delete info box on 2nd button release */ if (Context == C_IDENTIFY) { XUnmapWindow(dpy, Scr->InfoWindow); InfoLines = 0; Context = C_NO_CONTEXT; } if (DragWindow != None) { MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0); XFindContext(dpy, DragWindow, TwmContext, (caddr_t *)&Tmp_win); if (DragWindow == Tmp_win->frame) @@ -1712,75 +1626,74 @@ ResizeWindow == None) { XUngrabPointer(dpy, CurrentTime); XUngrabServer(dpy); XFlush(dpy); EventHandler[EnterNotify] = HandleEnterNotify; EventHandler[LeaveNotify] = HandleLeaveNotify; ButtonPressed = -1; if (DownIconManager) { DownIconManager->down = FALSE; if (Scr->Highlight) DrawIconManagerBorder(DownIconManager); DownIconManager = NULL; } Cancel = FALSE; } } +/** + * + * \param menu menu to pop up + * \param w invoking window, or None + */ static void -do_menu (menu, w) - MenuRoot *menu; /* menu to pop up */ - Window w; /* invoking window or None */ +do_menu (MenuRoot *menu, Window w) { int x = Event.xbutton.x_root; int y = Event.xbutton.y_root; Bool center; if (!Scr->NoGrabServer) XGrabServer(dpy); if (w) { int h = Scr->TBInfo.width - Scr->TBInfo.border; Window child; (void) XTranslateCoordinates (dpy, w, Scr->Root, 0, h, &x, &y, &child); center = False; } else { center = True; } if (PopUpMenu (menu, x, y, center)) { UpdateMenu(); } else { Bell(XkbBI_MinorError,0,w); } } -/*********************************************************************** - * - * Procedure: - * HandleButtonPress - ButtonPress event handler - * - *********************************************************************** +/** + * ButtonPress event handler */ void 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(); XSync(dpy, 0); /* XXX - remove? */ if (ButtonPressed != -1 && !InfoLines) /* want menus if we have info box */ { /* we got another butt press in addition to one still held @@ -1981,95 +1894,81 @@ Action, Event.xany.window, Tmp_win, &Event, Context, FALSE); } else if (Scr->DefaultFunction.func != 0) { if (Scr->DefaultFunction.func == F_MENU) { do_menu (Scr->DefaultFunction.menu, (Window) None); } else { Action = Scr->DefaultFunction.item ? Scr->DefaultFunction.item->action : NULL; ExecuteFunction(Scr->DefaultFunction.func, Action, Event.xany.window, Tmp_win, &Event, Context, FALSE); } } } -/*********************************************************************** - * - * Procedure: - * HENQueueScanner - EnterNotify event q scanner +/** \fn HENQueueScanner + * EnterNotify event q scanner. * * Looks at the queued events and determines if any matching * LeaveNotify events or EnterEvents deriving from the * termination of a grab are behind this event to allow * skipping of unnecessary processing. - * - *********************************************************************** */ - typedef struct HENScanArgs { - Window w; /* Window we are currently entering */ - Bool leaves; /* Any LeaveNotifies found for this window */ - Bool inferior; /* Was NotifyInferior the mode for LeaveNotify */ - Bool enters; /* Any EnterNotify events with NotifyUngrab */ + Window w; /**< Window we are currently entering */ + Bool leaves; /**< Any LeaveNotifies found for this window */ + Bool inferior; /**< Was NotifyInferior the mode for LeaveNotify */ + Bool enters; /**< Any EnterNotify events with NotifyUngrab */ } HENScanArgs; -/* ARGSUSED*/ static Bool -HENQueueScanner(dpy, ev, args) - Display *dpy; - XEvent *ev; - char *args; +HENQueueScanner(Display *dpy, XEvent *ev, char *args) { if (ev->type == LeaveNotify) { if (ev->xcrossing.window == ((HENScanArgs *) args)->w && ev->xcrossing.mode == NotifyNormal) { ((HENScanArgs *) args)->leaves = True; /* * Only the last event found matters for the Inferior field. */ ((HENScanArgs *) args)->inferior = (ev->xcrossing.detail == NotifyInferior); } } else if (ev->type == EnterNotify) { if (ev->xcrossing.mode == NotifyUngrab) ((HENScanArgs *) args)->enters = True; } return (False); } -/*********************************************************************** - * - * Procedure: - * HandleEnterNotify - EnterNotify event handler - * - *********************************************************************** +/** + * EnterNotify event handler */ - void HandleEnterNotify() { MenuRoot *mr; XEnterWindowEvent *ewp = &Event.xcrossing; HENScanArgs scanArgs; XEvent dummy; /* * Save the id of the window entered. This will be used to remove * border highlight on entering the next application window. */ if (UnHighLight_win && ewp->window != UnHighLight_win->w) { SetBorder (UnHighLight_win, False); /* application window */ if (UnHighLight_win->list) /* in the icon box */ NotActiveIconManager(UnHighLight_win->list); } if (ewp->window == Scr->Root) UnHighLight_win = NULL; else if (Tmp_win) @@ -2189,84 +2088,71 @@ mr->entered = TRUE; if (ActiveMenu && mr == ActiveMenu->prev && RootFunction == 0) { if (Scr->Shadow) XUnmapWindow (dpy, ActiveMenu->shadow); XUnmapWindow (dpy, ActiveMenu->w); ActiveMenu->mapped = UNMAPPED; UninstallRootColormap (); if (ActiveItem) { ActiveItem->state = 0; PaintEntry (ActiveMenu, ActiveItem, False); } ActiveItem = NULL; ActiveMenu = mr; MenuDepth--; } return; } -/*********************************************************************** - * - * Procedure: - * HLNQueueScanner - LeaveNotify event q scanner +/** \fn HLNQueueScanner + * LeaveNotify event q scanner. * * Looks at the queued events and determines if any * EnterNotify events are behind this event to allow * skipping of unnecessary processing. - * - *********************************************************************** */ typedef struct HLNScanArgs { - Window w; /* The window getting the LeaveNotify */ - Bool enters; /* Any EnterNotify event at all */ - Bool matches; /* Any matching EnterNotify events */ + Window w; /**< The window getting the LeaveNotify */ + Bool enters; /**< Any EnterNotify event at all */ + Bool matches; /**< Any matching EnterNotify events */ } HLNScanArgs; -/* ARGSUSED*/ static Bool -HLNQueueScanner(dpy, ev, args) - Display *dpy; - XEvent *ev; - char *args; +HLNQueueScanner(Display *dpy, XEvent *ev, char *args) { if (ev->type == EnterNotify && ev->xcrossing.mode != NotifyGrab) { ((HLNScanArgs *) args)->enters = True; if (ev->xcrossing.window == ((HLNScanArgs *) args)->w) ((HLNScanArgs *) args)->matches = True; } return (False); } -/*********************************************************************** - * - * Procedure: - * HandleLeaveNotify - LeaveNotify event handler - * - *********************************************************************** +/** + * LeaveNotify event handler */ - void HandleLeaveNotify() { HLNScanArgs scanArgs; XEvent dummy; if (Tmp_win != NULL) { Bool inicon; /* * We're not interested in pseudo Enter/Leave events generated * from grab initiations and terminations. */ if (Event.xcrossing.mode != NotifyNormal) return; inicon = (Tmp_win->list && Tmp_win->list->w == Event.xcrossing.window); @@ -2305,48 +2191,43 @@ if (Tmp_win->hilite_w) XUnmapWindow (dpy, Tmp_win->hilite_w); SetBorder (Tmp_win, False); if (Scr->TitleFocus || Tmp_win->protocols & DoesWmTakeFocus) SetFocus ((TwmWindow *) NULL, Event.xcrossing.time); Scr->Focus = NULL; } else if (Event.xcrossing.window == Tmp_win->w && !scanArgs.enters) { InstallWindowColormaps (LeaveNotify, &Scr->TwmRoot); } } } XSync (dpy, 0); return; } } -/*********************************************************************** - * - * Procedure: +/** * HandleConfigureRequest - ConfigureRequest event handler - * - *********************************************************************** */ - void HandleConfigureRequest() { XWindowChanges xwc; unsigned long xwcm; int x, y, width, height, bw; int gravx, gravy; XConfigureRequestEvent *cre = &Event.xconfigurerequest; #ifdef DEBUG_EVENTS fprintf(stderr, "ConfigureRequest\n"); if (cre->value_mask & CWX) fprintf(stderr, " x = %d\n", cre->x); if (cre->value_mask & CWY) fprintf(stderr, " y = %d\n", cre->y); if (cre->value_mask & CWWidth) fprintf(stderr, " width = %d\n", cre->width); if (cre->value_mask & CWHeight) fprintf(stderr, " height = %d\n", cre->height); if (cre->value_mask & CWSibling) @@ -2440,171 +2321,139 @@ } if (cre->value_mask & CWHeight) { height = cre->height + Tmp_win->title_height; } if (width != Tmp_win->frame_width || height != Tmp_win->frame_height) Tmp_win->zoomed = ZOOM_NONE; /* * SetupWindow (x,y) are the location of the upper-left outer corner and * are passed directly to XMoveResizeWindow (frame). The (width,height) * are the inner size of the frame. The inner width is the same as the * requested client window width; the inner height is the same as the * requested client window height plus any title bar slop. */ SetupWindow (Tmp_win, x, y, width, height, bw); } -/*********************************************************************** - * - * Procedure: - * HandleShapeNotify - shape notification event handler - * - *********************************************************************** +/** + * shape notification event handler */ void HandleShapeNotify () { XShapeEvent *sev = (XShapeEvent *) &Event; if (Tmp_win == NULL) return; if (sev->kind != ShapeBounding) return; if (!Tmp_win->wShaped && sev->shaped) { XShapeCombineMask (dpy, Tmp_win->frame, ShapeClip, 0, 0, None, ShapeSet); } Tmp_win->wShaped = sev->shaped; SetFrameShape (Tmp_win); } -/*********************************************************************** - * - * Procedure: - * HandleUnknown - unknown event handler - * - *********************************************************************** +/** + * unknown event handler */ - void HandleUnknown() { #ifdef DEBUG_EVENTS fprintf(stderr, "type = %d\n", Event.type); #endif } -/*********************************************************************** +/** + * checks to see if the window is a transient. * - * Procedure: - * Transient - checks to see if the window is a transient + * \return TRUE if window is a transient + * \return FALSE if window is not a transient * - * Returned Value: - * TRUE - window is a transient - * FALSE - window is not a transient - * - * Inputs: - * w - the window to check - * - *********************************************************************** + * \param w the window to check */ - int -Transient(w, propw) - Window w, *propw; +Transient(Window w, Window *propw) { return (XGetTransientForHint(dpy, w, propw)); } -/*********************************************************************** - * - * Procedure: - * FindScreenInfo - get ScreenInfo struct associated with a given window - * - * Returned Value: - * ScreenInfo struct +/** + * get ScreenInfo struct associated with a given window * - * Inputs: - * w - the window - * - *********************************************************************** + * \return ScreenInfo struct + * \param w the window */ - ScreenInfo * FindScreenInfo(w) Window w; { XWindowAttributes attr; int scrnum; attr.screen = NULL; if (XGetWindowAttributes(dpy, w, &attr)) { for (scrnum = 0; scrnum < NumScreens; scrnum++) { if (ScreenList[scrnum] != NULL && (ScreenOfDisplay(dpy, ScreenList[scrnum]->screen) == attr.screen)) return ScreenList[scrnum]; } } return NULL; } static void flush_expose (w) Window w; { XEvent dummy; /* SUPPRESS 530 */ while (XCheckTypedWindowEvent (dpy, w, Expose, &dummy)) ; } -/*********************************************************************** - * - * Procedure: - * InstallWindowColormaps - install the colormaps for one twm window +/** + * install the colormaps for one twm window. * - * Inputs: - * type - type of event that caused the installation - * tmp - for a subset of event types, the address of the + * \param type type of event that caused the installation + * \param tmp for a subset of event types, the address of the * window structure, whose colormaps are to be installed. - * - *********************************************************************** */ void -InstallWindowColormaps (type, tmp) - int type; - TwmWindow *tmp; +InstallWindowColormaps (int type, TwmWindow *tmp) { int i, j, n, number_cwins, state; ColormapWindow **cwins, *cwin, **maxcwin = NULL; TwmColormap *cmap; char *row, *scoreboard; switch (type) { case EnterNotify: case LeaveNotify: case DestroyNotify: default: /* Save the colormap to be loaded for when force loading of * root colormap(s) ends. */ Scr->cmapInfo.pushed_window = tmp; /* Don't load any new colormap if root colormap(s) has been * force loaded. */ if (Scr->cmapInfo.root_pushes) return; @@ -2659,125 +2508,119 @@ } Scr->cmapInfo.first_req = NextRequest(dpy); for ( ; n > 0 && maxcwin >= cwins; maxcwin--) { cmap = (*maxcwin)->colormap; if (cmap->state & CM_INSTALL) { cmap->state &= ~CM_INSTALL; if (!(state & CM_INSTALLED)) { cmap->install_req = NextRequest(dpy); XInstallColormap(dpy, cmap->c); } cmap->state |= CM_INSTALLED; n--; } } } -/*********************************************************************** +/** \fn InstallRootColormap + * \fn UninstallRootColormap * - * Procedures: - * nstallRootColormap - Force (un)loads root colormap(s) + * Force (un)loads root colormap(s) * * These matching routines provide a mechanism to insure that * the root colormap(s) is installed during operations like * rubber banding or menu display that require colors from * that colormap. Calls may be nested arbitrarily deeply, * as long as there is one UninstallRootColormap call per * InstallRootColormap call. * * The final UninstallRootColormap will cause the colormap list * which would otherwise have be loaded to be loaded, unless * Enter or Leave Notify events are queued, indicating some * other colormap list would potentially be loaded anyway. - *********************************************************************** */ void InstallRootColormap() { TwmWindow *tmp; if (Scr->cmapInfo.root_pushes == 0) { /* * The saving and restoring of cmapInfo.pushed_window here * is a slimy way to remember the actual pushed list and * not that of the root window. */ tmp = Scr->cmapInfo.pushed_window; InstallWindowColormaps(0, &Scr->TwmRoot); Scr->cmapInfo.pushed_window = tmp; } Scr->cmapInfo.root_pushes++; } -/* ARGSUSED*/ static Bool -UninstallRootColormapQScanner(dpy, ev, args) - Display *dpy; - XEvent *ev; - char *args; +UninstallRootColormapQScanner(Display *dpy, XEvent *ev, char *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; XEvent dummy; if (Scr->cmapInfo.root_pushes) Scr->cmapInfo.root_pushes--; if (!Scr->cmapInfo.root_pushes) { /* * If we have subsequent Enter or Leave Notify events, * we can skip the reload of pushed colormaps. */ XSync (dpy, 0); args = 0; (void) XCheckIfEvent(dpy, &dummy, UninstallRootColormapQScanner, &args); if (!args) InstallWindowColormaps(0, Scr->cmapInfo.pushed_window); } } #ifdef TRACE void -dumpevent (e) - XEvent *e; +dumpevent (XEvent *e) { char *name = NULL; switch (e->type) { case KeyPress: name = "KeyPress"; break; case KeyRelease: name = "KeyRelease"; break; case ButtonPress: name = "ButtonPress"; break; case ButtonRelease: name = "ButtonRelease"; break; case MotionNotify: name = "MotionNotify"; break; case EnterNotify: name = "EnterNotify"; break; case LeaveNotify: name = "LeaveNotify"; break; case FocusIn: name = "FocusIn"; break; case FocusOut: name = "FocusOut"; break; case KeymapNotify: name = "KeymapNotify"; break; case Expose: name = "Expose"; break; case GraphicsExpose: name = "GraphicsExpose"; break; case NoExpose: name = "NoExpose"; break; case VisibilityNotify: name = "VisibilityNotify"; break; case CreateNotify: name = "CreateNotify"; break; case DestroyNotify: name = "DestroyNotify"; break; Index: xc/programs/twm/gc.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/gc.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 gc.c --- xc/programs/twm/gc.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/gc.c 11 Mar 2005 16:17:25 -0000 @@ -7,92 +7,87 @@ documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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. */ -/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ -/** Salt Lake City, Utah **/ -/** Cambridge, Massachusetts **/ -/** **/ -/** All Rights Reserved **/ -/** **/ -/** Permission to use, copy, modify, and distribute this software and **/ -/** its documentation for any purpose and without fee is hereby **/ -/** granted, provided that the above copyright notice appear in all **/ -/** copies and that both that copyright notice and this permis- **/ -/** sion notice appear in supporting documentation, and that the **/ -/** name of Evans & Sutherland not be used in advertising **/ -/** in publicity pertaining to distribution of the software without **/ -/** specific, written prior permission. **/ -/** **/ -/** EVANS & SUTHERLAND DISCLAIMs ALL WARRANTIES WITH REGARD **/ -/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ -/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND **/ -/** BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ -/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ -/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ -/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ -/** OR PERFORMANCE OF THIS SOFTWARE. **/ -/*****************************************************************************/ +/* Copyright 1988 by Evans & Sutherland Computer Corporation, */ +/* Salt Lake City, Utah */ +/* Cambridge, Massachusetts */ +/* */ +/* All Rights Reserved */ +/* */ +/* Permission to use, copy, modify, and distribute this software and */ +/* its documentation for any purpose and without fee is hereby */ +/* granted, provided that the above copyright notice appear in all */ +/* copies and that both that copyright notice and this permis- */ +/* sion notice appear in supporting documentation, and that the */ +/* name of Evans & Sutherland not be used in advertising */ +/* in publicity pertaining to distribution of the software without */ +/* specific, written prior permission. */ +/* */ +/* EVANS & SUTHERLAND DISCLAIMs ALL WARRANTIES WITH REGARD */ +/* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- */ +/* ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND */ +/* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- */ +/* AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA */ +/* OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER */ +/* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE */ +/* OR PERFORMANCE OF THIS SOFTWARE. */ +/*********************************************************************(*****/ /* $XFree86: xc/programs/twm/gc.c,v 1.5 2001/01/17 23:45:06 dawes Exp $ */ /********************************************************************** * * $Xorg: gc.c,v 1.4 2001/02/09 02:05:36 xorgcvs Exp $ * * Open the fonts and create the GCs * * 31-Mar-88 Tom LaStrange Initial Version. * **********************************************************************/ #include #include "twm.h" #include "util.h" #include "screen.h" #include "gc.h" -/*********************************************************************** - * - * Procedure: - * CreateGCs - open fonts and create all the needed GC's. I only +/** \fn CreateGCs + * open fonts and create all the needed GC's. I only * want to do this once, hence the first_time flag. - * - *********************************************************************** */ - void CreateGCs() { static ScreenInfo *prevScr = NULL; XGCValues gcv; unsigned long gcm; if (!Scr->FirstTime || prevScr == Scr) return; prevScr = Scr; /* create GC's */ gcm = 0; gcm |= GCFunction; gcv.function = GXxor; gcm |= GCLineWidth; gcv.line_width = 0; gcm |= GCForeground; gcv.foreground = Scr->XORvalue; gcm |= GCSubwindowMode; gcv.subwindow_mode = IncludeInferiors; Index: xc/programs/twm/gram.y =================================================================== RCS file: /cvs/xorg/xc/programs/twm/gram.y,v retrieving revision 1.2 diff -u -2 -0 -r1.2 gram.y --- xc/programs/twm/gram.y 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/gram.y 11 Mar 2005 16:17:26 -0000 @@ -734,158 +734,147 @@ *o = n; break; case '\n': i++; /* punt */ o--; /* to account for o++ at end of loop */ break; case '\"': case '\'': case '\\': default: *o = *i++; break; } } else *o = *i++; } *o = '\0'; } -static MenuRoot *GetRoot(name, fore, back) -char *name; -char *fore, *back; +static MenuRoot *GetRoot(char *name, char* fore, char *back) { MenuRoot *tmp; tmp = FindMenuRoot(name); if (tmp == NULL) tmp = NewMenuRoot(name); if (fore) { int save; save = Scr->FirstTime; Scr->FirstTime = TRUE; GetColor(COLOR, &tmp->hi_fore, fore); GetColor(COLOR, &tmp->hi_back, back); Scr->FirstTime = save; } return tmp; } -static void GotButton(butt, func) -int butt, func; +static void GotButton(int butt, int func) { int i; for (i = 0; i < NUM_CONTEXTS; i++) { if ((cont & (1 << i)) == 0) continue; Scr->Mouse[butt][i][mods].func = func; if (func == F_MENU) { pull->prev = NULL; Scr->Mouse[butt][i][mods].menu = pull; } else { root = GetRoot(TWM_ROOT, NULLSTR, NULLSTR); Scr->Mouse[butt][i][mods].item = AddToMenu(root,"x",Action, NULL, func, NULLSTR, NULLSTR); } } Action = ""; pull = NULL; cont = 0; mods_used |= mods; mods = 0; } -static void GotKey(key, func) -char *key; -int func; +static void GotKey(char *key, int func) { int i; for (i = 0; i < NUM_CONTEXTS; i++) { if ((cont & (1 << i)) == 0) continue; if (!AddFuncKey(key, i, mods, func, Name, Action)) break; } Action = ""; pull = NULL; cont = 0; mods_used |= mods; mods = 0; } -static void GotTitleButton (bitmapname, func, rightside) - char *bitmapname; - int func; - Bool rightside; +static void GotTitleButton (char *bitmapname, int func, Bool rightside) { if (!CreateTitleButton (bitmapname, func, Action, pull, rightside, True)) { twmrc_error_prefix(); fprintf (stderr, "unable to create %s titlebutton \"%s\"\n", rightside ? "right" : "left", bitmapname); } Action = ""; pull = NULL; } -static Bool CheckWarpScreenArg (s) - register char *s; +static Bool CheckWarpScreenArg (char *s) { XmuCopyISOLatin1Lowered (s, s); if (strcmp (s, WARPSCREEN_NEXT) == 0 || strcmp (s, WARPSCREEN_PREV) == 0 || strcmp (s, WARPSCREEN_BACK) == 0) return True; for (; *s && isascii(*s) && isdigit(*s); s++) ; /* SUPPRESS 530 */ return (*s ? False : True); } -static Bool CheckWarpRingArg (s) - register char *s; +static Bool CheckWarpRingArg (char *s) { XmuCopyISOLatin1Lowered (s, s); if (strcmp (s, WARPSCREEN_NEXT) == 0 || strcmp (s, WARPSCREEN_PREV) == 0) return True; return False; } -static Bool CheckColormapArg (s) - register char *s; +static Bool CheckColormapArg (char *s) { XmuCopyISOLatin1Lowered (s, s); if (strcmp (s, COLORMAP_NEXT) == 0 || strcmp (s, COLORMAP_PREV) == 0 || strcmp (s, COLORMAP_DEFAULT) == 0) return True; return False; } void twmrc_error_prefix () { fprintf (stderr, "%s: line %d: ", ProgramName, yylineno); } Index: xc/programs/twm/iconmgr.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/iconmgr.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 iconmgr.c --- xc/programs/twm/iconmgr.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/iconmgr.c 11 Mar 2005 16:17:26 -0000 @@ -38,55 +38,43 @@ #include #include "twm.h" #include "util.h" #include "parse.h" #include "screen.h" #include "resize.h" #include "add_window.h" #include "siconify.bm" #include #include #ifdef macII int strcmp(); /* missing from string.h in AUX 2.0 */ #endif int iconmgr_textx = siconify_width+11; WList *Active = NULL; WList *DownIconManager = NULL; int iconifybox_width = siconify_width; int iconifybox_height = siconify_height; -/*********************************************************************** - * - * Procedure: - * CreateIconManagers - creat all the icon manager windows - * for this screen. - * - * Returned Value: - * none - * - * Inputs: - * none - * - *********************************************************************** +/** + * create all the icon manager windows for this screen. */ - void CreateIconManagers() { IconMgr *p; int mask; char str[100]; char str1[100]; Pixel background; char *icon_name; if (Scr->NoIconManagers) return; if (Scr->siconifyPm == None) { Scr->siconifyPm = XCreatePixmapFromBitmapData(dpy, Scr->Root, (char *)siconify_bits, siconify_width, siconify_height, 1, 0, 1); } for (p = &Scr->iconmgr; p != NULL; p = p->next) { @@ -111,116 +99,96 @@ sprintf(str, "%s Icon Manager", p->name); sprintf(str1, "%s Icons", p->name); if (p->icon_name) icon_name = p->icon_name; else icon_name = str1; XSetStandardProperties(dpy, p->w, str, icon_name, None, NULL, 0, NULL); p->twm_win = AddWindow(p->w, TRUE, p); SetMapStateProp (p->twm_win, WithdrawnState); } for (p = &Scr->iconmgr; p != NULL; p = p->next) { GrabButtons(p->twm_win); GrabKeys(p->twm_win); } } -/*********************************************************************** +/** + * allocate a new icon manager * - * Procedure: - * AllocateIconManager - allocate a new icon manager - * - * Inputs: - * name - the name of this icon manager - * icon_name - the name of the associated icon - * geom - a geometry string to eventually parse - * columns - the number of columns this icon manager has - * - *********************************************************************** + * \param name the name of this icon manager + * \param con_name the name of the associated icon + * \param geom a geometry string to eventually parse + * \param columns the number of columns this icon manager has */ - -IconMgr *AllocateIconManager(name, icon_name, geom, columns) - char *name; - char *geom; - char *icon_name; - int columns; +IconMgr *AllocateIconManager(char *name, char *icon_name, char *geom, int columns) { IconMgr *p; #ifdef DEBUG_ICONMGR fprintf(stderr, "AllocateIconManager\n"); fprintf(stderr, " name=\"%s\" icon_name=\"%s\", geom=\"%s\", col=%d\n", name, icon_name, geom, columns); #endif if (Scr->NoIconManagers) return NULL; p = (IconMgr *)malloc(sizeof(IconMgr)); p->name = name; p->icon_name = icon_name; p->geometry = geom; p->columns = columns; p->first = NULL; p->last = NULL; p->active = NULL; p->scr = Scr; p->count = 0; p->x = 0; p->y = 0; p->width = 150; p->height = 10; Scr->iconmgr.lasti->next = p; p->prev = Scr->iconmgr.lasti; Scr->iconmgr.lasti = p; p->next = NULL; return(p); } -/*********************************************************************** - * - * Procedure: - * MoveIconManager - move the pointer around in an icon manager +/** + * move the pointer around in an icon manager * - * Inputs: - * dir - one of the following: - * F_FORWICONMGR - forward in the window list - * F_BACKICONMGR - backward in the window list - * F_UPICONMGR - up one row - * F_DOWNICONMGR - down one row - * F_LEFTICONMGR - left one column - * F_RIGHTICONMGR - right one column - * - * Special Considerations: - * none - * - *********************************************************************** + * \param dir one of the following: + * - F_FORWICONMGR: forward in the window list + * - F_BACKICONMGR: backward in the window list + * - F_UPICONMGR: up one row + * - F_DOWNICONMG: down one row + * - F_LEFTICONMGR: left one column + * - F_RIGHTICONMGR: right one column */ - -void MoveIconManager(dir) - int dir; +void MoveIconManager(int dir) { IconMgr *ip; WList *tmp = NULL; int cur_row, cur_col, new_row, new_col; int row_inc, col_inc; int got_it; if (!Active) return; cur_row = Active->row; cur_col = Active->col; ip = Active->iconmgr; row_inc = 0; col_inc = 0; got_it = FALSE; switch (dir) { case F_FORWICONMGR: @@ -296,56 +264,48 @@ if (tmp == NULL) return; /* raise the frame so the icon manager is visible */ if (ip->twm_win->mapped) { XRaiseWindow(dpy, ip->twm_win->frame); XWarpPointer(dpy, None, tmp->icon, 0,0,0,0, 5, 5); } else { if (tmp->twm->title_height) { int tbx = Scr->TBInfo.titlex; int x = tmp->twm->highlightx; XWarpPointer (dpy, None, tmp->twm->title_w, 0, 0, 0, 0, tbx + (x - tbx) / 2, Scr->TitleHeight / 4); } else { XWarpPointer (dpy, None, tmp->twm->w, 0, 0, 0, 0, 5, 5); } } } -/*********************************************************************** - * - * Procedure: - * JumpIconManager - jump from one icon manager to another, - * possibly even on another screen - * - * Inputs: - * dir - one of the following: - * F_NEXTICONMGR - go to the next icon manager - * F_PREVICONMGR - go to the previous one - * - *********************************************************************** +/** + * jump from one icon manager to another, possibly even on another screen + * \param dir one of the following: + * - F_NEXTICONMGR - go to the next icon manager + * - F_PREVICONMGR - go to the previous one */ -void JumpIconManager(dir) - register int dir; +void JumpIconManager(int dir) { IconMgr *ip, *tmp_ip = NULL; int got_it = FALSE; ScreenInfo *sp; int screen; if (!Active) return; #define ITER(i) (dir == F_NEXTICONMGR ? (i)->next : (i)->prev) #define IPOFSP(sp) (dir == F_NEXTICONMGR ? &(sp->iconmgr) : sp->iconmgr.lasti) #define TEST(ip) if ((ip)->count != 0 && (ip)->twm_win->mapped) \ { got_it = TRUE; break; } ip = Active->iconmgr; for (tmp_ip = ITER(ip); tmp_ip; tmp_ip = ITER(tmp_ip)) { TEST (tmp_ip); } if (!got_it) { @@ -368,53 +328,46 @@ } } #undef ITER #undef IPOFSP #undef TEST if (!got_it) { Bell(XkbBI_MinorError,0,None); return; } /* raise the frame so it is visible */ XRaiseWindow(dpy, tmp_ip->twm_win->frame); if (tmp_ip->active) XWarpPointer(dpy, None, tmp_ip->active->icon, 0,0,0,0, 5, 5); else XWarpPointer(dpy, None, tmp_ip->w, 0,0,0,0, 5, 5); } -/*********************************************************************** - * - * Procedure: - * AddIconManager - add a window to an icon manager - * - * Inputs: - * tmp_win - the TwmWindow structure +/** + * add a window to an icon manager * - *********************************************************************** + * \param tmp_win the TwmWindow structure */ - -WList *AddIconManager(tmp_win) - TwmWindow *tmp_win; +WList *AddIconManager(TwmWindow *tmp_win) { WList *tmp; int h; unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ IconMgr *ip; tmp_win->list = NULL; if (tmp_win->iconmgr || tmp_win->transient || Scr->NoIconManagers) return NULL; if (LookInList(Scr->IconMgrNoShow, tmp_win->full_name, &tmp_win->class)) return NULL; if (Scr->IconManagerDontShow && !LookInList(Scr->IconMgrShow, tmp_win->full_name, &tmp_win->class)) return NULL; if ((ip = (IconMgr *)LookInList(Scr->IconMgrs, tmp_win->full_name, &tmp_win->class)) == NULL) ip = &Scr->iconmgr; @@ -481,57 +434,47 @@ XMapWindow(dpy, tmp->w); XSaveContext(dpy, tmp->w, IconManagerContext, (caddr_t) tmp); XSaveContext(dpy, tmp->w, TwmContext, (caddr_t) tmp_win); XSaveContext(dpy, tmp->w, ScreenContext, (caddr_t) Scr); XSaveContext(dpy, tmp->icon, TwmContext, (caddr_t) tmp_win); XSaveContext(dpy, tmp->icon, ScreenContext, (caddr_t) Scr); tmp_win->list = tmp; if (!ip->twm_win->icon) { XMapWindow(dpy, ip->w); XMapWindow(dpy, ip->twm_win->frame); } if (Active == NULL) Active = tmp; return (tmp); } -/*********************************************************************** - * - * Procedure: - * InsertInIconManager - put an allocated entry into an icon - * manager +/** + * put an allocated entry into an icon manager * - * Inputs: - * ip - the icon manager pointer - * tmp - the entry to insert - * - *********************************************************************** + * \param ip the icon manager pointer + * \param tmp the entry to insert */ - -void InsertInIconManager(ip, tmp, tmp_win) - IconMgr *ip; - WList *tmp; - TwmWindow *tmp_win; +void InsertInIconManager(IconMgr *ip, WList *tmp, TwmWindow *tmp_win) { WList *tmp1; int added; int (*compar)(const char *, const char *) = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); added = FALSE; if (ip->first == NULL) { ip->first = tmp; tmp->prev = NULL; ip->last = tmp; added = TRUE; } else if (Scr->SortIconMgr) { for (tmp1 = ip->first; tmp1 != NULL; tmp1 = tmp1->next) { if ((*compar)(tmp_win->icon_name, tmp1->twm->icon_name) < 0) { @@ -539,195 +482,168 @@ tmp->prev = tmp1->prev; tmp1->prev = tmp; if (tmp->prev == NULL) ip->first = tmp; else tmp->prev->next = tmp; added = TRUE; break; } } } if (!added) { ip->last->next = tmp; tmp->prev = ip->last; ip->last = tmp; } } -void RemoveFromIconManager(ip, tmp) - IconMgr *ip; - WList *tmp; +void RemoveFromIconManager(IconMgr *ip, WList *tmp) { if (tmp->prev == NULL) ip->first = tmp->next; else tmp->prev->next = tmp->next; if (tmp->next == NULL) ip->last = tmp->prev; else tmp->next->prev = tmp->prev; } -/*********************************************************************** - * - * Procedure: - * RemoveIconManager - remove a window from the icon manager - * - * Inputs: - * tmp_win - the TwmWindow structure - * - *********************************************************************** +/** + * remove a window from the icon manager + * \param tmp_win the TwmWindow structure */ - -void RemoveIconManager(tmp_win) - TwmWindow *tmp_win; +void RemoveIconManager(TwmWindow *tmp_win) { IconMgr *ip; WList *tmp; if (tmp_win->list == NULL) return; tmp = tmp_win->list; tmp_win->list = NULL; ip = tmp->iconmgr; RemoveFromIconManager(ip, tmp); XDeleteContext(dpy, tmp->icon, TwmContext); XDeleteContext(dpy, tmp->icon, ScreenContext); XDestroyWindow(dpy, tmp->icon); XDeleteContext(dpy, tmp->w, IconManagerContext); XDeleteContext(dpy, tmp->w, TwmContext); XDeleteContext(dpy, tmp->w, ScreenContext); XDestroyWindow(dpy, tmp->w); ip->count -= 1; free((char *) tmp); PackIconManager(ip); if (ip->count == 0) { XUnmapWindow(dpy, ip->twm_win->frame); } } -void ActiveIconManager(active) - WList *active; +void ActiveIconManager(WList *active) { active->active = TRUE; Active = active; Active->iconmgr->active = active; DrawIconManagerBorder(active); } -void NotActiveIconManager(active) - WList *active; +void NotActiveIconManager(WList *active) { active->active = FALSE; DrawIconManagerBorder(active); } -void DrawIconManagerBorder(tmp) - WList *tmp; +void DrawIconManagerBorder(WList *tmp) { { XSetForeground(dpy, Scr->NormalGC, tmp->fore); XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 2, 2, tmp->width-5, tmp->height-5); if (tmp->active && Scr->Highlight) XSetForeground(dpy, Scr->NormalGC, tmp->highlight); else XSetForeground(dpy, Scr->NormalGC, tmp->back); XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 0, 0, tmp->width-1, tmp->height-1); XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 1, 1, tmp->width-3, tmp->height-3); } } -/*********************************************************************** - * - * Procedure: - * SortIconManager - sort the dude - * - * Inputs: - * ip - a pointer to the icon manager struture +/** + * sort The Dude * - *********************************************************************** + * \param ip a pointer to the icon manager struture */ - -void SortIconManager(ip) - IconMgr *ip; +void SortIconManager(IconMgr *ip) { WList *tmp1, *tmp2; int done; int (*compar)(const char *, const char *) = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); if (ip == NULL) ip = Active->iconmgr; done = FALSE; do { for (tmp1 = ip->first; tmp1 != NULL; tmp1 = tmp1->next) { if ((tmp2 = tmp1->next) == NULL) { done = TRUE; break; } if ((*compar)(tmp1->twm->icon_name, tmp2->twm->icon_name) > 0) { /* take it out and put it back in */ RemoveFromIconManager(ip, tmp2); InsertInIconManager(ip, tmp2, tmp2->twm); break; } } } while (!done); PackIconManager(ip); } -/*********************************************************************** - * - * Procedure: - * PackIconManager - pack the icon manager windows following +/** + * pack the icon manager windows following * an addition or deletion * - * Inputs: - * ip - a pointer to the icon manager struture - * - *********************************************************************** + * \param ip a pointer to the icon manager struture */ - -void PackIconManager(ip) - IconMgr *ip; +void PackIconManager(IconMgr *ip) { int newwidth, i, row, col, maxcol, colinc, rowinc, wheight, wwidth; int new_x, new_y; int savewidth; WList *tmp; wheight = Scr->IconManagerFont.height + 10; if (wheight < (siconify_height + 4)) wheight = siconify_height + 4; wwidth = ip->width / ip->columns; rowinc = wheight; colinc = wwidth; row = 0; col = ip->columns; maxcol = 0; for (i = 0, tmp = ip->first; tmp != NULL; i++, tmp = tmp->next) { Index: xc/programs/twm/icons.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/icons.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 icons.c --- xc/programs/twm/icons.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/icons.c 11 Mar 2005 16:17:26 -0000 @@ -34,44 +34,41 @@ * **********************************************************************/ #include #include "twm.h" #include "screen.h" #include "icons.h" #include "gram.h" #include "parse.h" #include "util.h" #define iconWidth(w) (Scr->IconBorderWidth * 2 + w->icon_w_width) #define iconHeight(w) (Scr->IconBorderWidth * 2 + w->icon_w_height) 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; +splitEntry (IconEntry *ie, int grav1, int grav2, int w, int h) { IconEntry *new; switch (grav1) { case D_NORTH: case D_SOUTH: if (w != ie->w) splitEntry (ie, grav2, grav1, w, ie->h); if (h != ie->h) { new = (IconEntry *)malloc (sizeof (IconEntry)); new->twm_win = 0; new->used = 0; new->next = ie->next; ie->next = new; new->x = ie->x; new->h = (ie->h - h); new->w = ie->w; ie->h = h; if (grav1 == D_SOUTH) { new->y = ie->y; @@ -94,210 +91,197 @@ new->w = (ie->w - w); new->h = ie->h; ie->w = w; if (grav1 == D_EAST) { new->x = ie->x; ie->x = new->x + new->w; } else new->x = ie->x + ie->w; } break; } } 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; +PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y, int *final_x, int *final_y) { IconRegion *ir; IconEntry *ie; int w = 0, h = 0; ie = 0; for (ir = Scr->FirstRegion; ir; ir = ir->next) { w = roundUp (iconWidth (tmp_win), ir->stepx); h = roundUp (iconHeight (tmp_win), ir->stepy); for (ie = ir->entries; ie; ie=ie->next) { if (ie->used) continue; if (ie->w >= w && ie->h >= h) break; } if (ie) break; } if (ie) { splitEntry (ie, ir->grav1, ir->grav2, w, h); ie->used = 1; ie->twm_win = tmp_win; *final_x = ie->x + (ie->w - iconWidth (tmp_win)) / 2; *final_y = ie->y + (ie->h - iconHeight (tmp_win)) / 2; } else { *final_x = def_x; *final_y = def_y; } return; } static IconEntry * -FindIconEntry (tmp_win, irp) - TwmWindow *tmp_win; - IconRegion **irp; +FindIconEntry (TwmWindow *tmp_win, IconRegion **irp) { IconRegion *ir; IconEntry *ie; for (ir = Scr->FirstRegion; ir; ir = ir->next) { for (ie = ir->entries; ie; ie=ie->next) if (ie->twm_win == tmp_win) { if (irp) *irp = ir; return ie; } } return 0; } void -IconUp (tmp_win) - TwmWindow *tmp_win; +IconUp (TwmWindow *tmp_win) { int x, y; int defx, defy; struct IconRegion *ir; /* * If the client specified a particular location, let's use it (this might * want to be an option at some point). Otherwise, try to fit within the * icon region. */ if (tmp_win->wmhints && (tmp_win->wmhints->flags & IconPositionHint)) return; if (tmp_win->icon_moved) { if (!XGetGeometry (dpy, tmp_win->icon_w, &JunkRoot, &defx, &defy, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth)) return; x = defx + ((int) JunkWidth) / 2; y = defy + ((int) JunkHeight) / 2; for (ir = Scr->FirstRegion; ir; ir = ir->next) { if (x >= ir->x && x < (ir->x + ir->w) && y >= ir->y && y < (ir->y + ir->h)) break; } if (!ir) return; /* outside icon regions, leave alone */ } defx = -100; defy = -100; PlaceIcon(tmp_win, defx, defy, &x, &y); if (x != defx || y != defy) { XMoveWindow (dpy, tmp_win->icon_w, x, y); tmp_win->icon_moved = FALSE; /* since we've restored it */ } } static IconEntry * -prevIconEntry (ie, ir) - IconEntry *ie; - IconRegion *ir; +prevIconEntry (IconEntry *ie, IconRegion *ir) { IconEntry *ip; if (ie == ir->entries) return 0; for (ip = ir->entries; ip->next != ie; ip=ip->next) ; return ip; } -/* old is being freed; and is adjacent to ie. Merge +/** + * old is being freed; and is adjacent to ie. Merge * regions together */ - static void -mergeEntries (old, ie) - IconEntry *old, *ie; +mergeEntries (IconEntry *old, IconEntry *ie) { if (old->y == ie->y) { ie->w = old->w + ie->w; if (old->x < ie->x) ie->x = old->x; } else { ie->h = old->h + ie->h; if (old->y < ie->y) ie->y = old->y; } } void -IconDown (tmp_win) - TwmWindow *tmp_win; +IconDown (TwmWindow *tmp_win) { IconEntry *ie, *ip, *in; IconRegion *ir; ie = FindIconEntry (tmp_win, &ir); if (ie) { ie->twm_win = 0; ie->used = 0; ip = prevIconEntry (ie, ir); in = ie->next; for (;;) { if (ip && ip->used == 0 && ((ip->x == ie->x && ip->w == ie->w) || (ip->y == ie->y && ip->h == ie->h))) { ip->next = ie->next; mergeEntries (ie, ip); free ((char *) ie); ie = ip; ip = prevIconEntry (ip, ir); } else if (in && in->used == 0 && ((in->x == ie->x && in->w == ie->w) || (in->y == ie->y && in->h == ie->h))) { ie->next = in->next; mergeEntries (in, ie); free ((char *) in); in = ie->next; } else break; } } } void -AddIconRegion(geom, grav1, grav2, stepx, stepy) -char *geom; -int grav1, grav2; -int stepx, stepy; +AddIconRegion(char *geom, int grav1, int grav2, int stepx, int stepy) { IconRegion *ir; int mask; ir = (IconRegion *)malloc(sizeof(IconRegion)); ir->next = NULL; if (Scr->LastRegion) Scr->LastRegion->next = ir; Scr->LastRegion = ir; if (!Scr->FirstRegion) Scr->FirstRegion = ir; ir->entries = NULL; ir->grav1 = grav1; ir->grav2 = grav2; if (stepx <= 0) stepx = 1; if (stepy <= 0) stepy = 1; ir->stepx = stepx; @@ -306,73 +290,70 @@ mask = XParseGeometry(geom, &ir->x, &ir->y, (unsigned int *)&ir->w, (unsigned int *)&ir->h); if (mask & XNegative) ir->x += Scr->MyDisplayWidth - ir->w; if (mask & YNegative) ir->y += Scr->MyDisplayHeight - ir->h; ir->entries = (IconEntry *)malloc(sizeof(IconEntry)); ir->entries->next = 0; ir->entries->x = ir->x; ir->entries->y = ir->y; ir->entries->w = ir->w; ir->entries->h = ir->h; ir->entries->twm_win = 0; ir->entries->used = 0; } #ifdef comment void -FreeIconEntries (ir) - IconRegion *ir; +FreeIconEntries (IconRegion *ir) { IconEntry *ie, *tmp; for (ie = ir->entries; ie; ie=tmp) { tmp = ie->next; free ((char *) ie); } } void FreeIconRegions() { IconRegion *ir, *tmp; for (ir = Scr->FirstRegion; ir != NULL;) { tmp = ir; FreeIconEntries (ir); ir = ir->next; free((char *) tmp); } Scr->FirstRegion = NULL; Scr->LastRegion = NULL; } #endif void -CreateIconWindow(tmp_win, def_x, def_y) - TwmWindow *tmp_win; - int def_x, def_y; +CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) { unsigned long event_mask; unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm = None; /* tmp pixmap variable */ int final_x, final_y; int x; FB(tmp_win->iconc.fore, tmp_win->iconc.back); tmp_win->forced = FALSE; tmp_win->icon_not_ours = FALSE; /* now go through the steps to get an icon window, if ForceIcon is * set, then no matter what else is defined, the bitmap from the * .twmrc file is used */ if (Scr->ForceIcon) { Index: xc/programs/twm/list.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/list.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 list.c --- xc/programs/twm/list.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/list.c 11 Mar 2005 16:17:27 -0000 @@ -53,208 +53,168 @@ /********************************************************************** * * $Xorg: list.c,v 1.4 2001/02/09 02:05:36 xorgcvs Exp $ * * TWM code to deal with the name lists for the NoTitle list and * the AutoRaise list * * 11-Apr-88 Tom LaStrange Initial Version. * **********************************************************************/ #include #include "twm.h" #include "screen.h" #include "gram.h" #include "util.h" struct name_list_struct { - name_list *next; /* pointer to the next name */ - char *name; /* the name of the window */ - char *ptr; /* list dependent data */ + name_list *next; /**< pointer to the next name */ + char *name; /**< the name of the window */ + char *ptr; /**< list dependent data */ }; -/*********************************************************************** +/** + * add a window name to the appropriate list. * - * Procedure: - * AddToList - add a window name to the appropriate list - * - * Inputs: - * list - the address of the pointer to the head of a list - * name - a pointer to the name of the window - * ptr - pointer to list dependent data - * - * Special Considerations * If the list does not use the ptr value, a non-null value * should be placed in it. LookInList returns this ptr value * and procedures calling LookInList will check for a non-null * return value as an indication of success. * - *********************************************************************** + * \param list the address of the pointer to the head of a list + * \param name a pointer to the name of the window + * \param ptr pointer to list dependent data */ - void -AddToList(list_head, name, ptr) -name_list **list_head; -char *name; -char *ptr; +AddToList(name_list **list_head, char *name, char *ptr) { name_list *nptr; if (!list_head) return; /* ignore empty inserts */ nptr = (name_list *)malloc(sizeof(name_list)); if (nptr == NULL) { twmrc_error_prefix(); fprintf (stderr, "unable to allocate %ld bytes for name_list\n", (unsigned long)sizeof(name_list)); Done(NULL, NULL); } nptr->next = *list_head; nptr->name = name; nptr->ptr = (ptr == NULL) ? (char *)TRUE : ptr; *list_head = nptr; } -/*********************************************************************** - * - * Procedure: - * LookInList - look through a list for a window name, or class +/** + * look through a list for a window name, or class * - * Returned Value: - * the ptr field of the list structure or NULL if the name + * \return the ptr field of the list structure or NULL if the name * or class was not found in the list * - * Inputs: - * list - a pointer to the head of a list - * name - a pointer to the name to look for - * class - a pointer to the class to look for - * - *********************************************************************** + * \param list a pointer to the head of a list + * \param name a pointer to the name to look for + * \param class a pointer to the class to look for */ - char * -LookInList(list_head, name, class) -name_list *list_head; -char *name; -XClassHint *class; +LookInList(name_list *list_head, char *name, XClassHint *class) { name_list *nptr; /* look for the name first */ for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (strcmp(name, nptr->name) == 0) return (nptr->ptr); if (class) { /* look for the res_name next */ for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (strcmp(class->res_name, nptr->name) == 0) return (nptr->ptr); /* finally look for the res_class */ for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (strcmp(class->res_class, nptr->name) == 0) return (nptr->ptr); } return (NULL); } char * -LookInNameList(list_head, name) -name_list *list_head; -char *name; +LookInNameList(name_list *list_head, char *name) { return (LookInList(list_head, name, NULL)); } -/*********************************************************************** - * - * Procedure: - * GetColorFromList - look through a list for a window name, or class +/** + * look through a list for a window name, or class * - * Returned Value: - * TRUE if the name was found - * FALSE if the name was not found + * \return TRUE if the name was found + * \return FALSE if the name was not found * - * Inputs: - * list - a pointer to the head of a list - * name - a pointer to the name to look for - * class - a pointer to the class to look for - * - * Outputs: - * ptr - fill in the list value if the name was found - * - *********************************************************************** + * \param list a pointer to the head of a list + * \param name a pointer to the name to look for + * \param class a pointer to the class to look for + * \param[out] ptr fill in the list value if the name was found */ - -int GetColorFromList(list_head, name, class, ptr) -name_list *list_head; -char *name; -XClassHint *class; -Pixel *ptr; +int GetColorFromList(name_list *list_head, char *name, XClassHint *class, + Pixel *ptr) { int save; name_list *nptr; for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (strcmp(name, nptr->name) == 0) { save = Scr->FirstTime; Scr->FirstTime = TRUE; GetColor(Scr->Monochrome, ptr, nptr->ptr); Scr->FirstTime = save; return (TRUE); } if (class) { for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (strcmp(class->res_name, nptr->name) == 0) { save = Scr->FirstTime; Scr->FirstTime = TRUE; GetColor(Scr->Monochrome, ptr, nptr->ptr); Scr->FirstTime = save; return (TRUE); } for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (strcmp(class->res_class, nptr->name) == 0) { save = Scr->FirstTime; Scr->FirstTime = TRUE; GetColor(Scr->Monochrome, ptr, nptr->ptr); Scr->FirstTime = save; return (TRUE); } } return (FALSE); } -/*********************************************************************** - * - * Procedure: - * FreeList - free up a list - * - *********************************************************************** +/** + * free up a list */ - -void FreeList(list) -name_list **list; +void FreeList(name_list **list) { name_list *nptr; name_list *tmp; for (nptr = *list; nptr != NULL; ) { tmp = nptr->next; free((char *) nptr); nptr = tmp; } *list = NULL; } Index: xc/programs/twm/menus.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/menus.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 menus.c --- xc/programs/twm/menus.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/menus.c 11 Mar 2005 16:17:28 -0000 @@ -66,138 +66,124 @@ #include "twm.h" #include "gc.h" #include "menus.h" #include "resize.h" #include "events.h" #include "util.h" #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 "version.h" #include #include int RootFunction = 0; -MenuRoot *ActiveMenu = NULL; /* the active menu */ -MenuItem *ActiveItem = NULL; /* the active menu item */ -int MoveFunction; /* either F_MOVE or F_FORCEMOVE */ +MenuRoot *ActiveMenu = NULL; /**< the active menu */ +MenuItem *ActiveItem = NULL; /**< the active menu item */ +int MoveFunction; /**< either F_MOVE or F_FORCEMOVE */ int WindowMoved = FALSE; int menuFromFrameOrWindowOrTitlebar = FALSE; -int ConstMove = FALSE; /* constrained move variables */ +int ConstMove = FALSE; /**< constrained move variables */ int ConstMoveDir; int ConstMoveX; int ConstMoveY; int ConstMoveXL; int ConstMoveXR; int ConstMoveYT; int ConstMoveYB; /* Globals used to keep track of whether the mouse has moved during a resize function. */ int ResizeOrigX; int ResizeOrigY; -int MenuDepth = 0; /* number of menus up */ +int MenuDepth = 0; /**< number of menus up */ static struct { int x; int y; } MenuOrigins[MAXMENUDEPTH]; static Cursor LastCursor; 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: - * InitMenus - initialize menu roots - * - *********************************************************************** +/** + * initialize menu roots */ - void InitMenus() { int i, j, k; FuncKey *key, *tmp; for (i = 0; i < MAX_BUTTONS+1; i++) for (j = 0; j < NUM_CONTEXTS; j++) for (k = 0; k < MOD_SIZE; k++) { Scr->Mouse[i][j][k].func = 0; Scr->Mouse[i][j][k].item = NULL; } Scr->DefaultFunction.func = 0; Scr->WindowFunction.func = 0; if (FirstScreen) { for (key = Scr->FuncKeyRoot.next; key != NULL;) { free(key->name); tmp = key; key = key->next; free((char *) tmp); } Scr->FuncKeyRoot.next = NULL; } } -/*********************************************************************** - * - * Procedure: - * AddFuncKey - add a function key to the list +/** + * add a function key to the list * - * Inputs: - * name - the name of the key - * cont - the context to look for the key press in - * mods - modifier keys that need to be pressed - * func - the function to perform - * win_name- the window name (if any) - * action - the action string associated with the function (if any) - * - *********************************************************************** + * \param name the name of the key + * \param cont the context to look for the key press in + * \param mods modifier keys that need to be pressed + * \param func the function to perform + * \param win_name the window name (if any) + * \param action the action string associated with the function (if any) */ - -Bool AddFuncKey (name, cont, mods, func, win_name, action) - char *name; - int cont, mods, func; - char *win_name; - char *action; +Bool AddFuncKey (char *name, int cont, int mods, int func, char *win_name, + char *action) { FuncKey *tmp; KeySym keysym; KeyCode keycode; /* * Don't let a 0 keycode go through, since that means AnyKey to the * XGrabKey call in GrabKeys(). */ if ((keysym = XStringToKeysym(name)) == NoSymbol || (keycode = XKeysymToKeycode(dpy, keysym)) == 0) { return False; } /* see if there already is a key defined for this context */ for (tmp = Scr->FuncKeyRoot.next; tmp != NULL; tmp = tmp->next) { if (tmp->keysym == keysym && tmp->cont == cont && @@ -209,47 +195,42 @@ { tmp = (FuncKey *) malloc(sizeof(FuncKey)); tmp->next = Scr->FuncKeyRoot.next; Scr->FuncKeyRoot.next = tmp; } tmp->name = name; tmp->keysym = keysym; tmp->keycode = keycode; tmp->cont = cont; tmp->mods = mods; tmp->func = func; tmp->win_name = win_name; tmp->action = action; return True; } -int CreateTitleButton (name, func, action, menuroot, rightside, append) - char *name; - int func; - char *action; - MenuRoot *menuroot; - Bool rightside; - Bool append; +int CreateTitleButton (char *name, int func, char *action, MenuRoot *menuroot, + Bool rightside, Bool append) { TitleButton *tb = (TitleButton *) malloc (sizeof(TitleButton)); if (!tb) { fprintf (stderr, "%s: unable to allocate %ld bytes for title button\n", ProgramName, (unsigned long)sizeof(TitleButton)); return 0; } tb->next = NULL; tb->name = name; /* note that we are not copying */ tb->bitmap = None; /* WARNING, values not set yet */ tb->width = 0; /* see InitTitlebarButtons */ tb->height = 0; /* ditto */ tb->func = func; tb->action = action; tb->menuroot = menuroot; tb->rightside = rightside; if (rightside) { @@ -279,45 +260,44 @@ tb->next = NULL; } else { /* 2 */ register TitleButton *t, *prev = NULL; for (t = Scr->TBInfo.head; t && !t->rightside; t = t->next) { prev = t; } if (prev) { tb->next = prev->next; prev->next = tb; } else { tb->next = Scr->TBInfo.head; Scr->TBInfo.head = tb; } } return 1; } -/* - * InitTitlebarButtons - Do all the necessary stuff to load in a titlebar - * button. If we can't find the button, then put in a question; if we can't - * find the question mark, something is wrong and we are probably going to be - * in trouble later on. +/** + * Do all the necessary stuff to load in a titlebar button. If we can't find + * the button, then put in a question; if we can't find the question mark, + * something is wrong and we are probably going to be in trouble later on. */ void InitTitlebarButtons () { TitleButton *tb; int h; /* * initialize dimensions */ Scr->TBInfo.width = (Scr->TitleHeight - 2 * (Scr->FramePadding + Scr->ButtonIndent)); Scr->TBInfo.pad = ((Scr->TitlePadding > 1) ? ((Scr->TitlePadding + 1) / 2) : 1); h = Scr->TBInfo.width - 2 * Scr->TBInfo.border; /* * add in some useful buttons and bindings so that novices can still * use the system. */ if (!Scr->NoDefaults) { @@ -354,45 +334,43 @@ tb->dstx = (h - tb->width + 1) / 2; if (tb->dstx < 0) { /* clip to minimize copying */ tb->srcx = -(tb->dstx); tb->width = h; tb->dstx = 0; } else { tb->srcx = 0; } tb->dsty = (h - tb->height + 1) / 2; if (tb->dsty < 0) { tb->srcy = -(tb->dsty); tb->height = h; tb->dsty = 0; } else { tb->srcy = 0; } } } + void -PaintEntry(mr, mi, exposure) -MenuRoot *mr; -MenuItem *mi; -int exposure; +PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) { int y_offset; int text_y; GC gc; #ifdef DEBUG_MENUS fprintf(stderr, "Paint entry\n"); #endif y_offset = mi->item_num * Scr->EntryHeight; text_y = y_offset + Scr->MenuFont.y; if (mi->func != F_TITLE) { int x, y; if (mi->state) { XSetForeground(dpy, Scr->NormalGC, mi->hi_back); XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset, @@ -451,43 +429,41 @@ { XSetForeground(dpy, Scr->NormalGC, mi->fore); /* now draw the dividing lines */ if (y_offset) XDrawLine (dpy, mr->w, Scr->NormalGC, 0, y_offset, mr->width, y_offset); y = ((mi->item_num+1) * Scr->EntryHeight)-1; XDrawLine(dpy, mr->w, Scr->NormalGC, 0, y, mr->width, y); } MyFont_ChangeGC(mi->fore, mi->back, &Scr->MenuFont); /* finally render the title */ 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; +PaintMenu(MenuRoot *mr, XEvent *e) { MenuItem *mi; for (mi = mr->first; mi != NULL; mi = mi->next) { int y_offset = mi->item_num * Scr->EntryHeight; /* be smart about handling the expose, redraw only the entries * that we need to */ if (e->xexpose.y < (y_offset + Scr->EntryHeight) && (e->xexpose.y + e->xexpose.height) > y_offset) { PaintEntry(mr, mi, True); } } XSync(dpy, 0); } @@ -612,57 +588,47 @@ Bell(XkbBI_MinorError,0,None); badItem = ActiveItem; } /* if the menu did get popped up, unhighlight the active item */ if (save != ActiveMenu && ActiveItem->state) { ActiveItem->state = 0; PaintEntry(save, ActiveItem, False); ActiveItem = NULL; } } if (badItem != ActiveItem) badItem = NULL; XFlush(dpy); } } -/*********************************************************************** +/** + * create a new menu root * - * Procedure: - * NewMenuRoot - create a new menu root - * - * Returned Value: - * (MenuRoot *) - * - * Inputs: - * name - the name of the menu root - * - *********************************************************************** + * \param name the name of the menu root */ - MenuRoot * -NewMenuRoot(name) - char *name; +NewMenuRoot(char *name) { MenuRoot *tmp; #define UNUSED_PIXEL ((unsigned long) (~0)) /* more than 24 bits */ tmp = (MenuRoot *) malloc(sizeof(MenuRoot)); tmp->hi_fore = UNUSED_PIXEL; tmp->hi_back = UNUSED_PIXEL; tmp->name = name; tmp->prev = NULL; tmp->first = NULL; tmp->last = NULL; tmp->items = 0; tmp->width = 0; tmp->mapped = NEVER_MAPPED; tmp->pull = FALSE; tmp->w = None; tmp->shadow = None; tmp->real_menu = FALSE; @@ -675,67 +641,54 @@ if (Scr->LastMenu == NULL) { Scr->LastMenu = tmp; Scr->LastMenu->next = NULL; } else { Scr->LastMenu->next = tmp; Scr->LastMenu = tmp; Scr->LastMenu->next = NULL; } if (strcmp(name, TWM_WINDOWS) == 0) Scr->Windows = tmp; return (tmp); } -/*********************************************************************** - * - * Procedure: - * AddToMenu - add an item to a root menu - * - * Returned Value: - * (MenuItem *) - * - * Inputs: - * menu - pointer to the root menu to add the item - * item - the text to appear in the menu - * action - the string to possibly execute - * sub - the menu root if it is a pull-right entry - * func - the numeric function - * fore - foreground color string - * back - background color string +/** + * add an item to a root menu * - *********************************************************************** + * \param menu pointer to the root menu to add the item + * \param item the text to appear in the menu + * \param action the string to possibly execute + * \param sub the menu root if it is a pull-right entry + * \param func the numeric function + * \param fore foreground color string + * \param back background color string */ - MenuItem * -AddToMenu(menu, item, action, sub, func, fore, back) - MenuRoot *menu; - char *item, *action; - MenuRoot *sub; - int func; - char *fore, *back; +AddToMenu(MenuRoot *menu, char *item, char *action, MenuRoot *sub, int func, + char *fore, char *back) { MenuItem *tmp; int width; #ifdef DEBUG_MENUS fprintf(stderr, "adding menu item=\"%s\", action=%s, sub=%d, f=%d\n", item, action, sub, func); #endif tmp = (MenuItem *) malloc(sizeof(MenuItem)); tmp->root = menu; if (menu->first == NULL) { menu->first = tmp; tmp->prev = NULL; } else { menu->last->next = tmp; @@ -780,42 +733,41 @@ return (tmp); } void MakeMenus() { MenuRoot *mr; for (mr = Scr->MenuList; mr != NULL; mr = mr->next) { if (mr->real_menu == FALSE) continue; MakeMenu(mr); } } void -MakeMenu(mr) -MenuRoot *mr; +MakeMenu(MenuRoot *mr) { MenuItem *start, *end, *cur, *tmp; XColor f1, f2, f3; XColor b1, b2, b3; XColor save_fore, save_back; int num, i; int fred, fgreen, fblue; int bred, bgreen, bblue; int width; unsigned long valuemask; XSetWindowAttributes attributes; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; Scr->EntryHeight = Scr->MenuFont.height + 4; /* lets first size the window accordingly */ if (mr->mapped == NEVER_MAPPED) { if (mr->pull == TRUE) { @@ -972,58 +924,49 @@ b3.red += bred; b3.green += bgreen; b3.blue += bblue; save_back = b3; XAllocColor(dpy, cmap, &f3); XAllocColor(dpy, cmap, &b3); cur->hi_back = cur->fore = f3.pixel; cur->hi_fore = cur->back = b3.pixel; cur->user_colors = True; f3 = save_fore; b3 = save_back; } start = end; } } -/*********************************************************************** - * - * Procedure: - * PopUpMenu - pop up a pull down menu +/** + * pop up a pull down menu. * - * Inputs: - * menu - the root pointer of the menu to pop up - * x, y - location of upper left of menu - * center - whether or not to center horizontally over position - * - *********************************************************************** + * \param menu the root pointer of the menu to pop up + * \param x,y location of upper left of menu + * \param center whether or not to center horizontally over position */ - Bool -PopUpMenu (menu, x, y, center) - MenuRoot *menu; - int x, y; - Bool center; +PopUpMenu (MenuRoot *menu, int x, int y, Bool center) { int WindowNameCount; TwmWindow **WindowNames; TwmWindow *tmp_win2,*tmp_win3; int i; int (*compar)(const char *, const char *) = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); if (!menu) return False; InstallRootColormap(); if (menu == Scr->Windows) { TwmWindow *tmp_win; /* this is the twm windows menu, let's go ahead and build it */ DestroyMenu (menu); @@ -1112,148 +1055,121 @@ MenuOrigins[MenuDepth].y = y; MenuDepth++; XMoveWindow(dpy, menu->w, x, y); if (Scr->Shadow) { XMoveWindow (dpy, menu->shadow, x + SHADOWWIDTH, y + SHADOWWIDTH); } if (Scr->Shadow) { XRaiseWindow (dpy, menu->shadow); } XMapRaised(dpy, menu->w); if (Scr->Shadow) { XMapWindow (dpy, menu->shadow); } XSync(dpy, 0); return True; } -/*********************************************************************** - * - * Procedure: - * PopDownMenu - unhighlight the current menu selection and - * take down the menus - * - *********************************************************************** +/** + * unhighlight the current menu selection and take down the menus */ void PopDownMenu() { MenuRoot *tmp; if (ActiveMenu == NULL) return; if (ActiveItem) { ActiveItem->state = 0; PaintEntry(ActiveMenu, ActiveItem, False); } for (tmp = ActiveMenu; tmp != NULL; tmp = tmp->prev) { if (Scr->Shadow) { XUnmapWindow (dpy, tmp->shadow); } XUnmapWindow(dpy, tmp->w); tmp->mapped = UNMAPPED; UninstallRootColormap(); } XFlush(dpy); ActiveMenu = NULL; ActiveItem = NULL; MenuDepth = 0; if (Context == C_WINDOW || Context == C_FRAME || Context == C_TITLE) menuFromFrameOrWindowOrTitlebar = TRUE; } -/*********************************************************************** +/** + * look for a menu root * - * Procedure: - * FindMenuRoot - look for a menu root + * \return a pointer to the menu root structure * - * Returned Value: - * (MenuRoot *) - a pointer to the menu root structure - * - * Inputs: - * name - the name of the menu root - * - *********************************************************************** + * \param name the name of the menu root */ - MenuRoot * -FindMenuRoot(name) - char *name; +FindMenuRoot(char *name) { MenuRoot *tmp; for (tmp = Scr->MenuList; tmp != NULL; tmp = tmp->next) { if (strcmp(name, tmp->name) == 0) return (tmp); } return NULL; } static Bool -belongs_to_twm_window (t, w) - register TwmWindow *t; - register Window w; +belongs_to_twm_window (TwmWindow *t, Window w) { if (!t) return False; if (w == t->frame || w == t->title_w || w == t->hilite_w || w == t->icon_w || w == t->icon_bm_w) return True; if (t && t->titlebuttons) { register TBWindow *tbw; register int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright; for (tbw = t->titlebuttons; nb > 0; tbw++, nb--) { if (tbw->window == w) return True; } } return False; } - -/*********************************************************************** - * - * Procedure: - * resizeFromCenter - - * - *********************************************************************** - */ - - void -resizeFromCenter(w, tmp_win) - Window w; - TwmWindow *tmp_win; +resizeFromCenter(Window w, TwmWindow *tmp_win) { int lastx, lasty, bw2; XEvent event; #if 0 int namelen; int width, height; namelen = strlen (tmp_win->name); #endif bw2 = tmp_win->frame_bw * 2; AddingW = tmp_win->attr.width + bw2; AddingH = tmp_win->attr.height + tmp_win->title_height + bw2; #if 0 width = (SIZE_HINDENT + MyFont_TextWidth (&Scr->SizeFont, tmp_win->name, namelen)); height = Scr->SizeFont.height + SIZE_VINDENT * 2; #endif XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY, (unsigned int *)&DragWidth, (unsigned int *)&DragHeight, &JunkBW, &JunkDepth); @@ -1311,86 +1227,71 @@ * XXX - if we are going to do a loop, we ought to consider * using multiple GXxor lines so that we don't need to * grab the server. */ XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask); if (lastx != AddingX || lasty != AddingY) { MenuDoResize(AddingX, AddingY, tmp_win); lastx = AddingX; lasty = AddingY; } } } -/*********************************************************************** - * - * Procedure: - * ExecuteFunction - execute a twm root function - * - * Inputs: - * func - the function to execute - * action - the menu action to execute - * w - the window to execute this function on - * tmp_win - the twm window structure - * event - the event that caused the function - * context - the context in which the button was pressed - * pulldown- flag indicating execution from pull down menu +/** \fn ExecureFunction + * execute a twm root function. * - * Returns: - * TRUE if should continue with remaining actions else FALSE to abort + * \param func the function to execute + * \param action the menu action to execute + * \param w the window to execute this function on + * \param tmp_win the twm window structure + * \param event the event that caused the function + * \param context the context in which the button was pressed + * \param pulldown flag indicating execution from pull down menu * - *********************************************************************** + * \return TRUE if should continue with remaining actions, + * else FALSE to abort */ -/* for F_WARPTO */ -#define true 1 -#define false 0 int -WarpThere(t) - TwmWindow* t; +WarpThere(TwmWindow *t) { if (Scr->WarpUnmapped || t->mapped) { if (!t->mapped) DeIconify (t); if (!Scr->NoRaiseWarp) XRaiseWindow (dpy, t->frame); WarpToWindow (t); - return true; + return 1; } - return false; + return 0; } int -ExecuteFunction(func, action, w, tmp_win, eventp, context, pulldown) - int func; - char *action; - Window w; - TwmWindow *tmp_win; - XEvent *eventp; - int context; - int pulldown; +ExecuteFunction(int func, char *action, Window w, TwmWindow *tmp_win, + XEvent *eventp, int context, int pulldown) { static Time last_time = 0; char tmp[200]; char *ptr; char buff[MAX_FILE_SIZE]; int count, fd; Window rootw; int origX, origY; int do_next_action = TRUE; int moving_icon = FALSE; Bool fromtitlebar = False; RootFunction = 0; if (Cancel) return TRUE; /* XXX should this be FALSE? */ switch (func) { case F_UPICONMGR: case F_LEFTICONMGR: @@ -2317,240 +2218,210 @@ if (HasSync) { if (DeferExecution (context, func, Scr->SelectCursor)) return TRUE; (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); return do_next_action; } -/*********************************************************************** - * - * Procedure: - * DeferExecution - defer the execution of a function to the - * next button press if the context is C_ROOT - * - * Inputs: - * context - the context in which the mouse button was pressed - * func - the function to defer - * cursor - the cursor to display while waiting - * - *********************************************************************** +/** + * defer the execution of a function to the next button press if the context + * is C_ROOT + * + * \param context the context in which the mouse button was pressed + * \param func the function to defer + * \param cursor cursor the cursor to display while waiting */ - int -DeferExecution(context, func, cursor) -int context, func; -Cursor cursor; +DeferExecution(int context, int func, Cursor cursor) { if (context == C_ROOT) { LastCursor = cursor; XGrabPointer(dpy, Scr->Root, True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, Scr->Root, cursor, CurrentTime); RootFunction = func; return (TRUE); } return (FALSE); } -/*********************************************************************** - * - * Procedure: - * ReGrab - regrab the pointer with the LastCursor; - * - *********************************************************************** +/** + *regrab the pointer with the LastCursor; */ void ReGrab() { XGrabPointer(dpy, Scr->Root, True, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, Scr->Root, LastCursor, CurrentTime); } -/*********************************************************************** - * - * Procedure: - * NeedToDefer - checks each function in the list to see if it - * is one that needs to be defered. +/** + * checks each function in the list to see if it is one that needs + * to be deferred. * - * Inputs: - * root - the menu root to check - * - *********************************************************************** + * \param root the menu root to check */ Bool -NeedToDefer(root) -MenuRoot *root; +NeedToDefer(MenuRoot *root) { MenuItem *mitem; for (mitem = root->first; mitem != NULL; mitem = mitem->next) { switch (mitem->func) { case F_IDENTIFY: case F_RESIZE: case F_MOVE: case F_FORCEMOVE: case F_DEICONIFY: case F_ICONIFY: case F_RAISELOWER: case F_RAISE: case F_LOWER: case F_FOCUS: case F_DESTROY: case F_WINREFRESH: case F_ZOOM: case F_FULLZOOM: case F_HORIZOOM: case F_RIGHTZOOM: case F_LEFTZOOM: case F_TOPZOOM: case F_BOTTOMZOOM: case F_AUTORAISE: return TRUE; } } return FALSE; } -/*********************************************************************** - * - * Procedure: - * Execute - execute the string by /bin/sh - * - * Inputs: - * s - the string containing the command - * - *********************************************************************** - */ - #if defined(sun) && defined(SVR4) + +/** + * execute the string by /bin/sh + * \param s the string containing the command + */ static int -System (s) - char *s; +System (char *s) { int pid, status; if ((pid = fork ()) == 0) { (void) setpgrp(); execl ("/bin/sh", "sh", "-c", s, 0); } else waitpid (pid, &status, 0); return status; } #define system(s) System(s) + #endif void -Execute(s) - char *s; +Execute(char *s) { + /* FIXME: is all this stuff needed? There could be security problems here. */ static char buf[256]; char *ds = DisplayString (dpy); char *colon, *dot1; char oldDisplay[256]; char *doisplay; int restorevar = 0; oldDisplay[0] = '\0'; doisplay=getenv("DISPLAY"); if (doisplay) strcpy (oldDisplay, doisplay); /* * Build a display string using the current screen number, so that * X programs which get fired up from a menu come up on the screen * that they were invoked from, unless specifically overridden on * their command line. */ colon = strrchr (ds, ':'); if (colon) { /* if host[:]:dpy */ strcpy (buf, "DISPLAY="); strcat (buf, ds); colon = buf + 8 + (colon - ds); /* use version in buf */ dot1 = strchr (colon, '.'); /* first period after colon */ if (!dot1) dot1 = colon + strlen (colon); /* if not there, append */ (void) sprintf (dot1, ".%d", Scr->screen); putenv (buf); restorevar = 1; } (void) system (s); if (restorevar) { /* why bother? */ (void) sprintf (buf, "DISPLAY=%s", oldDisplay); putenv (buf); } } -/*********************************************************************** - * - * Procedure: - * FocusOnRoot - put input focus on the root window - * - *********************************************************************** +/** + * put input focus on the root window. */ - void FocusOnRoot() { SetFocus ((TwmWindow *) NULL, LastTimestamp()); if (Scr->Focus != NULL) { SetBorder (Scr->Focus, False); if (Scr->Focus->hilite_w) XUnmapWindow (dpy, Scr->Focus->hilite_w); } InstallWindowColormaps(0, &Scr->TwmRoot); Scr->Focus = NULL; Scr->FocusRoot = TRUE; } void -DeIconify(tmp_win) -TwmWindow *tmp_win; +DeIconify(TwmWindow *tmp_win) { TwmWindow *t; /* de-iconify the main window */ if (tmp_win->icon) { if (tmp_win->icon_on) Zoom(tmp_win->icon_w, tmp_win->frame); else if (tmp_win->group != (Window) 0) { for (t = Scr->TwmRoot.next; t != NULL; t = t->next) { if (tmp_win->group == t->w && t->icon_on) { Zoom(t->icon_w, tmp_win->frame); break; } } } } @@ -2592,44 +2463,43 @@ if (Scr->NoRaiseDeicon) XMapWindow(dpy, t->frame); else XMapRaised(dpy, t->frame); SetMapStateProp(t, NormalState); if (t->icon_w) { XUnmapWindow(dpy, t->icon_w); IconDown (t); } if (t->list) XUnmapWindow(dpy, t->list->icon); t->icon = FALSE; t->icon_on = FALSE; } } XSync (dpy, 0); } + void -Iconify(tmp_win, def_x, def_y) -TwmWindow *tmp_win; -int def_x, def_y; +Iconify(TwmWindow *tmp_win, int def_x, int def_y) { TwmWindow *t; int iconify; XWindowAttributes winattrs; unsigned long eventMask; iconify = ((!tmp_win->iconify_by_unmapping) || tmp_win->transient); if (iconify) { if (tmp_win->icon_w == (Window) 0) CreateIconWindow(tmp_win, def_x, def_y); else IconUp(tmp_win); XMapRaised(dpy, tmp_win->icon_w); } if (tmp_win->list) XMapWindow(dpy, tmp_win->list->icon); XGetWindowAttributes(dpy, tmp_win->w, &winattrs); eventMask = winattrs.your_event_mask; @@ -2687,42 +2557,41 @@ SetMapStateProp(tmp_win, IconicState); SetBorder (tmp_win, False); if (tmp_win == Scr->Focus) { SetFocus ((TwmWindow *) NULL, LastTimestamp()); Scr->Focus = NULL; Scr->FocusRoot = TRUE; } tmp_win->icon = TRUE; if (iconify) tmp_win->icon_on = TRUE; else tmp_win->icon_on = FALSE; XSync (dpy, 0); } static void -Identify (t) - TwmWindow *t; +Identify (TwmWindow *t) { int i, n, twidth, width, height; int x, y; unsigned int wwidth, wheight, bw, depth; Window junk; int px, py, dummy; unsigned udummy; n = 0; (void) sprintf(Info[n++], "Twm version: %s", Version); Info[n++][0] = '\0'; if (t) { XGetGeometry (dpy, t->w, &JunkRoot, &JunkX, &JunkY, &wwidth, &wheight, &bw, &depth); (void) XTranslateCoordinates (dpy, t->w, Scr->Root, 0, 0, &x, &y, &junk); (void) sprintf(Info[n++], "Name = \"%s\"", t->full_name); (void) sprintf(Info[n++], "Class.res_name = \"%s\"", t->class.res_name); (void) sprintf(Info[n++], "Class.res_class = \"%s\"", t->class.res_class); @@ -2758,133 +2627,125 @@ if (XQueryPointer (dpy, Scr->Root, &JunkRoot, &JunkChild, &px, &py, &dummy, &dummy, &udummy)) { px -= (width / 2); py -= (height / 3); if (px + width + BW2 >= Scr->MyDisplayWidth) px = Scr->MyDisplayWidth - width - BW2; if (py + height + BW2 >= Scr->MyDisplayHeight) py = Scr->MyDisplayHeight - height - BW2; if (px < 0) px = 0; if (py < 0) py = 0; } else { px = py = 0; } XMoveResizeWindow(dpy, Scr->InfoWindow, px, py, width, height); XMapRaised(dpy, Scr->InfoWindow); InfoLines = n; } void -SetMapStateProp(tmp_win, state) - TwmWindow *tmp_win; - int state; +SetMapStateProp(TwmWindow *tmp_win, int state) { unsigned long data[2]; /* "suggested" by ICCCM version 1 */ data[0] = (unsigned long) state; data[1] = (unsigned long) (tmp_win->iconify_by_unmapping ? None : tmp_win->icon_w); XChangeProperty (dpy, tmp_win->w, _XA_WM_STATE, _XA_WM_STATE, 32, PropModeReplace, (unsigned char *) data, 2); } Bool -GetWMState (w, statep, iwp) - Window w; - int *statep; - Window *iwp; +GetWMState (Window w, int *statep, Window *iwp) { Atom actual_type; int actual_format; unsigned long nitems, bytesafter; unsigned long *datap = NULL; Bool retval = False; if (XGetWindowProperty (dpy, w, _XA_WM_STATE, 0L, 2L, False, _XA_WM_STATE, &actual_type, &actual_format, &nitems, &bytesafter, (unsigned char **) &datap) != Success || !datap) return False; if (nitems <= 2) { /* "suggested" by ICCCM version 1 */ *statep = (int) datap[0]; *iwp = (Window) datap[1]; retval = True; } XFree ((char *) datap); return retval; } void -WarpToScreen (n, inc) - int n, inc; +WarpToScreen (int n, int inc) { Window dumwin; int x, y, dumint; unsigned int dummask; ScreenInfo *newscr = NULL; while (!newscr) { /* wrap around */ if (n < 0) n = NumScreens - 1; else if (n >= NumScreens) n = 0; newscr = ScreenList[n]; if (!newscr) { /* make sure screen is managed */ if (inc) { /* walk around the list */ n += inc; continue; } fprintf (stderr, "%s: unable to warp to unmanaged screen %d\n", ProgramName, n); Bell(XkbBI_MinorError,0,None); return; } } if (Scr->screen == n) return; /* already on that screen */ PreviousScreen = Scr->screen; XQueryPointer (dpy, Scr->Root, &dumwin, &dumwin, &x, &y, &dumint, &dumint, &dummask); XWarpPointer (dpy, None, newscr->Root, 0, 0, 0, 0, x, y); return; } -/* - * BumpWindowColormap - rotate our internal copy of WM_COLORMAP_WINDOWS +/** + * rotate our internal copy of WM_COLORMAP_WINDOWS */ void -BumpWindowColormap (tmp, inc) - TwmWindow *tmp; - int inc; +BumpWindowColormap (TwmWindow *tmp, int inc) { int i, j, previously_installed; ColormapWindow **cwins; if (!tmp) return; if (inc && tmp->cmaps.number_cwins > 0) { cwins = (ColormapWindow **) malloc(sizeof(ColormapWindow *)* tmp->cmaps.number_cwins); if (cwins) { if ((previously_installed = /* SUPPRESS 560 */(Scr->cmapInfo.cmaps == &tmp->cmaps && tmp->cmaps.number_cwins))) { for (i = tmp->cmaps.number_cwins; i-- > 0; ) tmp->cmaps.cwins[i]->colormap->state = 0; } for (i = 0; i < tmp->cmaps.number_cwins; i++) { j = i - inc; if (j >= tmp->cmaps.number_cwins) @@ -2907,87 +2768,83 @@ } } else FetchWmColormapWindows (tmp); } void HideIconManager () { SetMapStateProp (Scr->iconmgr.twm_win, WithdrawnState); XUnmapWindow(dpy, Scr->iconmgr.twm_win->frame); if (Scr->iconmgr.twm_win->icon_w) XUnmapWindow (dpy, Scr->iconmgr.twm_win->icon_w); Scr->iconmgr.twm_win->mapped = FALSE; Scr->iconmgr.twm_win->icon = TRUE; } void -SetBorder (tmp, onoroff) - TwmWindow *tmp; - Bool onoroff; +SetBorder (TwmWindow *tmp, Bool onoroff) { if (tmp->highlight) { if (onoroff) { XSetWindowBorder (dpy, tmp->frame, tmp->border); if (tmp->title_w) XSetWindowBorder (dpy, tmp->title_w, tmp->border); } else { XSetWindowBorderPixmap (dpy, tmp->frame, tmp->gray); if (tmp->title_w) XSetWindowBorderPixmap (dpy, tmp->title_w, tmp->gray); } } } void -DestroyMenu (menu) - MenuRoot *menu; +DestroyMenu (MenuRoot *menu) { MenuItem *item; if (menu->w) { XDeleteContext (dpy, menu->w, MenuContext); XDeleteContext (dpy, menu->w, ScreenContext); if (Scr->Shadow) XDestroyWindow (dpy, menu->shadow); XDestroyWindow(dpy, menu->w); } for (item = menu->first; item; ) { MenuItem *tmp = item; item = item->next; free ((char *) tmp); } } /* * warping routines */ + void -WarpAlongRing (ev, forward) - XButtonEvent *ev; - Bool forward; +WarpAlongRing (XButtonEvent *ev, Bool forward) { TwmWindow *r, *head; if (Scr->RingLeader) head = Scr->RingLeader; else if (!(head = Scr->Ring)) return; if (forward) { for (r = head->ring.next; r != head; r = r->ring.next) { if (!r || r->mapped) break; } } else { for (r = head->ring.prev; r != head; r = r->ring.prev) { if (!r || r->mapped) break; } } if (r && r != head) { TwmWindow *p = Scr->RingLeader, *t; @@ -2999,90 +2856,80 @@ XFindContext (dpy, ev->window, TwmContext, (caddr_t *)&t) == XCSUCCESS && p == t) { p->ring.cursor_valid = True; p->ring.curs_x = ev->x_root - t->frame_x; p->ring.curs_y = ev->y_root - t->frame_y; if (p->ring.curs_x < -p->frame_bw || p->ring.curs_x >= p->frame_width + p->frame_bw || p->ring.curs_y < -p->frame_bw || p->ring.curs_y >= p->frame_height + p->frame_bw) { /* somehow out of window */ p->ring.curs_x = p->frame_width / 2; p->ring.curs_y = p->frame_height / 2; } } } } void -WarpToWindow (t) - TwmWindow *t; +WarpToWindow (TwmWindow *t) { int x, y; if (t->auto_raise || !Scr->NoRaiseWarp) AutoRaiseWindow (t); if (t->ring.cursor_valid) { x = t->ring.curs_x; y = t->ring.curs_y; } else { x = t->frame_width / 2; y = t->frame_height / 2; } XWarpPointer (dpy, None, t->frame, 0, 0, 0, 0, x, y); } /* * ICCCM Client Messages - Section 4.2.8 of the ICCCM dictates that all * client messages will have the following form: * * event type ClientMessage * message type _XA_WM_PROTOCOLS * window tmp->w * format 32 * data[0] message atom * data[1] time stamp */ static void -send_clientmessage (w, a, timestamp) - Window w; - Atom a; - Time timestamp; +send_clientmessage (Window w, Atom a, Time timestamp) { XClientMessageEvent ev; ev.type = ClientMessage; ev.window = w; ev.message_type = _XA_WM_PROTOCOLS; ev.format = 32; ev.data.l[0] = a; ev.data.l[1] = timestamp; XSendEvent (dpy, w, False, 0L, (XEvent *) &ev); } void -SendDeleteWindowMessage (tmp, timestamp) - TwmWindow *tmp; - Time timestamp; +SendDeleteWindowMessage (TwmWindow *tmp, Time timestamp) { send_clientmessage (tmp->w, _XA_WM_DELETE_WINDOW, timestamp); } void -SendSaveYourselfMessage (tmp, timestamp) - TwmWindow *tmp; - Time timestamp; +SendSaveYourselfMessage (TwmWindow *tmp, Time timestamp) { send_clientmessage (tmp->w, _XA_WM_SAVE_YOURSELF, timestamp); } void -SendTakeFocusMessage (tmp, timestamp) - TwmWindow *tmp; - Time timestamp; +SendTakeFocusMessage (TwmWindow *tmp, Time timestamp) { send_clientmessage (tmp->w, _XA_WM_TAKE_FOCUS, timestamp); } Index: xc/programs/twm/parse.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/parse.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 parse.c --- xc/programs/twm/parse.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/parse.c 11 Mar 2005 16:17:29 -0000 @@ -81,55 +81,45 @@ static FILE *twmrc; static int ptr = 0; static int len = 0; static char buff[BUF_LEN+1]; static unsigned char overflowbuff[20]; /* really only need one */ static int overflowlen; static char **stringListSource, *currentString; 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; int ConstrainedMoveTime = 400; /* milliseconds, event times */ int (*twmInputFunc)(void); -/*********************************************************************** - * - * Procedure: - * ParseTwmrc - parse the .twmrc file - * - * Inputs: - * filename - the filename to parse. A NULL indicates $HOME/.twmrc - * - *********************************************************************** +/** + * parse the .twmrc file + * \param filename the filename to parse. NULL indicates $HOME/.twmrc */ - -static int doparse (ifunc, srctypename, srcname) - int (*ifunc)(void); - char *srctypename; - char *srcname; +static int doparse (int (*ifunc)(void), char *srctypename, char*srcname) { mods = 0; ptr = 0; len = 0; yylineno = 1; ParseError = FALSE; twmInputFunc = ifunc; overflowlen = 0; yyparse(); if (Scr->PointerForeground.pixel != Scr->Black || Scr->PointerBackground.pixel != Scr->White) { XRecolorCursor(dpy, UpperLeftCursor, &Scr->PointerForeground, &Scr->PointerBackground); XRecolorCursor(dpy, RightButt, &Scr->PointerForeground, &Scr->PointerBackground); XRecolorCursor(dpy, LeftButt, &Scr->PointerForeground, &Scr->PointerBackground); @@ -151,42 +141,41 @@ &Scr->PointerForeground, &Scr->PointerBackground); XRecolorCursor(dpy, Scr->ButtonCursor, &Scr->PointerForeground, &Scr->PointerBackground); XRecolorCursor(dpy, Scr->WaitCursor, &Scr->PointerForeground, &Scr->PointerBackground); XRecolorCursor(dpy, Scr->SelectCursor, &Scr->PointerForeground, &Scr->PointerBackground); XRecolorCursor(dpy, Scr->DestroyCursor, &Scr->PointerForeground, &Scr->PointerBackground); } if (ParseError) { fprintf (stderr, "%s: errors found in twm %s", ProgramName, srctypename); if (srcname) fprintf (stderr, " \"%s\"", srcname); fprintf (stderr, "\n"); } return (ParseError ? 0 : 1); } -int ParseTwmrc (filename) - char *filename; +int ParseTwmrc (char *filename) { int i; char *home = NULL; int homelen = 0; char *cp = NULL; char tmpfilename[257]; /* * If filename given, try it, else try ~/.twmrc.# then ~/.twmrc. Then * try system.twmrc; finally using built-in defaults. */ for (twmrc = NULL, i = 0; !twmrc && i < 4; i++) { switch (i) { case 0: /* -f filename */ cp = filename; break; case 1: /* ~/.twmrc.screennum */ if (!filename) { home = getenv ("HOME"); @@ -218,140 +207,118 @@ int status; if (filename && cp != filename) { fprintf (stderr, "%s: unable to open twmrc file %s, using %s instead\n", ProgramName, filename, cp); } status = doparse (twmFileInput, "file", cp); fclose (twmrc); return status; } else { if (filename) { fprintf (stderr, "%s: unable to open twmrc file %s, using built-in defaults instead\n", ProgramName, filename); } return ParseStringList (defTwmrc); } } -int ParseStringList (sl) - char **sl; +int ParseStringList (char **sl) { stringListSource = sl; currentString = *sl; return doparse (twmStringListInput, "string list", (char *)NULL); } -/*********************************************************************** - * - * Procedure: - * twmFileInput - redefinition of the lex input routine for file input - * - * Returned Value: - * the next input character +/** + * redefinition of the lex input routine for file input * - *********************************************************************** + * \return the next input character */ - static int twmFileInput() { if (overflowlen) return (int) overflowbuff[--overflowlen]; while (ptr == len) { if (fgets(buff, BUF_LEN, twmrc) == NULL) return 0; ptr = 0; len = strlen(buff); } return ((int)buff[ptr++]); } static int twmStringListInput() { if (overflowlen) return (int) overflowbuff[--overflowlen]; /* * return the character currently pointed to */ if (currentString) { unsigned int c = (unsigned int) *currentString++; if (c) return c; /* if non-nul char */ currentString = *++stringListSource; /* advance to next bol */ return '\n'; /* but say that we hit last eol */ } return 0; /* eof */ } -/*********************************************************************** - * - * Procedure: - * twmUnput - redefinition of the lex unput routine - * - * Inputs: - * c - the character to push back onto the input stream +/* + * redefinition of the lex unput routine * - *********************************************************************** + * \param c the character to push back onto the input stream */ - -void twmUnput (c) - int c; +void twmUnput (int c) { if (overflowlen < sizeof overflowbuff) { overflowbuff[overflowlen++] = (unsigned char) c; } else { twmrc_error_prefix (); fprintf (stderr, "unable to unput character (%d)\n", c); } } -/*********************************************************************** +/** + * redefinition of the lex output routine * - * Procedure: - * TwmOutput - redefinition of the lex output routine - * - * Inputs: - * c - the character to print - * - *********************************************************************** + * \param c the character to print */ void -TwmOutput(c) - int c; +TwmOutput(int c) { putchar(c); } /********************************************************************** - * * Parsing table and routines - * ***********************************************************************/ typedef struct _TwmKeyword { char *name; int value; int subnum; } TwmKeyword; #define kw0_NoDefaults 1 #define kw0_AutoRelativeResize 2 #define kw0_ForceIcons 3 #define kw0_NoIconManagers 4 #define kw0_OpaqueMove 5 #define kw0_InterpolateMenuColors 6 #define kw0_NoVersion 7 #define kw0_SortIconManager 8 #define kw0_NoGrabServer 9 #define kw0_NoMenuShadows 10 #define kw0_NoRaiseOnMove 11 #define kw0_NoRaiseOnResize 12 @@ -608,72 +575,69 @@ { "titlefont", SKEYWORD, kws_TitleFont }, { "titleforeground", CLKEYWORD, kwcl_TitleForeground }, { "titlehighlight", TITLE_HILITE, 0 }, { "titlepadding", NKEYWORD, kwn_TitlePadding }, { "unknownicon", SKEYWORD, kws_UnknownIcon }, { "usepposition", SKEYWORD, kws_UsePPosition }, { "w", WINDOW, 0 }, { "wait", WAIT, 0 }, { "warpcursor", WARP_CURSOR, 0 }, { "warpunmapped", KEYWORD, kw0_WarpUnmapped }, { "west", DKEYWORD, D_WEST }, { "window", WINDOW, 0 }, { "windowfunction", WINDOW_FUNCTION, 0 }, { "windowring", WINDOW_RING, 0 }, { "xorvalue", NKEYWORD, kwn_XorValue }, { "zoom", ZOOM, 0 }, }; static int numkeywords = (sizeof(keytable)/sizeof(keytable[0])); -int parse_keyword (s, nump) - char *s; - int *nump; +int parse_keyword (char *s, int *nump) { register int lower = 0, upper = numkeywords - 1; XmuCopyISOLatin1Lowered (s, s); while (lower <= upper) { int middle = (lower + upper) / 2; TwmKeyword *p = &keytable[middle]; int res = strcmp (p->name, s); if (res < 0) { lower = middle + 1; } else if (res == 0) { *nump = p->subnum; return p->value; } else { upper = middle - 1; } } return ERRORTOKEN; } /* * action routines called by grammar */ -int do_single_keyword (keyword) - int keyword; +int do_single_keyword (int keyword) { switch (keyword) { case kw0_NoDefaults: Scr->NoDefaults = TRUE; return 1; case kw0_AutoRelativeResize: Scr->AutoRelativeResize = TRUE; return 1; case kw0_ForceIcons: if (Scr->FirstTime) Scr->ForceIcon = TRUE; return 1; case kw0_NoIconManagers: Scr->NoIconManagers = TRUE; return 1; case kw0_OpaqueMove: Scr->OpaqueMove = TRUE; @@ -747,43 +711,41 @@ Scr->ShowIconManager = TRUE; return 1; case kw0_NoCaseSensitive: Scr->CaseSensitive = FALSE; return 1; case kw0_NoRaiseOnWarp: Scr->NoRaiseWarp = TRUE; return 1; case kw0_WarpUnmapped: Scr->WarpUnmapped = TRUE; return 1; } return 0; } -int do_string_keyword (keyword, s) - int keyword; - char *s; +int do_string_keyword (int keyword, char *s) { switch (keyword) { case kws_UsePPosition: { int ppos = ParseUsePPosition (s); if (ppos < 0) { twmrc_error_prefix(); fprintf (stderr, "ignoring invalid UsePPosition argument \"%s\"\n", s); } else { Scr->UsePPosition = ppos; } return 1; } case kws_IconFont: if (!Scr->HaveFonts) Scr->IconFont.name = s; return 1; case kws_ResizeFont: @@ -815,43 +777,41 @@ if ((JunkMask & (WidthValue | HeightValue)) != (WidthValue | HeightValue)) { twmrc_error_prefix(); fprintf (stderr, "bad MaxWindowSize \"%s\"\n", s); return 0; } if (JunkWidth <= 0 || JunkHeight <= 0) { twmrc_error_prefix(); fprintf (stderr, "MaxWindowSize \"%s\" must be positive\n", s); return 0; } Scr->MaxWindowWidth = JunkWidth; Scr->MaxWindowHeight = JunkHeight; return 1; } return 0; } -int do_number_keyword (keyword, num) - int keyword; - int num; +int do_number_keyword (int keyword, int num) { switch (keyword) { case kwn_ConstrainedMoveTime: ConstrainedMoveTime = num; return 1; case kwn_MoveDelta: Scr->MoveDelta = num; return 1; case kwn_XorValue: if (Scr->FirstTime) Scr->XORvalue = num; return 1; case kwn_FramePadding: if (Scr->FirstTime) Scr->FramePadding = num; return 1; case kwn_TitlePadding: if (Scr->FirstTime) Scr->TitlePadding = num; @@ -868,44 +828,41 @@ case kwn_IconBorderWidth: if (Scr->FirstTime) Scr->IconBorderWidth = num; return 1; case kwn_MenuBorderWidth: if (Scr->FirstTime) Scr->MenuBorderWidth = num; return 1; case kwn_TitleButtonBorderWidth: if (Scr->FirstTime) Scr->TBInfo.border = num; return 1; case kwn_Priority: if (HasSync) XSyncSetPriority(dpy, /*self*/ None, num); return 1; } return 0; } -name_list **do_colorlist_keyword (keyword, colormode, s) - int keyword; - int colormode; - char *s; +name_list **do_colorlist_keyword (int keyword, int colormode, char *s) { switch (keyword) { case kwcl_BorderColor: GetColor (colormode, &Scr->BorderColor, s); return &Scr->BorderColorL; case kwcl_IconManagerHighlight: GetColor (colormode, &Scr->IconManagerHighlight, s); return &Scr->IconManagerHighlightL; case kwcl_BorderTileForeground: GetColor (colormode, &Scr->BorderTileC.fore, s); return &Scr->BorderTileForegroundL; case kwcl_BorderTileBackground: GetColor (colormode, &Scr->BorderTileC.back, s); return &Scr->BorderTileBackgroundL; case kwcl_TitleForeground: GetColor (colormode, &Scr->TitleC.fore, s); @@ -921,44 +878,41 @@ case kwcl_IconBackground: GetColor (colormode, &Scr->IconC.back, s); return &Scr->IconBackgroundL; case kwcl_IconBorderColor: GetColor (colormode, &Scr->IconBorderColor, s); return &Scr->IconBorderColorL; case kwcl_IconManagerForeground: GetColor (colormode, &Scr->IconManagerC.fore, s); return &Scr->IconManagerFL; case kwcl_IconManagerBackground: GetColor (colormode, &Scr->IconManagerC.back, s); return &Scr->IconManagerBL; } return NULL; } -int do_color_keyword (keyword, colormode, s) - int keyword; - int colormode; - char *s; +int do_color_keyword (int keyword, int colormode, char *s) { switch (keyword) { case kwc_DefaultForeground: GetColor (colormode, &Scr->DefaultC.fore, s); return 1; case kwc_DefaultBackground: GetColor (colormode, &Scr->DefaultC.back, s); return 1; case kwc_MenuForeground: GetColor (colormode, &Scr->MenuC.fore, s); return 1; case kwc_MenuBackground: GetColor (colormode, &Scr->MenuC.back, s); return 1; case kwc_MenuBorderColor: GetColor (colormode, &Scr->MenuBorderColor, s); @@ -971,105 +925,101 @@ case kwc_MenuTitleBackground: GetColor (colormode, &Scr->MenuTitleC.back, s); return 1; case kwc_MenuShadowColor: GetColor (colormode, &Scr->MenuShadowColor, s); return 1; case kwc_PointerForeground: GetColorValue (colormode, &Scr->PointerForeground, s); return 1; case kwc_PointerBackground: GetColorValue (colormode, &Scr->PointerBackground, s); return 1; } return 0; } -/* - * put_pixel_on_root() Save a pixel value in twm root window color property. +/** + * Save a pixel value in twm root window color property. */ void -put_pixel_on_root(pixel) - Pixel pixel; +put_pixel_on_root(Pixel pixel) { int i, addPixel = 1; Atom pixelAtom, retAtom; int retFormat; unsigned long nPixels, retAfter; Pixel *retProp; pixelAtom = XInternAtom(dpy, "_MIT_PRIORITY_COLORS", True); XGetWindowProperty(dpy, Scr->Root, pixelAtom, 0, 8192, False, XA_CARDINAL, &retAtom, &retFormat, &nPixels, &retAfter, (unsigned char **)&retProp); for (i=0; i< nPixels; i++) if (pixel == retProp[i]) addPixel = 0; if (addPixel) XChangeProperty (dpy, Scr->Root, _XA_MIT_PRIORITY_COLORS, XA_CARDINAL, 32, PropModeAppend, (unsigned char *)&pixel, 1); } -/* - * do_string_savecolor() save a color from a string in the twmrc file. +/** + * save a color from a string in the twmrc file. */ void -do_string_savecolor(colormode, s) - int colormode; - char *s; +do_string_savecolor(int colormode, char *s) { Pixel p; GetColor(colormode, &p, s); put_pixel_on_root(p); } -/* - * do_var_savecolor() save a color from a var in the twmrc file. - */ typedef struct _cnode {int i; struct _cnode *next;} Cnode, *Cptr; Cptr chead = NULL; +/** + * save a color from a var in the twmrc file + */ void -do_var_savecolor(key) -int key; +do_var_savecolor(int key) { Cptr cptrav, cpnew; if (!chead) { chead = (Cptr)malloc(sizeof(Cnode)); chead->i = key; chead->next = NULL; } else { cptrav = chead; while (cptrav->next != NULL) { cptrav = cptrav->next; } cpnew = (Cptr)malloc(sizeof(Cnode)); cpnew->i = key; cpnew->next = NULL; cptrav->next = cpnew; } } -/* - * assign_var_savecolor() traverse the var save color list placeing the pixels +/** + * traverse the var save color list placeing the pixels * in the root window property. */ void assign_var_savecolor() { Cptr cp = chead; while (cp != NULL) { switch (cp->i) { case kwcl_BorderColor: put_pixel_on_root(Scr->BorderColor); break; case kwcl_IconManagerHighlight: put_pixel_on_root(Scr->IconManagerHighlight); break; case kwcl_BorderTileForeground: put_pixel_on_root(Scr->BorderTileC.fore); break; case kwcl_BorderTileBackground: put_pixel_on_root(Scr->BorderTileC.back); break; @@ -1087,65 +1037,67 @@ break; case kwcl_IconBorderColor: put_pixel_on_root(Scr->IconBorderColor); break; case kwcl_IconManagerForeground: put_pixel_on_root(Scr->IconManagerC.fore); break; case kwcl_IconManagerBackground: put_pixel_on_root(Scr->IconManagerC.back); break; } cp = cp->next; } if (chead) { free(chead); chead = NULL; } } static int -ParseUsePPosition (s) - register char *s; +ParseUsePPosition (char *s) { XmuCopyISOLatin1Lowered (s, s); if (strcmp (s, "off") == 0) { return PPOS_OFF; } else if (strcmp (s, "on") == 0) { return PPOS_ON; } else if (strcmp (s, "non-zero") == 0 || strcmp (s, "nonzero") == 0) { return PPOS_NON_ZERO; } return -1; } +/** + * + * \param list squeeze or dont-squeeze list + * \param name window name + * \param justify left, center, or right + * \param num signed num + * \param denom 0 or indicates fraction denom + */ void -do_squeeze_entry (list, name, justify, num, denom) - name_list **list; /* squeeze or dont-squeeze list */ - char *name; /* window name */ - int justify; /* left, center, right */ - int num; /* signed num */ - int denom; /* 0 or indicates fraction denom */ +do_squeeze_entry (name_list **list, char *name, int justify, int num, int denom) { int absnum = (num < 0 ? -num : num); if (denom < 0) { twmrc_error_prefix(); fprintf (stderr, "negative SqueezeTitle denominator %d\n", denom); return; } if (absnum > denom && denom != 0) { twmrc_error_prefix(); fprintf (stderr, "SqueezeTitle fraction %d/%d outside window\n", num, denom); return; } if (denom == 1) { twmrc_error_prefix(); fprintf (stderr, "useless SqueezeTitle faction %d/%d, assuming 0/0\n", num, denom); num = 0; denom = 0; Index: xc/programs/twm/resize.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/resize.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 resize.c --- xc/programs/twm/resize.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/resize.c 11 Mar 2005 16:17:29 -0000 @@ -123,58 +123,48 @@ (dragHeight < 3 ? 1 : (dragHeight / 3))); if (h <= 0) { clampLeft = 1; clampDX = (x - dragx); } else if (h >= 2) { clampRight = 1; clampDX = (x - dragx - dragWidth); } if (v <= 0) { clampTop = 1; clampDY = (y - dragy); } else if (v >= 2) { clampBottom = 1; clampDY = (y - dragy - dragHeight); } } -/*********************************************************************** - * - * Procedure: - * StartResize - begin a window resize operation - * - * Inputs: - * ev - the event structure (button press) - * tmp_win - the TwmWindow pointer - * fromtitlebar - action invoked from titlebar button - * - *********************************************************************** +/** + * begin a window resize operation + * \param ev the event structure (button press) + * \param tmp_win the TwmWindow pointer + * \param fromtitlebar action invoked from titlebar button */ - void -StartResize(evp, tmp_win, fromtitlebar) -XEvent *evp; -TwmWindow *tmp_win; -Bool fromtitlebar; +StartResize(XEvent *evp, TwmWindow *tmp_win, Bool fromtitlebar) { Window junkRoot; unsigned int junkbw, junkDepth; ResizeWindow = tmp_win->frame; XGrabServer(dpy); XGrabPointer(dpy, Scr->Root, True, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PointerMotionHintMask, GrabModeAsync, GrabModeAsync, Scr->Root, Scr->ResizeCursor, CurrentTime); XGetGeometry(dpy, (Drawable) tmp_win->frame, &junkRoot, &dragx, &dragy, (unsigned int *)&dragWidth, (unsigned int *)&dragHeight, &junkbw, &junkDepth); dragx += tmp_win->frame_bw; dragy += tmp_win->frame_bw; origx = dragx; origy = dragy; origWidth = dragWidth; @@ -185,117 +175,103 @@ do_auto_clamp (tmp_win, evp); Scr->SizeStringOffset = SIZE_HINDENT; XResizeWindow (dpy, Scr->SizeWindow, Scr->SizeStringWidth + SIZE_HINDENT * 2, Scr->SizeFont.height + SIZE_VINDENT * 2); XMapRaised(dpy, Scr->SizeWindow); InstallRootColormap(); last_width = 0; last_height = 0; DisplaySize(tmp_win, origWidth, origHeight); MoveOutline (Scr->Root, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw, dragWidth + 2 * tmp_win->frame_bw, dragHeight + 2 * tmp_win->frame_bw, tmp_win->frame_bw, tmp_win->title_height); } void -MenuStartResize(tmp_win, x, y, w, h) -TwmWindow *tmp_win; -int x, y, w, h; +MenuStartResize(TwmWindow *tmp_win, int x, int y, int w, int h) { XGrabServer(dpy); XGrabPointer(dpy, Scr->Root, True, ButtonPressMask | ButtonMotionMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, Scr->Root, Scr->ResizeCursor, CurrentTime); dragx = x + tmp_win->frame_bw; dragy = y + tmp_win->frame_bw; origx = dragx; origy = dragy; dragWidth = origWidth = w; /* - 2 * tmp_win->frame_bw; */ dragHeight = origHeight = h; /* - 2 * tmp_win->frame_bw; */ clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0; last_width = 0; last_height = 0; Scr->SizeStringOffset = SIZE_HINDENT; XResizeWindow (dpy, Scr->SizeWindow, Scr->SizeStringWidth + SIZE_HINDENT * 2, Scr->SizeFont.height + SIZE_VINDENT * 2); XMapRaised(dpy, Scr->SizeWindow); DisplaySize(tmp_win, origWidth, origHeight); MoveOutline (Scr->Root, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw, dragWidth + 2 * tmp_win->frame_bw, dragHeight + 2 * tmp_win->frame_bw, tmp_win->frame_bw, tmp_win->title_height); } -/*********************************************************************** - * - * Procedure: - * AddStartResize - begin a windorew resize operation from AddWindow - * - * Inputs: - * tmp_win - the TwmWindow pointer - * - *********************************************************************** +/** + * begin a windorew resize operation from AddWindow + * \param tmp_win the TwmWindow pointer */ - void -AddStartResize(tmp_win, x, y, w, h) -TwmWindow *tmp_win; -int x, y, w, h; +AddStartResize(TwmWindow *tmp_win, int x, int y, int w, int h) { XGrabServer(dpy); XGrabPointer(dpy, Scr->Root, True, ButtonReleaseMask | ButtonMotionMask | PointerMotionHintMask, GrabModeAsync, GrabModeAsync, Scr->Root, Scr->ResizeCursor, CurrentTime); dragx = x + tmp_win->frame_bw; dragy = y + tmp_win->frame_bw; origx = dragx; origy = dragy; dragWidth = origWidth = w - 2 * tmp_win->frame_bw; dragHeight = origHeight = h - 2 * tmp_win->frame_bw; clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0; /***** if (Scr->AutoRelativeResize) { clampRight = clampBottom = 1; } *****/ last_width = 0; last_height = 0; DisplaySize(tmp_win, origWidth, origHeight); } void -MenuDoResize(x_root, y_root, tmp_win) -int x_root; -int y_root; -TwmWindow *tmp_win; +MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win) { int action; action = 0; x_root -= clampDX; y_root -= clampDY; if (clampTop) { int delta = y_root - dragy; if (dragHeight - delta < MINHEIGHT) { delta = dragHeight - MINHEIGHT; clampTop = 0; } dragy += delta; dragHeight -= delta; action = 1; } else if (y_root <= dragy/* || y_root == findRootInfo(root)->rooty*/) { @@ -362,59 +338,51 @@ action = 1; } if (action) { ConstrainSize (tmp_win, &dragWidth, &dragHeight); if (clampLeft) dragx = origx + origWidth - dragWidth; if (clampTop) dragy = origy + origHeight - dragHeight; MoveOutline(Scr->Root, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw, dragWidth + 2 * tmp_win->frame_bw, dragHeight + 2 * tmp_win->frame_bw, tmp_win->frame_bw, tmp_win->title_height); } DisplaySize(tmp_win, dragWidth, dragHeight); } -/*********************************************************************** - * - * Procedure: - * DoResize - move the rubberband around. This is called for - * each motion event when we are resizing - * - * Inputs: - * x_root - the X corrdinate in the root window - * y_root - the Y corrdinate in the root window - * tmp_win - the current twm window - * - *********************************************************************** - */ +/** + * move the rubberband around. This is called for each motion event when + * we are resizing + * + * \param x_root the X corrdinate in the root window + * \param y_root the Y corrdinate in the root window + * \param tmp_win the current twm window + */ void -DoResize(x_root, y_root, tmp_win) -int x_root; -int y_root; -TwmWindow *tmp_win; +DoResize(int x_root, int y_root, TwmWindow *tmp_win) { int action; action = 0; x_root -= clampDX; y_root -= clampDY; if (clampTop) { int delta = y_root - dragy; if (dragHeight - delta < MINHEIGHT) { delta = dragHeight - MINHEIGHT; clampTop = 0; } dragy += delta; dragHeight -= delta; action = 1; } else if (y_root <= dragy/* || y_root == findRootInfo(root)->rooty*/) { @@ -485,58 +453,49 @@ action = 1; } if (action) { ConstrainSize (tmp_win, &dragWidth, &dragHeight); if (clampLeft) dragx = origx + origWidth - dragWidth; if (clampTop) dragy = origy + origHeight - dragHeight; MoveOutline(Scr->Root, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw, dragWidth + 2 * tmp_win->frame_bw, dragHeight + 2 * tmp_win->frame_bw, tmp_win->frame_bw, tmp_win->title_height); } DisplaySize(tmp_win, dragWidth, dragHeight); } -/*********************************************************************** - * - * Procedure: - * DisplaySize - display the size in the dimensions window +/** + * display the size in the dimensions window. * - * Inputs: - * tmp_win - the current twm window - * width - the width of the rubber band - * height - the height of the rubber band - * - *********************************************************************** + * \param tmp_win the current twm window + * \param width the width of the rubber band + * \param height the height of the rubber band */ - void -DisplaySize(tmp_win, width, height) -TwmWindow *tmp_win; -int width; -int height; +DisplaySize(TwmWindow *tmp_win, int width, int height) { char str[100]; int dwidth; int dheight; if (last_width == width && last_height == height) return; last_width = width; last_height = height; dheight = height - tmp_win->title_height; dwidth = width; /* * ICCCM says that PMinSize is the default is no PBaseSize is given, * and vice-versa. */ if (tmp_win->hints.flags&(PMinSize|PBaseSize) && tmp_win->hints.flags & PResizeInc) { @@ -547,48 +506,43 @@ dwidth -= tmp_win->hints.min_width; dheight -= tmp_win->hints.min_height; } } if (tmp_win->hints.flags & PResizeInc) { dwidth /= tmp_win->hints.width_inc; dheight /= tmp_win->hints.height_inc; } (void) sprintf (str, " %4d x %-4d ", dwidth, dheight); XRaiseWindow(dpy, Scr->SizeWindow); 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); } -/*********************************************************************** - * - * Procedure: - * EndResize - finish the resize operation - * - *********************************************************************** +/** + * finish the resize operation */ - void EndResize() { TwmWindow *tmp_win; #ifdef DEBUG fprintf(stderr, "EndResize\n"); #endif MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0); XUnmapWindow(dpy, Scr->SizeWindow); XFindContext(dpy, ResizeWindow, TwmContext, (caddr_t *)&tmp_win); ConstrainSize (tmp_win, &dragWidth, &dragHeight); if (dragWidth != tmp_win->frame_width || dragHeight != tmp_win->frame_height) tmp_win->zoomed = ZOOM_NONE; @@ -598,93 +552,81 @@ if (tmp_win->iconmgr) { int ncols = tmp_win->iconmgrp->cur_columns; if (ncols == 0) ncols = 1; tmp_win->iconmgrp->width = (int) ((dragWidth * (long) tmp_win->iconmgrp->columns) / ncols); PackIconManager(tmp_win->iconmgrp); } if (!Scr->NoRaiseResize) XRaiseWindow(dpy, tmp_win->frame); UninstallRootColormap(); ResizeWindow = None; } void -MenuEndResize(tmp_win) -TwmWindow *tmp_win; +MenuEndResize(TwmWindow *tmp_win) { MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0); XUnmapWindow(dpy, Scr->SizeWindow); ConstrainSize (tmp_win, &dragWidth, &dragHeight); 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); } -/*********************************************************************** - * - * Procedure: - * AddEndResize - finish the resize operation for AddWindoframe_bw); AddingH = dragHeight + (2 * tmp_win->frame_bw); } -/*********************************************************************** - * - * Procedure: - * ConstrainSize - adjust the given width and height to account for the - * constraints imposed by size hints +/** + * adjust the given width and height to account for the constraints imposed + * by size hints. * * The general algorithm, especially the aspect ratio stuff, is * borrowed from uwm's CheckConsistency routine. - * - ***********************************************************************/ + */ void -ConstrainSize (tmp_win, widthp, heightp) - TwmWindow *tmp_win; - int *widthp, *heightp; +ConstrainSize (TwmWindow *tmp_win, int *widthp, int *heightp) { #define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) ) #define _min(a,b) (((a) < (b)) ? (a) : (b)) int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta; int baseWidth, baseHeight; int dwidth = *widthp, dheight = *heightp; dheight -= tmp_win->title_height; if (tmp_win->hints.flags & PMinSize) { minWidth = tmp_win->hints.min_width; minHeight = tmp_win->hints.min_height; } else if (tmp_win->hints.flags & PBaseSize) { minWidth = tmp_win->hints.base_width; minHeight = tmp_win->hints.base_height; } else minWidth = minHeight = 1; @@ -772,78 +714,69 @@ yinc); if (dheight + delta <= maxHeight) dheight += delta; else { delta = makemult(dwidth - maxAspectX*dheight/maxAspectY, xinc); if (dwidth - delta >= minWidth) dwidth -= delta; } } } /* * Fourth, account for border width and title height */ *widthp = dwidth; *heightp = dheight + tmp_win->title_height; } -/*********************************************************************** - * - * Procedure: - * SetupWindow - set window sizes, this was called from either - * AddWindow, EndResize, or HandleConfigureNotify. - * - * Inputs: - * tmp_win - the TwmWindow pointer - * x - the x coordinate of the upper-left outer corner of the frame - * y - the y coordinate of the upper-left outer corner of the frame - * w - the width of the frame window w/o border - * h - the height of the frame window w/o border - * bw - the border width of the frame window or -1 not to change +/** + * set window sizes, this was called from either AddWindow, EndResize, or + * HandleConfigureNotify. * * Special Considerations: - * This routine will check to make sure the window is not completely - * off the display, if it is, it'll bring some of it back on. - * - * The tmp_win->frame_XXX variables should NOT be updated with the - * values of x,y,w,h prior to calling this routine, since the new - * values are compared against the old to see whether a synthetic - * ConfigureNotify event should be sent. (It should be sent if the - * window was moved but not resized.) + * This routine will check to make sure the window is not completely off the + * display, if it is, it'll bring some of it back on. * - *********************************************************************** + * The tmp_win->frame_XXX variables should NOT be updated with the values of + * x,y,w,h prior to calling this routine, since the new values are compared + * against the old to see whether a synthetic ConfigureNotify event should be + * sent. (It should be sent if the window was moved but not resized.) + * + * \param tmp_win the TwmWindow pointer + * \param x the x coordinate of the upper-left outer corner of the frame + * \param y the y coordinate of the upper-left outer corner of the frame + * \param w the width of the frame window w/o border + * \param h the height of the frame window w/o border + * \param bw the border width of the frame window or -1 not to change */ - -void SetupWindow (tmp_win, x, y, w, h, bw) - TwmWindow *tmp_win; - int x, y, w, h, bw; +void SetupWindow (TwmWindow *tmp_win, int x, int y, int w, int h, int bw) { SetupFrame (tmp_win, x, y, w, h, bw, False); } -void SetupFrame (tmp_win, x, y, w, h, bw, sendEvent) - TwmWindow *tmp_win; - int x, y, w, h, bw; - Bool sendEvent; /* whether or not to force a send */ +/** + * \param sendEvent whether or not to force a send + */ +void SetupFrame (TwmWindow *tmp_win, int x, int y, int w, int h, int bw, Bool sendEvent) { XEvent client_event; XWindowChanges frame_wc, xwc; unsigned long frame_mask, xwcm; int title_width, title_height; int reShape; #ifdef DEBUG fprintf (stderr, "SetupWindow: x=%d, y=%d, w=%d, h=%d, bw=%d\n", x, y, w, h, bw); #endif if (x >= Scr->MyDisplayWidth) x = Scr->MyDisplayWidth - 16; /* one "average" cursor width */ if (y >= Scr->MyDisplayHeight) y = Scr->MyDisplayHeight - 16; /* one "average" cursor width */ if (bw < 0) bw = tmp_win->frame_bw; /* -1 means current frame width */ if (tmp_win->iconmgr) { @@ -955,59 +888,49 @@ client_event.type = ConfigureNotify; client_event.xconfigure.display = dpy; client_event.xconfigure.event = tmp_win->w; client_event.xconfigure.window = tmp_win->w; client_event.xconfigure.x = (x + tmp_win->frame_bw - tmp_win->old_bw); client_event.xconfigure.y = (y + tmp_win->frame_bw + tmp_win->title_height - tmp_win->old_bw); client_event.xconfigure.width = tmp_win->frame_width; client_event.xconfigure.height = tmp_win->frame_height - tmp_win->title_height; client_event.xconfigure.border_width = tmp_win->old_bw; /* Real ConfigureNotify events say we're above title window, so ... */ /* what if we don't have a title ????? */ client_event.xconfigure.above = tmp_win->frame; client_event.xconfigure.override_redirect = False; XSendEvent(dpy, tmp_win->w, False, StructureNotifyMask, &client_event); } } -/********************************************************************** - * Rutgers mod #1 - rocky. - * Procedure: - * fullzoom - zooms window to full height of screen or - * to full height and width of screen. (Toggles - * so that it can undo the zoom - even when switching - * between fullzoom and vertical zoom.) - * - * Inputs: - * tmp_win - the TwmWindow pointer +/** + * zooms window to full height of screen or to full height and width of screen. + * (Toggles so that it can undo the zoom - even when switching between fullzoom + * and vertical zoom.) * - * - ********************************************************************** + * \param tmp_win the TwmWindow pointer */ - void -fullzoom(tmp_win,flag) -TwmWindow *tmp_win; -int flag; +fullzoom(TwmWindow *tmp_win, int flag) { Window junkRoot; unsigned int junkbw, junkDepth; int basex, basey; int frame_bw_times_2; XGetGeometry(dpy, (Drawable) tmp_win->frame, &junkRoot, &dragx, &dragy, (unsigned int *)&dragWidth, (unsigned int *)&dragHeight, &junkbw, &junkDepth); basex = 0; basey = 0; if (tmp_win->zoomed == flag) { dragHeight = tmp_win->save_frame_height; dragWidth = tmp_win->save_frame_width; dragx = tmp_win->save_frame_x; dragy = tmp_win->save_frame_y; tmp_win->zoomed = ZOOM_NONE; @@ -1067,42 +990,41 @@ case F_BOTTOMZOOM: dragx = basex; dragy = basey + Scr->MyDisplayHeight/2; dragHeight = Scr->MyDisplayHeight/2 - frame_bw_times_2; dragWidth = Scr->MyDisplayWidth - frame_bw_times_2; break; } } if (!Scr->NoRaiseResize) XRaiseWindow(dpy, tmp_win->frame); ConstrainSize(tmp_win, &dragWidth, &dragHeight); SetupWindow (tmp_win, dragx , dragy , dragWidth, dragHeight, -1); XUngrabPointer (dpy, CurrentTime); XUngrabServer (dpy); } void -SetFrameShape (tmp) - TwmWindow *tmp; +SetFrameShape (TwmWindow *tmp) { /* * see if the titlebar needs to move */ if (tmp->title_w) { int oldx = tmp->title_x, oldy = tmp->title_y; ComputeTitleLocation (tmp); if (oldx != tmp->title_x || oldy != tmp->title_y) XMoveWindow (dpy, tmp->title_w, tmp->title_x, tmp->title_y); } /* * The frame consists of the shape of the contents window offset by * title_height or'ed with the shape of title_w (which is always * rectangular). */ if (tmp->wShaped) { /* * need to do general case */ Index: xc/programs/twm/twm.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/twm.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 twm.c --- xc/programs/twm/twm.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/twm.c 11 Mar 2005 16:17:30 -0000 @@ -596,48 +596,43 @@ FirstScreen = FALSE; Scr->FirstTime = FALSE; } /* for */ if (numManaged == 0) { if (MultiScreen && NumScreens > 0) fprintf (stderr, "%s: unable to find any unmanaged screens\n", ProgramName); exit (1); } (void) ConnectToSessionManager (client_id); RestartPreviousState = False; HandlingEvents = TRUE; InitEvents(); HandleEvents(); exit(0); } -/*********************************************************************** - * - * Procedure: - * InitVariables - initialize twm variables - * - *********************************************************************** +/** + * initialize twm variables */ - void InitVariables() { FreeList(&Scr->BorderColorL); FreeList(&Scr->IconBorderColorL); FreeList(&Scr->BorderTileForegroundL); FreeList(&Scr->BorderTileBackgroundL); FreeList(&Scr->TitleForegroundL); FreeList(&Scr->TitleBackgroundL); FreeList(&Scr->IconForegroundL); FreeList(&Scr->IconBackgroundL); FreeList(&Scr->IconManagerFL); FreeList(&Scr->IconManagerBL); FreeList(&Scr->IconMgrs); FreeList(&Scr->NoTitle); FreeList(&Scr->MakeTitle); FreeList(&Scr->AutoRaise); FreeList(&Scr->IconNames); FreeList(&Scr->NoHighlight); FreeList(&Scr->NoStackModeL); @@ -766,42 +761,41 @@ 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); GetFont(&Scr->MenuFont); GetFont(&Scr->IconFont); GetFont(&Scr->SizeFont); GetFont(&Scr->IconManagerFont); GetFont(&Scr->DefaultFont); Scr->HaveFonts = TRUE; } void -RestoreWithdrawnLocation (tmp) - TwmWindow *tmp; +RestoreWithdrawnLocation (TwmWindow *tmp) { int gravx, gravy; unsigned int bw, mask; XWindowChanges xwc; if (XGetGeometry (dpy, tmp->w, &JunkRoot, &xwc.x, &xwc.y, &JunkWidth, &JunkHeight, &bw, &JunkDepth)) { GetGravityOffsets (tmp, &gravx, &gravy); if (gravy < 0) xwc.y -= tmp->title_height; if (bw != tmp->old_bw) { int xoff, yoff; if (!Scr->ClientBorderWidth) { xoff = gravx; yoff = gravy; } else { xoff = 0; yoff = 0; @@ -815,120 +809,99 @@ xwc.y += gravy * tmp->frame_bw; } mask = (CWX | CWY); if (bw != tmp->old_bw) { xwc.border_width = tmp->old_bw; mask |= CWBorderWidth; } XConfigureWindow (dpy, tmp->w, mask, &xwc); if (tmp->wmhints && (tmp->wmhints->flags & IconWindowHint)) { XUnmapWindow (dpy, tmp->wmhints->icon_window); } } } void -Reborder (time) -Time time; +Reborder (Time time) { TwmWindow *tmp; /* temp twm window structure */ int scrnum; /* put a border back around all windows */ XGrabServer (dpy); for (scrnum = 0; scrnum < NumScreens; scrnum++) { if ((Scr = ScreenList[scrnum]) == NULL) continue; InstallWindowColormaps (0, &Scr->TwmRoot); /* force reinstall */ for (tmp = Scr->TwmRoot.next; tmp != NULL; tmp = tmp->next) { RestoreWithdrawnLocation (tmp); XMapWindow (dpy, tmp->w); } } XUngrabServer (dpy); SetFocus ((TwmWindow*)NULL, time); } static SIGNAL_T sigHandler(int sig) { XtNoticeSignal(si); SIGNAL_RETURN; } -/*********************************************************************** - * - * Procedure: - * Done - cleanup and exit twm - * - * Returned Value: - * none - * - * Inputs: - * none - * - * Outputs: - * none - * - * Special Considerations: - * none - * - *********************************************************************** +/** + * cleanup and exit twm */ void Done(XtPointer client_data, XtSignalId *si) { if (dpy) { Reborder(CurrentTime); XCloseDisplay(dpy); } exit(0); } + /* * Error Handlers. If a client dies, we'll get a BadWindow error (except for * GetGeometry which returns BadDrawable) for most operations that we do before * manipulating the client's window. */ Bool ErrorOccurred = False; XErrorEvent LastErrorEvent; static int -TwmErrorHandler(dpy, event) - Display *dpy; - XErrorEvent *event; +TwmErrorHandler(Display *dpy, XErrorEvent *event) { LastErrorEvent = *event; ErrorOccurred = True; if (PrintErrorMessages && /* don't be too obnoxious */ event->error_code != BadWindow && /* watch for dead puppies */ (event->request_code != X_GetGeometry && /* of all styles */ event->error_code != BadDrawable)) XmuPrintDefaultErrorMessage (dpy, event, stderr); return 0; } -/* ARGSUSED*/ static int -CatchRedirectError(dpy, event) - Display *dpy; - XErrorEvent *event; +CatchRedirectError(Display *dpy, XErrorEvent *event) { RedirectError = TRUE; LastErrorEvent = *event; ErrorOccurred = True; return 0; } Index: xc/programs/twm/util.c =================================================================== RCS file: /cvs/xorg/xc/programs/twm/util.c,v retrieving revision 1.2 diff -u -2 -0 -r1.2 util.c --- xc/programs/twm/util.c 23 Apr 2004 19:54:37 -0000 1.2 +++ xc/programs/twm/util.c 11 Mar 2005 16:17:30 -0000 @@ -67,61 +67,50 @@ #include "screen.h" #include #include #include #include #include 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; -/*********************************************************************** +/** + * move a window outline * - * Procedure: - * MoveOutline - move a window outline - * - * Inputs: - * root - the window we are outlining - * x - upper left x coordinate - * y - upper left y coordinate - * width - the width of the rectangle - * height - the height of the rectangle - * bw - the border width of the frame - * th - title height - * - *********************************************************************** + * \param root window we are outlining + * \param x,y upper left coordinate + * \param width,height size of the rectangle + * \param bw border width of the frame + * \param th title height */ - -/* ARGSUSED */ -void MoveOutline(root, x, y, width, height, bw, th) - Window root; - int x, y, width, height, bw, th; +void MoveOutline(Window root, int x, int y, int width, int height, int bw, int th) { static int lastx = 0; static int lasty = 0; static int lastWidth = 0; static int lastHeight = 0; static int lastBW = 0; static int lastTH = 0; int xl, xr, yt, yb, xinnerl, xinnerr, yinnert, yinnerb; int xthird, ythird; XSegment outline[18]; register XSegment *r; if (x == lastx && y == lasty && width == lastWidth && height == lastHeight && lastBW == bw && th == lastTH) return; r = outline; #define DRAWIT() \ if (lastWidth || lastHeight) \ @@ -199,171 +188,139 @@ lastx = x; lasty = y; lastWidth = width; lastHeight = height; lastBW = bw; lastTH = th; /* draw the new one, if any */ DRAWIT (); #undef DRAWIT if (r != outline) { XDrawSegments(dpy, root, Scr->DrawGC, outline, r - outline); } } -/*********************************************************************** - * - * Procedure: - * Zoom - zoom in or out of an icon - * - * Inputs: - * wf - window to zoom from - * wt - window to zoom to +/** + * zoom in or out of an icon * - *********************************************************************** + * \param wf window to zoom from + * \param wt window to zoom to */ - void -Zoom(wf, wt) - Window wf, wt; +Zoom(Window wf, Window wt) { int fx, fy, tx, ty; /* from, to */ unsigned int fw, fh, tw, th; /* from, to */ long dx, dy, dw, dh; long z; int j; if (!Scr->DoZoom || Scr->ZoomCount < 1) return; if (wf == None || wt == None) return; XGetGeometry (dpy, wf, &JunkRoot, &fx, &fy, &fw, &fh, &JunkBW, &JunkDepth); XGetGeometry (dpy, wt, &JunkRoot, &tx, &ty, &tw, &th, &JunkBW, &JunkDepth); dx = ((long) (tx - fx)); /* going from -> to */ dy = ((long) (ty - fy)); /* going from -> to */ dw = ((long) (tw - fw)); /* going from -> to */ dh = ((long) (th - fh)); /* going from -> to */ z = (long) (Scr->ZoomCount + 1); for (j = 0; j < 2; j++) { long i; XDrawRectangle (dpy, Scr->Root, Scr->DrawGC, fx, fy, fw, fh); for (i = 1; i < z; i++) { int x = fx + (int) ((dx * i) / z); int y = fy + (int) ((dy * i) / z); unsigned width = (unsigned) (((long) fw) + (dw * i) / z); unsigned height = (unsigned) (((long) fh) + (dh * i) / z); XDrawRectangle (dpy, Scr->Root, Scr->DrawGC, x, y, width, height); } XDrawRectangle (dpy, Scr->Root, Scr->DrawGC, tx, ty, tw, th); } } - -/*********************************************************************** - * - * Procedure: - * ExpandFilename - expand the tilde character to HOME - * if it is the first character of the filename - * - * Returned Value: - * a pointer to the new name +/** + * expand the tilde character to HOME if it is the first + * character of the filename * - * Inputs: - * name - the filename to expand + * \return a pointer to the new name * - *********************************************************************** + * \param name the filename to expand */ - char * -ExpandFilename(name) -char *name; +ExpandFilename(char *name) { char *newname; if (name[0] != '~') return name; newname = (char *) malloc (HomeLen + strlen(name) + 2); if (!newname) { fprintf (stderr, "%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]); } return newname; } -/*********************************************************************** - * - * Procedure: - * GetUnknownIcon - read in the bitmap file for the unknown icon - * - * Inputs: - * name - the filename to read +/** + * read in the bitmap file for the unknown icon * - *********************************************************************** + * \param name the filename to read */ - void -GetUnknownIcon(name) -char *name; +GetUnknownIcon(char *name) { if ((Scr->UnknownPm = GetBitmap(name)) != None) { XGetGeometry(dpy, Scr->UnknownPm, &JunkRoot, &JunkX, &JunkY, (unsigned int *)&Scr->UnknownWidth, (unsigned int *)&Scr->UnknownHeight, &JunkBW, &JunkDepth); } } -/*********************************************************************** - * - * Procedure: +/** * FindBitmap - read in a bitmap file and return size * - * Returned Value: - * the pixmap associated with the bitmap - * widthp - pointer to width of bitmap - * heightp - pointer to height of bitmap + * \return pixmap associated with bitmap * - * Inputs: - * name - the filename to read - * - *********************************************************************** + * \param name filename to read + * \param[out] widthp pointer to width of bitmap + * \param[out] heightp pointer to height of bitmap */ - Pixmap -FindBitmap (name, widthp, heightp) - char *name; - unsigned int *widthp, *heightp; +FindBitmap (char *name, unsigned *widthp, unsigned *heightp) { char *bigname; Pixmap pm; if (!name) return None; /* * Names of the form :name refer to hardcoded images that are scaled to * look nice in title buttons. Eventually, it would be nice to put in a * menu symbol as well.... */ if (name[0] == ':') { int i; static struct { char *name; Pixmap (*proc)(unsigned int *, unsigned int *); } pmtab[] = { { TBPM_DOT, CreateDotPixmap }, { TBPM_ICONIFY, CreateDotPixmap }, { TBPM_RESIZE, CreateResizePixmap }, @@ -407,136 +364,127 @@ "%s: unable to allocate memory for \"%s/%s\"\n", ProgramName, Scr->IconDirectory, name); return None; } (void) sprintf (bigname, "%s/%s", Scr->IconDirectory, name); if (XReadBitmapFile (dpy, Scr->Root, bigname, widthp, heightp, &pm, &HotX, &HotY) != BitmapSuccess) { pm = None; } } if (bigname != name) free (bigname); if (pm == None) { fprintf (stderr, "%s: unable to find bitmap \"%s\"\n", ProgramName, name); } return pm; } Pixmap -GetBitmap (name) - char *name; +GetBitmap (char *name) { return FindBitmap (name, &JunkWidth, &JunkHeight); } void -InsertRGBColormap (a, maps, nmaps, replace) - Atom a; - XStandardColormap *maps; - int nmaps; - Bool replace; +InsertRGBColormap (Atom a, XStandardColormap *maps, int nmaps, Bool replace) { StdCmap *sc = NULL; if (replace) { /* locate existing entry */ for (sc = Scr->StdCmapInfo.head; sc; sc = sc->next) { if (sc->atom == a) break; } } if (!sc) { /* no existing, allocate new */ sc = (StdCmap *) malloc (sizeof (StdCmap)); if (!sc) { fprintf (stderr, "%s: unable to allocate %ld bytes for StdCmap\n", ProgramName, (unsigned long)sizeof (StdCmap)); return; } } if (replace) { /* just update contents */ if (sc->maps) XFree ((char *) maps); if (sc == Scr->StdCmapInfo.mru) Scr->StdCmapInfo.mru = NULL; } else { /* else appending */ sc->next = NULL; sc->atom = a; if (Scr->StdCmapInfo.tail) { Scr->StdCmapInfo.tail->next = sc; } else { Scr->StdCmapInfo.head = sc; } Scr->StdCmapInfo.tail = sc; } sc->nmaps = nmaps; sc->maps = maps; return; } void -RemoveRGBColormap (a) - Atom a; +RemoveRGBColormap (Atom a) { StdCmap *sc, *prev; prev = NULL; for (sc = Scr->StdCmapInfo.head; sc; sc = sc->next) { if (sc->atom == a) break; prev = sc; } if (sc) { /* found one */ if (sc->maps) XFree ((char *) sc->maps); if (prev) prev->next = sc->next; if (Scr->StdCmapInfo.head == sc) Scr->StdCmapInfo.head = sc->next; if (Scr->StdCmapInfo.tail == sc) Scr->StdCmapInfo.tail = prev; if (Scr->StdCmapInfo.mru == sc) Scr->StdCmapInfo.mru = NULL; } return; } void LocateStandardColormaps() { Atom *atoms; int natoms; int i; atoms = XListProperties (dpy, Scr->Root, &natoms); for (i = 0; i < natoms; i++) { XStandardColormap *maps = NULL; int nmaps; if (XGetRGBColormaps (dpy, Scr->Root, &maps, &nmaps, atoms[i])) { /* if got one, then append to current list */ InsertRGBColormap (atoms[i], maps, nmaps, False); } } if (atoms) XFree ((char *) atoms); return; } void -GetColor(kind, what, name) -int kind; -Pixel *what; -char *name; +GetColor(int kind, Pixel *what, char *name) { XColor color, junkcolor; Status stat = 0; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; #ifndef TOM if (!Scr->FirstTime) return; #endif if (Scr->Monochrome != kind) return; if (!XAllocNamedColor (dpy, cmap, name, &color, &junkcolor)) { /* if we could not allocate the color, let's see if this is a * standard colormap */ XStandardColormap *stdcmap = NULL; @@ -580,80 +528,76 @@ ((Pixel)(((float)color.red / 65535.0) * stdcmap->red_max + 0.5) * stdcmap->red_mult) + ((Pixel)(((float)color.green /65535.0) * stdcmap->green_max + 0.5) * stdcmap->green_mult) + ((Pixel)(((float)color.blue / 65535.0) * stdcmap->blue_max + 0.5) * stdcmap->blue_mult)); } else { fprintf (stderr, "%s: unable to allocate color \"%s\"\n", ProgramName, name); return; } } *what = color.pixel; } void -GetColorValue(kind, what, name) -int kind; -XColor *what; -char *name; +GetColorValue(int kind, XColor *what, char *name) { XColor junkcolor; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; #ifndef TOM if (!Scr->FirstTime) return; #endif if (Scr->Monochrome != kind) return; if (!XLookupColor (dpy, cmap, name, what, &junkcolor)) { fprintf (stderr, "%s: invalid color name \"%s\"\n", ProgramName, name); } else { what->pixel = AllPlanes; } } /* * 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; +GetFont(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); @@ -693,197 +637,172 @@ if ((font->font = XLoadQueryFont(dpy, font->name)) == NULL) { if (Scr->DefaultFont.name) { deffontname = Scr->DefaultFont.name; } if ((font->font = XLoadQueryFont(dpy, deffontname)) == NULL) { fprintf (stderr, "%s: unable to open fonts \"%s\" or \"%s\"\n", ProgramName, font->name, deffontname); exit(1); } } 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; +MyFont_TextWidth(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; +MyFont_DrawImageString(Display *dpy, Drawable d, MyFont *font, GC gc, + int x, int 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; +MyFont_DrawString(Display *dpy, Drawable d, MyFont *font, GC gc, + int x, int 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; +MyFont_ChangeGC(unsigned long fix_fore, unsigned long 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; +I18N_FetchName(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; +I18N_GetIconName(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 +/** + * separate routine to set focus to make things more understandable * and easier to debug */ void -SetFocus (tmp_win, time) - TwmWindow *tmp_win; - Time time; +SetFocus (TwmWindow *tmp_win, Time time) { Window w = (tmp_win ? tmp_win->w : PointerRoot); #ifdef TRACE if (tmp_win) { printf ("Focusing on window \"%s\"\n", tmp_win->full_name); } else { printf ("Unfocusing; Scr->Focus was \"%s\"\n", Scr->Focus ? Scr->Focus->full_name : "(nil)"); } #endif XSetInputFocus (dpy, w, RevertToPointerRoot, time); } #ifdef NOPUTENV -/* +/** * define our own putenv() if the system doesn't have one. * putenv(s): place s (a string of the form "NAME=value") in * the environment; replacing any existing NAME. s is placed in * environment, so if you change s, the environment changes (like * putenv on a sun). Binding removed if you putenv something else * called NAME. */ int -putenv(s) - char *s; +putenv(char *s) { char *v; int varlen, idx; extern char **environ; char **newenv; static int virgin = 1; /* true while "environ" is a virgin */ v = index(s, '='); if(v == 0) return 0; /* punt if it's not of the right form */ varlen = (v + 1) - s; for (idx = 0; environ[idx] != 0; idx++) { if (strncmp(environ[idx], s, varlen) == 0) { if(v[1] != 0) { /* true if there's a value */ environ[idx] = s; return 0; } else { do { environ[idx] = environ[idx+1]; @@ -905,78 +824,76 @@ for(i = idx-1; i >= 0; --i) newenv[i] = environ[i]; virgin = 0; /* you're not a virgin anymore, sweety */ } else { newenv = (char **) realloc((char *) environ, (unsigned) ((idx + 2) * sizeof(char*))); if (newenv == 0) return -1; } environ = newenv; environ[idx] = s; environ[idx+1] = 0; return 0; } #endif /* NOPUTENV */ static Pixmap -CreateXLogoPixmap (widthp, heightp) - unsigned int *widthp, *heightp; +CreateXLogoPixmap (unsigned *widthp, unsigned *heightp) { int h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (h < 0) h = 0; *widthp = *heightp = (unsigned int) h; if (Scr->tbpm.xlogo == None) { GC gc, gcBack; Scr->tbpm.xlogo = XCreatePixmap (dpy, Scr->Root, h, h, 1); gc = XCreateGC (dpy, Scr->tbpm.xlogo, 0L, NULL); XSetForeground (dpy, gc, 0); XFillRectangle (dpy, Scr->tbpm.xlogo, gc, 0, 0, h, h); XSetForeground (dpy, gc, 1); gcBack = XCreateGC (dpy, Scr->tbpm.xlogo, 0L, NULL); XSetForeground (dpy, gcBack, 0); /* * draw the logo large so that it gets as dense as possible; then white * out the edges so that they look crisp */ XmuDrawLogo (dpy, Scr->tbpm.xlogo, gc, gcBack, -1, -1, h + 2, h + 2); XDrawRectangle (dpy, Scr->tbpm.xlogo, gcBack, 0, 0, h - 1, h - 1); /* * done drawing */ XFreeGC (dpy, gc); XFreeGC (dpy, gcBack); } return Scr->tbpm.xlogo; } static Pixmap -CreateResizePixmap (widthp, heightp) - unsigned int *widthp, *heightp; +CreateResizePixmap (unsigned *widthp, unsigned *heightp) { int h = Scr->TBInfo.width - Scr->TBInfo.border * 2; if (h < 1) h = 1; *widthp = *heightp = (unsigned int) h; if (Scr->tbpm.resize == None) { XPoint points[3]; GC gc; int w; int lw; /* * create the pixmap */ Scr->tbpm.resize = XCreatePixmap (dpy, Scr->Root, h, h, 1); gc = XCreateGC (dpy, Scr->tbpm.resize, 0L, NULL); XSetForeground (dpy, gc, 0); XFillRectangle (dpy, Scr->tbpm.resize, gc, 0, 0, h, h); XSetForeground (dpy, gc, 1); lw = h / 16; @@ -997,102 +914,97 @@ XDrawLines (dpy, Scr->tbpm.resize, gc, points, 3, CoordModeOrigin); w = w / 2; points[0].x = w; points[0].y = 0; points[1].x = w; points[1].y = w; points[2].x = 0; points[2].y = w; XDrawLines (dpy, Scr->tbpm.resize, gc, points, 3, CoordModeOrigin); /* * done drawing */ XFreeGC(dpy, gc); } return Scr->tbpm.resize; } static Pixmap -CreateDotPixmap (widthp, heightp) - unsigned int *widthp, *heightp; +CreateDotPixmap (unsigned *widthp, unsigned *heightp) { int h = Scr->TBInfo.width - Scr->TBInfo.border * 2; h = h * 3 / 4; if (h < 1) h = 1; if (!(h & 1)) h--; *widthp = *heightp = (unsigned int) h; if (Scr->tbpm.delete == None) { GC gc; Pixmap pix; pix = Scr->tbpm.delete = XCreatePixmap (dpy, Scr->Root, h, h, 1); gc = XCreateGC (dpy, pix, 0L, NULL); XSetLineAttributes (dpy, gc, h, LineSolid, CapRound, JoinRound); XSetForeground (dpy, gc, 0L); XFillRectangle (dpy, pix, gc, 0, 0, h, h); XSetForeground (dpy, gc, 1L); XDrawLine (dpy, pix, gc, h/2, h/2, h/2, h/2); XFreeGC (dpy, gc); } return Scr->tbpm.delete; } #define questionmark_width 8 #define questionmark_height 8 static char questionmark_bits[] = { 0x38, 0x7c, 0x64, 0x30, 0x18, 0x00, 0x18, 0x18}; static Pixmap -CreateQuestionPixmap (widthp, heightp) - unsigned int *widthp, *heightp; +CreateQuestionPixmap (unsigned *widthp, unsigned *heightp) { *widthp = questionmark_width; *heightp = questionmark_height; if (Scr->tbpm.question == None) { Scr->tbpm.question = XCreateBitmapFromData (dpy, Scr->Root, questionmark_bits, questionmark_width, questionmark_height); } /* * this must succeed or else we are in deep trouble elsewhere */ return Scr->tbpm.question; } static Pixmap -CreateMenuPixmap (widthp, heightp) - unsigned int *widthp, *heightp; +CreateMenuPixmap (unsigned *widthp, unsigned *heightp) { return CreateMenuIcon (Scr->TBInfo.width - Scr->TBInfo.border * 2, widthp,heightp); } Pixmap -CreateMenuIcon (height, widthp, heightp) - int height; - unsigned int *widthp, *heightp; +CreateMenuIcon (int height, unsigned *widthp, unsigned *heightp) { int h, w; int ih, iw; int ix, iy; int mh, mw; int tw, th; int lw, lh; int lx, ly; int lines, dly; int off; int bw; h = height; w = h * 7 / 8; if (h < 1) h = 1; if (w < 1) w = 1; *widthp = w; *heightp = h; @@ -1132,32 +1044,29 @@ lh++; ly = iy + bw + (th - bw - lh) / 2; lines = 3; if ((lh & 1) && lh < 6) { lines--; } dly = lh / (lines - 1); while (lines--) { XFillRectangle (dpy, pix, gc, lx, ly, lw, bw); ly += dly; } XFreeGC (dpy, gc); } return Scr->tbpm.menu; } void -Bell(type,percent,win) - int type; - int percent; - Window win; +Bell(int type, int percent, Window win) { #ifdef XKB XkbStdBell(dpy, win, percent, type); #else XBell(dpy, percent); #endif return; }