summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/add_window.c1937
-rw-r--r--src/add_window.h29
-rw-r--r--src/cursor.c53
-rw-r--r--src/events.c3393
-rw-r--r--src/events.h76
-rw-r--r--src/gc.h5
-rw-r--r--src/iconmgr.c589
-rw-r--r--src/iconmgr.h51
-rw-r--r--src/icons.c650
-rw-r--r--src/icons.h42
-rw-r--r--src/list.c142
-rw-r--r--src/list.h19
-rw-r--r--src/menus.c3766
-rw-r--r--src/menus.h188
-rw-r--r--src/parse.c1629
-rw-r--r--src/parse.h171
-rw-r--r--src/resize.c725
-rw-r--r--src/resize.h30
-rw-r--r--src/screen.h319
-rw-r--r--src/session.c1081
-rw-r--r--src/session.h11
-rw-r--r--src/twm.c969
-rw-r--r--src/twm.h380
-rw-r--r--src/util.c1081
-rw-r--r--src/util.h81
-rw-r--r--src/version.c3
-rw-r--r--src/version.h2
27 files changed, 8633 insertions, 8789 deletions
diff --git a/src/add_window.c b/src/add_window.c
index acd685f..44e1bed 100644
--- a/src/add_window.c
+++ b/src/add_window.c
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/**********************************************************************
*
* Add a new window, put the titlbar and other stuff around
@@ -76,7 +75,8 @@ in this Software without prior written authorization from The Open Group.
#define gray_width 2
#define gray_height 2
static char gray_bits[] = {
- 0x02, 0x01};
+ 0x02, 0x01
+};
int AddingX;
int AddingY;
@@ -86,13 +86,11 @@ 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 */
+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
@@ -103,57 +101,57 @@ char NoName[] = "Untitled"; /* name if no name is specified */
*
*/
void
-GetGravityOffsets (TwmWindow *tmp, int *xp, int *yp)
+GetGravityOffsets(TwmWindow *tmp, int *xp, int *yp)
{
+ /* *INDENT-OFF* */
static struct _gravity_offset {
- int x, y;
+ 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 */
+ { 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 */
};
+ /* *INDENT-ON* */
register int g = ((tmp->hints.flags & PWinGravity)
- ? tmp->hints.win_gravity : NorthWestGravity);
+ ? tmp->hints.win_gravity : NorthWestGravity);
if (g < ForgetGravity || g > StaticGravity) {
- *xp = *yp = 0;
- } else {
- *xp = gravity_offsets[g].x;
- *yp = gravity_offsets[g].y;
+ *xp = *yp = 0;
+ }
+ else {
+ *xp = gravity_offsets[g].x;
+ *yp = gravity_offsets[g].y;
}
}
-
-
-
/**
* add a new window to the twm list.
*
* \return pointer to the TwmWindow structure
*
- * \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
+ * \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(Window w, int iconm, IconMgr *iconp)
{
- TwmWindow *tmp_win; /* new twm window structure */
+ 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 */
+ 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;
@@ -166,16 +164,16 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
char *name;
#ifdef DEBUG
- fprintf(stderr, "AddWindow: w = 0x%lx\n", (unsigned long)w);
+ fprintf(stderr, "AddWindow: w = 0x%lx\n", (unsigned long) w);
#endif
/* allocate space for the twm window */
tmp_win = calloc(1, sizeof(TwmWindow));
- if (tmp_win == NULL)
- {
- fprintf (stderr, "%s: Unable to allocate memory to manage window ID %lx.\n",
- ProgramName, w);
- return NULL;
+ if (tmp_win == NULL) {
+ fprintf(stderr,
+ "%s: Unable to allocate memory to manage window ID %lx.\n",
+ ProgramName, w);
+ return NULL;
}
tmp_win->w = w;
tmp_win->zoomed = ZOOM_NONE;
@@ -188,134 +186,131 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
XGetWindowAttributes(dpy, tmp_win->w, &tmp_win->attr);
if (!I18N_FetchName(dpy, tmp_win->w, &name))
- name = NULL;
+ name = NULL;
tmp_win->class = NoClass;
XGetClassHint(dpy, tmp_win->w, &tmp_win->class);
- FetchWmProtocols (tmp_win);
- FetchWmColormapWindows (tmp_win);
+ FetchWmProtocols(tmp_win);
+ FetchWmColormapWindows(tmp_win);
if (name == NULL)
- tmp_win->name = strdup(NoName);
+ tmp_win->name = strdup(NoName);
else {
- tmp_win->name = strdup(name);
- free(name);
+ tmp_win->name = strdup(name);
+ free(name);
}
- if (GetWindowConfig (tmp_win,
- &saved_x, &saved_y, &saved_width, &saved_height,
- &restore_iconified, &restore_icon_info_present,
- &restore_icon_x, &restore_icon_y,
- &width_ever_changed_by_user, &height_ever_changed_by_user))
- {
- tmp_win->attr.x = saved_x;
- tmp_win->attr.y = saved_y;
+ if (GetWindowConfig(tmp_win,
+ &saved_x, &saved_y, &saved_width, &saved_height,
+ &restore_iconified, &restore_icon_info_present,
+ &restore_icon_x, &restore_icon_y,
+ &width_ever_changed_by_user,
+ &height_ever_changed_by_user)) {
+ tmp_win->attr.x = saved_x;
+ tmp_win->attr.y = saved_y;
- tmp_win->widthEverChangedByUser = width_ever_changed_by_user;
- tmp_win->heightEverChangedByUser = height_ever_changed_by_user;
+ tmp_win->widthEverChangedByUser = width_ever_changed_by_user;
+ tmp_win->heightEverChangedByUser = height_ever_changed_by_user;
- if (width_ever_changed_by_user)
- tmp_win->attr.width = saved_width;
+ if (width_ever_changed_by_user)
+ tmp_win->attr.width = saved_width;
- if (height_ever_changed_by_user)
- tmp_win->attr.height = saved_height;
+ if (height_ever_changed_by_user)
+ tmp_win->attr.height = saved_height;
- restoredFromPrevSession = 1;
+ restoredFromPrevSession = 1;
}
- else
- {
- tmp_win->widthEverChangedByUser = False;
- tmp_win->heightEverChangedByUser = False;
+ else {
+ tmp_win->widthEverChangedByUser = False;
+ tmp_win->heightEverChangedByUser = False;
- restoredFromPrevSession = 0;
+ restoredFromPrevSession = 0;
}
-
/*
* do initial clip; should look at window gravity
*/
if (tmp_win->attr.width > Scr->MaxWindowWidth)
- tmp_win->attr.width = Scr->MaxWindowWidth;
+ tmp_win->attr.width = Scr->MaxWindowWidth;
if (tmp_win->attr.height > Scr->MaxWindowHeight)
- tmp_win->attr.height = Scr->MaxWindowHeight;
+ tmp_win->attr.height = Scr->MaxWindowHeight;
tmp_win->wmhints = XGetWMHints(dpy, tmp_win->w);
- if (tmp_win->wmhints)
- {
- if (restore_iconified)
- {
- tmp_win->wmhints->initial_state = IconicState;
- tmp_win->wmhints->flags |= StateHint;
- }
-
- if (restore_icon_info_present)
- {
- tmp_win->wmhints->icon_x = restore_icon_x;
- tmp_win->wmhints->icon_y = restore_icon_y;
- tmp_win->wmhints->flags |= IconPositionHint;
- }
+ if (tmp_win->wmhints) {
+ if (restore_iconified) {
+ tmp_win->wmhints->initial_state = IconicState;
+ tmp_win->wmhints->flags |= StateHint;
+ }
+
+ if (restore_icon_info_present) {
+ tmp_win->wmhints->icon_x = restore_icon_x;
+ tmp_win->wmhints->icon_y = restore_icon_y;
+ tmp_win->wmhints->flags |= IconPositionHint;
+ }
}
if (tmp_win->wmhints && (tmp_win->wmhints->flags & WindowGroupHint))
- tmp_win->group = tmp_win->wmhints->window_group;
+ tmp_win->group = tmp_win->wmhints->window_group;
else
- tmp_win->group = tmp_win->w/* NULL */;
+ tmp_win->group = tmp_win->w /* NULL */ ;
/*
* The July 27, 1988 draft of the ICCCM ignores the size and position
* fields in the WM_NORMAL_HINTS property.
*/
- tmp_win->transient = (short)Transient(tmp_win->w, &tmp_win->transientfor);
+ tmp_win->transient = (short) Transient(tmp_win->w, &tmp_win->transientfor);
tmp_win->nameChanged = 0;
if (tmp_win->class.res_name == NULL)
- tmp_win->class.res_name = NoName;
+ tmp_win->class.res_name = NoName;
if (tmp_win->class.res_class == NULL)
- tmp_win->class.res_class = NoName;
+ tmp_win->class.res_class = NoName;
tmp_win->full_name = strdup(tmp_win->name);
- namelen = (int)strlen (tmp_win->name);
+ namelen = (int) strlen(tmp_win->name);
tmp_win->highlight = Scr->Highlight &&
- (!(short)(long) LookInList(Scr->NoHighlight, tmp_win->full_name,
- &tmp_win->class));
+ (!(short) (long) LookInList(Scr->NoHighlight, tmp_win->full_name,
+ &tmp_win->class));
tmp_win->stackmode = Scr->StackMode &&
- (!(short)(long) LookInList(Scr->NoStackModeL, tmp_win->full_name,
- &tmp_win->class));
+ (!(short) (long) LookInList(Scr->NoStackModeL, tmp_win->full_name,
+ &tmp_win->class));
tmp_win->titlehighlight = Scr->TitleHighlight &&
- (!(short)(long) LookInList(Scr->NoTitleHighlight, tmp_win->full_name,
- &tmp_win->class));
-
- tmp_win->auto_raise = (short)(long) LookInList(Scr->AutoRaise,
- tmp_win->full_name,
- &tmp_win->class);
- if (tmp_win->auto_raise) Scr->NumAutoRaises++;
+ (!(short) (long) LookInList(Scr->NoTitleHighlight, tmp_win->full_name,
+ &tmp_win->class));
+
+ tmp_win->auto_raise = (short) (long) LookInList(Scr->AutoRaise,
+ tmp_win->full_name,
+ &tmp_win->class);
+ if (tmp_win->auto_raise)
+ Scr->NumAutoRaises++;
tmp_win->iconify_by_unmapping = Scr->IconifyByUnmapping;
- if (Scr->IconifyByUnmapping)
- {
- tmp_win->iconify_by_unmapping = iconm ? FALSE :
- !(short)(long) LookInList(Scr->DontIconify, tmp_win->full_name,
- &tmp_win->class);
+ if (Scr->IconifyByUnmapping) {
+ tmp_win->iconify_by_unmapping = iconm ? FALSE :
+ !(short) (long) LookInList(Scr->DontIconify, tmp_win->full_name,
+ &tmp_win->class);
}
tmp_win->iconify_by_unmapping |=
- (short)(long) LookInList(Scr->IconifyByUn, tmp_win->full_name,
- &tmp_win->class);
+ (short) (long) LookInList(Scr->IconifyByUn, tmp_win->full_name,
+ &tmp_win->class);
if (LookInList(Scr->WindowRingL, tmp_win->full_name, &tmp_win->class)) {
- if (Scr->Ring) {
- tmp_win->ring.next = Scr->Ring->ring.next;
- if (Scr->Ring->ring.next->ring.prev)
- Scr->Ring->ring.next->ring.prev = tmp_win;
- Scr->Ring->ring.next = tmp_win;
- tmp_win->ring.prev = Scr->Ring;
- } else {
- tmp_win->ring.next = tmp_win->ring.prev = Scr->Ring = tmp_win;
- }
- } else
- tmp_win->ring.next = tmp_win->ring.prev = NULL;
+ if (Scr->Ring) {
+ tmp_win->ring.next = Scr->Ring->ring.next;
+ if (Scr->Ring->ring.next->ring.prev)
+ Scr->Ring->ring.next->ring.prev = tmp_win;
+ Scr->Ring->ring.next = tmp_win;
+ tmp_win->ring.prev = Scr->Ring;
+ }
+ else {
+ tmp_win->ring.next = tmp_win->ring.prev = Scr->Ring = tmp_win;
+ }
+ }
+ else
+ tmp_win->ring.next = tmp_win->ring.prev = NULL;
tmp_win->ring.cursor_valid = False;
tmp_win->squeeze_info = NULL;
@@ -324,25 +319,26 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
* since it is coming from the screen list
*/
if (HasShape) {
- if (!LookInList (Scr->DontSqueezeTitleL, tmp_win->full_name,
- &tmp_win->class)) {
- tmp_win->squeeze_info = (SqueezeInfo *)
- LookInList (Scr->SqueezeTitleL, tmp_win->full_name,
- &tmp_win->class);
- if (!tmp_win->squeeze_info) {
- static SqueezeInfo default_squeeze = { J_LEFT, 0, 0 };
- if (Scr->SqueezeTitle)
- tmp_win->squeeze_info = &default_squeeze;
- }
- }
- }
+ if (!LookInList(Scr->DontSqueezeTitleL, tmp_win->full_name,
+ &tmp_win->class)) {
+ tmp_win->squeeze_info = (SqueezeInfo *)
+ LookInList(Scr->SqueezeTitleL, tmp_win->full_name,
+ &tmp_win->class);
+ if (!tmp_win->squeeze_info) {
+ static SqueezeInfo default_squeeze = { J_LEFT, 0, 0 };
+ if (Scr->SqueezeTitle)
+ tmp_win->squeeze_info = &default_squeeze;
+ }
+ }
+ }
tmp_win->old_bw = tmp_win->attr.border_width;
if (Scr->ClientBorderWidth) {
- tmp_win->frame_bw = tmp_win->old_bw;
- } else {
- tmp_win->frame_bw = Scr->BorderWidth;
+ tmp_win->frame_bw = tmp_win->old_bw;
+ }
+ else {
+ tmp_win->frame_bw = Scr->BorderWidth;
}
bw2 = tmp_win->frame_bw * 2;
@@ -356,33 +352,29 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
/* if it is a transient window, don't put a title on it */
if (tmp_win->transient && !Scr->DecorateTransients)
- tmp_win->title_height = 0;
-
- if (LookInList(Scr->StartIconified, tmp_win->full_name, &tmp_win->class))
- {
- if (!tmp_win->wmhints)
- {
- tmp_win->wmhints = malloc(sizeof(XWMHints));
- tmp_win->wmhints->flags = 0;
- }
- tmp_win->wmhints->initial_state = IconicState;
- tmp_win->wmhints->flags |= StateHint;
+ tmp_win->title_height = 0;
+
+ if (LookInList(Scr->StartIconified, tmp_win->full_name, &tmp_win->class)) {
+ if (!tmp_win->wmhints) {
+ tmp_win->wmhints = malloc(sizeof(XWMHints));
+ tmp_win->wmhints->flags = 0;
+ }
+ tmp_win->wmhints->initial_state = IconicState;
+ tmp_win->wmhints->flags |= StateHint;
}
- GetWindowSizeHints (tmp_win);
+ GetWindowSizeHints(tmp_win);
- if (restoredFromPrevSession)
- {
- /*
- * When restoring window positions from the previous session,
- * we always use NorthWest gravity.
- */
+ if (restoredFromPrevSession) {
+ /*
+ * When restoring window positions from the previous session,
+ * we always use NorthWest gravity.
+ */
- gravx = gravy = -1;
+ gravx = gravy = -1;
}
- else
- {
- GetGravityOffsets (tmp_win, &gravx, &gravy);
+ else {
+ GetGravityOffsets(tmp_win, &gravx, &gravy);
}
/*
@@ -397,338 +389,352 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
*/
ask_user = TRUE;
if (tmp_win->transient ||
- (tmp_win->hints.flags & USPosition) ||
+ (tmp_win->hints.flags & USPosition) ||
((tmp_win->hints.flags & PPosition) && Scr->UsePPosition &&
- (Scr->UsePPosition == PPOS_ON ||
- tmp_win->attr.x != 0 || tmp_win->attr.y != 0)))
- ask_user = FALSE;
+ (Scr->UsePPosition == PPOS_ON ||
+ tmp_win->attr.x != 0 || tmp_win->attr.y != 0)))
+ ask_user = FALSE;
/*
* do any prompting for position
*/
if (HandlingEvents && ask_user && !restoredFromPrevSession) {
- if (Scr->RandomPlacement) { /* just stick it somewhere */
- if ((PlaceX + tmp_win->attr.width) > Scr->MyDisplayWidth)
- PlaceX = 50;
- if ((PlaceY + tmp_win->attr.height) > Scr->MyDisplayHeight)
- PlaceY = 50;
-
- tmp_win->attr.x = PlaceX;
- tmp_win->attr.y = PlaceY;
- PlaceX += 30;
- PlaceY += 30;
- } else { /* else prompt */
- if (!(tmp_win->wmhints && tmp_win->wmhints->flags & StateHint &&
- tmp_win->wmhints->initial_state == IconicState))
- {
- Bool firsttime = True;
-
- /* better wait until all the mouse buttons have been
- * released.
- */
- while (TRUE)
- {
- XUngrabServer(dpy);
- XSync(dpy, 0);
- XGrabServer(dpy);
-
- JunkMask = 0;
- if (!XQueryPointer (dpy, Scr->Root, &JunkRoot,
- &JunkChild, &JunkX, &JunkY,
- &AddingX, &AddingY, &JunkMask))
- JunkMask = 0;
-
- JunkMask &= (Button1Mask | Button2Mask | Button3Mask |
- Button4Mask | Button5Mask);
-
- /*
- * watch out for changing screens
- */
- if (firsttime) {
- if (JunkRoot != Scr->Root) {
- register int scrnum;
-
- for (scrnum = 0; scrnum < NumScreens; scrnum++) {
- if (JunkRoot == RootWindow (dpy, scrnum)) break;
- }
-
- if (scrnum != NumScreens) PreviousScreen = scrnum;
- }
- firsttime = False;
- }
-
- /*
- * wait for buttons to come up; yuck
- */
- if (JunkMask != 0) continue;
-
- /*
- * this will cause a warp to the indicated root
- */
- stat = XGrabPointer(dpy, Scr->Root, False,
- ButtonPressMask | ButtonReleaseMask |
- PointerMotionMask | PointerMotionHintMask,
- GrabModeAsync, GrabModeAsync,
- Scr->Root, UpperLeftCursor, CurrentTime);
-
- if (stat == GrabSuccess)
- break;
- }
-
- width = (SIZE_HINDENT + MyFont_TextWidth (&Scr->SizeFont,
- tmp_win->name, namelen));
- height = Scr->SizeFont.height + SIZE_VINDENT * 2;
-
- XResizeWindow (dpy, Scr->SizeWindow, (unsigned)(width + SIZE_HINDENT), (unsigned)height);
- XMapRaised(dpy, Scr->SizeWindow);
- InstallRootColormap();
-
- MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back,
- &Scr->SizeFont);
- MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont,
- Scr->NormalGC,
- SIZE_HINDENT,
- SIZE_VINDENT + Scr->SizeFont.ascent,
- tmp_win->name, namelen);
-
- AddingW = tmp_win->attr.width + bw2;
- AddingH = tmp_win->attr.height + tmp_win->title_height + bw2;
-
- if (Scr->DontMoveOff) {
- /*
- * Make sure the initial outline comes up on the screen.
- */
- if (AddingX < 0)
- AddingX = 0;
- if (AddingX > Scr->MyDisplayWidth - AddingW)
- AddingX = Scr->MyDisplayWidth - AddingW;
-
- if (AddingY < 0)
- AddingY = 0;
- if (AddingY > Scr->MyDisplayHeight - AddingH)
- AddingY = Scr->MyDisplayHeight - AddingH;
- }
-
- MoveOutline(Scr->Root, AddingX, AddingY, AddingW, AddingH,
- tmp_win->frame_bw, tmp_win->title_height);
-
- while (TRUE)
- {
- XMaskEvent(dpy, ButtonPressMask | PointerMotionMask, &event);
-
- if (Event.type == MotionNotify) {
- /* discard any extra motion events before a release */
- while(XCheckMaskEvent(dpy,
- ButtonMotionMask | ButtonPressMask, &Event))
- if (Event.type == ButtonPress)
- break;
- }
-
- if (event.type == ButtonPress) {
- AddingX = event.xbutton.x_root;
- AddingY = event.xbutton.y_root;
-
- /* DontMoveOff prohibits user form off-screen placement */
- if (Scr->DontMoveOff)
- {
- int AddingR, AddingB;
-
- AddingR = AddingX + AddingW;
- AddingB = AddingY + AddingH;
-
- if (AddingX < 0)
- AddingX = 0;
- if (AddingR > Scr->MyDisplayWidth)
- AddingX = Scr->MyDisplayWidth - AddingW;
-
- if (AddingY < 0)
- AddingY = 0;
- if (AddingB > Scr->MyDisplayHeight)
- AddingY = Scr->MyDisplayHeight - AddingH;
-
- }
- break;
- }
-
- if (event.type != MotionNotify) {
- continue;
- }
-
- XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
- &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
-
- if (Scr->DontMoveOff)
- {
- int AddingR, AddingB;
-
- AddingR = AddingX + AddingW;
- AddingB = AddingY + AddingH;
-
- if (AddingX < 0)
- AddingX = 0;
- if (AddingR > Scr->MyDisplayWidth)
- AddingX = Scr->MyDisplayWidth - AddingW;
-
- if (AddingY < 0)
- AddingY = 0;
- if (AddingB > Scr->MyDisplayHeight)
- AddingY = Scr->MyDisplayHeight - AddingH;
- }
-
- MoveOutline(Scr->Root, AddingX, AddingY, AddingW, AddingH,
- tmp_win->frame_bw, tmp_win->title_height);
-
- }
-
- if (event.xbutton.button == Button2) {
- int lastx, lasty;
-
- Scr->SizeStringOffset = width +
- MyFont_TextWidth(&Scr->SizeFont, ": ", 2);
- XResizeWindow (dpy, Scr->SizeWindow, (unsigned)(Scr->SizeStringOffset +
- Scr->SizeStringWidth), (unsigned)height);
- MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont,
- Scr->NormalGC, width,
- SIZE_VINDENT + Scr->SizeFont.ascent,
- ": ", 2);
- if (0/*Scr->AutoRelativeResize*/) {
- int dx = (tmp_win->attr.width / 4);
- int dy = (tmp_win->attr.height / 4);
-
-#define HALF_AVE_CURSOR_SIZE 8 /* so that it is visible */
- if (dx < HALF_AVE_CURSOR_SIZE) dx = HALF_AVE_CURSOR_SIZE;
- if (dy < HALF_AVE_CURSOR_SIZE) dy = HALF_AVE_CURSOR_SIZE;
+ if (Scr->RandomPlacement) { /* just stick it somewhere */
+ if ((PlaceX + tmp_win->attr.width) > Scr->MyDisplayWidth)
+ PlaceX = 50;
+ if ((PlaceY + tmp_win->attr.height) > Scr->MyDisplayHeight)
+ PlaceY = 50;
+
+ tmp_win->attr.x = PlaceX;
+ tmp_win->attr.y = PlaceY;
+ PlaceX += 30;
+ PlaceY += 30;
+ }
+ else { /* else prompt */
+ if (!(tmp_win->wmhints && tmp_win->wmhints->flags & StateHint &&
+ tmp_win->wmhints->initial_state == IconicState)) {
+ Bool firsttime = True;
+
+ /* better wait until all the mouse buttons have been
+ * released.
+ */
+ while (TRUE) {
+ XUngrabServer(dpy);
+ XSync(dpy, 0);
+ XGrabServer(dpy);
+
+ JunkMask = 0;
+ if (!XQueryPointer(dpy, Scr->Root, &JunkRoot,
+ &JunkChild, &JunkX, &JunkY,
+ &AddingX, &AddingY, &JunkMask))
+ JunkMask = 0;
+
+ JunkMask &= (Button1Mask | Button2Mask | Button3Mask |
+ Button4Mask | Button5Mask);
+
+ /*
+ * watch out for changing screens
+ */
+ if (firsttime) {
+ if (JunkRoot != Scr->Root) {
+ register int scrnum;
+
+ for (scrnum = 0; scrnum < NumScreens; scrnum++) {
+ if (JunkRoot == RootWindow(dpy, scrnum))
+ break;
+ }
+
+ if (scrnum != NumScreens)
+ PreviousScreen = scrnum;
+ }
+ firsttime = False;
+ }
+
+ /*
+ * wait for buttons to come up; yuck
+ */
+ if (JunkMask != 0)
+ continue;
+
+ /*
+ * this will cause a warp to the indicated root
+ */
+ stat = XGrabPointer(dpy, Scr->Root, False,
+ ButtonPressMask | ButtonReleaseMask |
+ PointerMotionMask |
+ PointerMotionHintMask, GrabModeAsync,
+ GrabModeAsync, Scr->Root,
+ UpperLeftCursor, CurrentTime);
+
+ if (stat == GrabSuccess)
+ break;
+ }
+
+ width = (SIZE_HINDENT + MyFont_TextWidth(&Scr->SizeFont,
+ tmp_win->name,
+ namelen));
+ height = Scr->SizeFont.height + SIZE_VINDENT * 2;
+
+ XResizeWindow(dpy, Scr->SizeWindow,
+ (unsigned) (width + SIZE_HINDENT),
+ (unsigned) height);
+ XMapRaised(dpy, Scr->SizeWindow);
+ InstallRootColormap();
+
+ MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back,
+ &Scr->SizeFont);
+ MyFont_DrawImageString(dpy, Scr->SizeWindow, &Scr->SizeFont,
+ Scr->NormalGC,
+ SIZE_HINDENT,
+ SIZE_VINDENT + Scr->SizeFont.ascent,
+ tmp_win->name, namelen);
+
+ AddingW = tmp_win->attr.width + bw2;
+ AddingH = tmp_win->attr.height + tmp_win->title_height + bw2;
+
+ if (Scr->DontMoveOff) {
+ /*
+ * Make sure the initial outline comes up on the screen.
+ */
+ if (AddingX < 0)
+ AddingX = 0;
+ if (AddingX > Scr->MyDisplayWidth - AddingW)
+ AddingX = Scr->MyDisplayWidth - AddingW;
+
+ if (AddingY < 0)
+ AddingY = 0;
+ if (AddingY > Scr->MyDisplayHeight - AddingH)
+ AddingY = Scr->MyDisplayHeight - AddingH;
+ }
+
+ MoveOutline(Scr->Root, AddingX, AddingY, AddingW, AddingH,
+ tmp_win->frame_bw, tmp_win->title_height);
+
+ while (TRUE) {
+ XMaskEvent(dpy, ButtonPressMask | PointerMotionMask,
+ &event);
+
+ if (Event.type == MotionNotify) {
+ /* discard any extra motion events before a release */
+ while (XCheckMaskEvent(dpy,
+ ButtonMotionMask |
+ ButtonPressMask, &Event))
+ if (Event.type == ButtonPress)
+ break;
+ }
+
+ if (event.type == ButtonPress) {
+ AddingX = event.xbutton.x_root;
+ AddingY = event.xbutton.y_root;
+
+ /* DontMoveOff prohibits user form off-screen placement */
+ if (Scr->DontMoveOff) {
+ int AddingR, AddingB;
+
+ AddingR = AddingX + AddingW;
+ AddingB = AddingY + AddingH;
+
+ if (AddingX < 0)
+ AddingX = 0;
+ if (AddingR > Scr->MyDisplayWidth)
+ AddingX = Scr->MyDisplayWidth - AddingW;
+
+ if (AddingY < 0)
+ AddingY = 0;
+ if (AddingB > Scr->MyDisplayHeight)
+ AddingY = Scr->MyDisplayHeight - AddingH;
+
+ }
+ break;
+ }
+
+ if (event.type != MotionNotify) {
+ continue;
+ }
+
+ XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
+ &JunkX, &JunkY, &AddingX, &AddingY,
+ &JunkMask);
+
+ if (Scr->DontMoveOff) {
+ int AddingR, AddingB;
+
+ AddingR = AddingX + AddingW;
+ AddingB = AddingY + AddingH;
+
+ if (AddingX < 0)
+ AddingX = 0;
+ if (AddingR > Scr->MyDisplayWidth)
+ AddingX = Scr->MyDisplayWidth - AddingW;
+
+ if (AddingY < 0)
+ AddingY = 0;
+ if (AddingB > Scr->MyDisplayHeight)
+ AddingY = Scr->MyDisplayHeight - AddingH;
+ }
+
+ MoveOutline(Scr->Root, AddingX, AddingY, AddingW, AddingH,
+ tmp_win->frame_bw, tmp_win->title_height);
+
+ }
+
+ if (event.xbutton.button == Button2) {
+ int lastx, lasty;
+
+ Scr->SizeStringOffset = width +
+ MyFont_TextWidth(&Scr->SizeFont, ": ", 2);
+ XResizeWindow(dpy, Scr->SizeWindow,
+ (unsigned) (Scr->SizeStringOffset +
+ Scr->SizeStringWidth),
+ (unsigned) height);
+ MyFont_DrawImageString(dpy, Scr->SizeWindow, &Scr->SizeFont,
+ Scr->NormalGC, width,
+ SIZE_VINDENT + Scr->SizeFont.ascent,
+ ": ", 2);
+ if (0 /*Scr->AutoRelativeResize */ ) {
+ int dx = (tmp_win->attr.width / 4);
+ int dy = (tmp_win->attr.height / 4);
+
+#define HALF_AVE_CURSOR_SIZE 8 /* so that it is visible */
+ if (dx < HALF_AVE_CURSOR_SIZE)
+ dx = HALF_AVE_CURSOR_SIZE;
+ if (dy < HALF_AVE_CURSOR_SIZE)
+ dy = HALF_AVE_CURSOR_SIZE;
#undef HALF_AVE_CURSOR_SIZE
- dx += (tmp_win->frame_bw + 1);
- dy += (bw2 + tmp_win->title_height + 1);
- if (AddingX + dx >= Scr->MyDisplayWidth)
- dx = Scr->MyDisplayWidth - AddingX - 1;
- if (AddingY + dy >= Scr->MyDisplayHeight)
- dy = Scr->MyDisplayHeight - AddingY - 1;
- if (dx > 0 && dy > 0)
- XWarpPointer (dpy, None, None, 0, 0, 0, 0, dx, dy);
- } else {
- XWarpPointer (dpy, None, Scr->Root, 0, 0, 0, 0,
- AddingX + AddingW/2, AddingY + AddingH/2);
- }
- AddStartResize(tmp_win, AddingX, AddingY, AddingW, AddingH);
-
- lastx = -10000;
- lasty = -10000;
- while (TRUE)
- {
- XMaskEvent(dpy,
- ButtonReleaseMask | ButtonMotionMask, &event);
-
- if (Event.type == MotionNotify) {
- /* discard any extra motion events before a release */
- while(XCheckMaskEvent(dpy,
- ButtonMotionMask | ButtonReleaseMask, &Event))
- if (Event.type == ButtonRelease)
- break;
- }
-
- if (event.type == ButtonRelease)
- {
- AddEndResize(tmp_win);
- break;
- }
-
- if (event.type != MotionNotify) {
- continue;
- }
-
- /*
- * XXX - if we are going to do a loop, we ought to consider
- * using multiple GXxor lines so that we don't need to
- * grab the server.
- */
- XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
- &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
-
- if (lastx != AddingX || lasty != AddingY)
- {
- DoResize(AddingX, AddingY, tmp_win);
-
- lastx = AddingX;
- lasty = AddingY;
- }
-
- }
- }
- else if (event.xbutton.button == Button3)
- {
- int maxw = Scr->MyDisplayWidth - AddingX;
- int maxh = Scr->MyDisplayHeight - AddingY;
-
- /*
- * Make window go to bottom of screen, and clip to right edge.
- * This is useful when popping up large windows and fixed
- * column text windows.
- */
- if (AddingW > maxw) AddingW = maxw;
- AddingH = maxh;
-
- AddingW -= bw2;
- AddingH -= bw2;
- ConstrainSize (tmp_win, &AddingW, &AddingH); /* w/o borders */
- AddingW += bw2;
- AddingH += bw2;
- }
- else
- {
- XMaskEvent(dpy, ButtonReleaseMask, &event);
- }
-
- MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
- XUnmapWindow(dpy, Scr->SizeWindow);
- UninstallRootColormap();
- XUngrabPointer(dpy, CurrentTime);
-
- tmp_win->attr.x = AddingX;
- tmp_win->attr.y = AddingY + tmp_win->title_height;
- tmp_win->attr.width = AddingW - bw2;
- tmp_win->attr.height = AddingH - tmp_win->title_height - bw2;
-
- XUngrabServer(dpy);
- }
- }
- } else { /* put it where asked, mod title bar */
- /* if the gravity is towards the top, move it by the title height */
- if (gravy < 0) tmp_win->attr.y -= gravy * tmp_win->title_height;
+ dx += (tmp_win->frame_bw + 1);
+ dy += (bw2 + tmp_win->title_height + 1);
+ if (AddingX + dx >= Scr->MyDisplayWidth)
+ dx = Scr->MyDisplayWidth - AddingX - 1;
+ if (AddingY + dy >= Scr->MyDisplayHeight)
+ dy = Scr->MyDisplayHeight - AddingY - 1;
+ if (dx > 0 && dy > 0)
+ XWarpPointer(dpy, None, None, 0, 0, 0, 0, dx, dy);
+ }
+ else {
+ XWarpPointer(dpy, None, Scr->Root, 0, 0, 0, 0,
+ AddingX + AddingW / 2,
+ AddingY + AddingH / 2);
+ }
+ AddStartResize(tmp_win, AddingX, AddingY, AddingW, AddingH);
+
+ lastx = -10000;
+ lasty = -10000;
+ while (TRUE) {
+ XMaskEvent(dpy,
+ ButtonReleaseMask | ButtonMotionMask,
+ &event);
+
+ if (Event.type == MotionNotify) {
+ /* discard any extra motion events before a release */
+ while (XCheckMaskEvent(dpy,
+ ButtonMotionMask |
+ ButtonReleaseMask, &Event))
+ if (Event.type == ButtonRelease)
+ break;
+ }
+
+ if (event.type == ButtonRelease) {
+ AddEndResize(tmp_win);
+ break;
+ }
+
+ if (event.type != MotionNotify) {
+ continue;
+ }
+
+ /*
+ * XXX - if we are going to do a loop, we ought to consider
+ * using multiple GXxor lines so that we don't need to
+ * grab the server.
+ */
+ XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
+ &JunkX, &JunkY, &AddingX, &AddingY,
+ &JunkMask);
+
+ if (lastx != AddingX || lasty != AddingY) {
+ DoResize(AddingX, AddingY, tmp_win);
+
+ lastx = AddingX;
+ lasty = AddingY;
+ }
+
+ }
+ }
+ else if (event.xbutton.button == Button3) {
+ int maxw = Scr->MyDisplayWidth - AddingX;
+ int maxh = Scr->MyDisplayHeight - AddingY;
+
+ /*
+ * Make window go to bottom of screen, and clip to right edge.
+ * This is useful when popping up large windows and fixed
+ * column text windows.
+ */
+ if (AddingW > maxw)
+ AddingW = maxw;
+ AddingH = maxh;
+
+ AddingW -= bw2;
+ AddingH -= bw2;
+ ConstrainSize(tmp_win, &AddingW, &AddingH); /* w/o borders */
+ AddingW += bw2;
+ AddingH += bw2;
+ }
+ else {
+ XMaskEvent(dpy, ButtonReleaseMask, &event);
+ }
+
+ MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
+ XUnmapWindow(dpy, Scr->SizeWindow);
+ UninstallRootColormap();
+ XUngrabPointer(dpy, CurrentTime);
+
+ tmp_win->attr.x = AddingX;
+ tmp_win->attr.y = AddingY + tmp_win->title_height;
+ tmp_win->attr.width = AddingW - bw2;
+ tmp_win->attr.height = AddingH - tmp_win->title_height - bw2;
+
+ XUngrabServer(dpy);
+ }
+ }
+ }
+ else { /* put it where asked, mod title bar */
+ /* if the gravity is towards the top, move it by the title height */
+ if (gravy < 0)
+ tmp_win->attr.y -= gravy * tmp_win->title_height;
}
-
#ifdef DEBUG
- fprintf(stderr, " position window %d, %d %dx%d\n",
- tmp_win->attr.x,
- tmp_win->attr.y,
- tmp_win->attr.width,
- tmp_win->attr.height);
+ fprintf(stderr, " position window %d, %d %dx%d\n",
+ tmp_win->attr.x,
+ tmp_win->attr.y, tmp_win->attr.width, tmp_win->attr.height);
#endif
- if (!Scr->ClientBorderWidth) { /* need to adjust for twm borders */
- int delta = tmp_win->attr.border_width - tmp_win->frame_bw;
- tmp_win->attr.x += gravx * delta;
- tmp_win->attr.y += gravy * delta;
+ if (!Scr->ClientBorderWidth) { /* need to adjust for twm borders */
+ int delta = tmp_win->attr.border_width - tmp_win->frame_bw;
+
+ tmp_win->attr.x += gravx * delta;
+ tmp_win->attr.y += gravy * delta;
}
tmp_win->title_width = tmp_win->attr.width;
- if (tmp_win->old_bw) XSetWindowBorderWidth (dpy, tmp_win->w, 0);
+ if (tmp_win->old_bw)
+ XSetWindowBorderWidth(dpy, tmp_win->w, 0);
tmp_win->name_width = MyFont_TextWidth(&Scr->TitleBarFont, tmp_win->name,
- namelen);
+ namelen);
if (!I18N_GetIconName(dpy, tmp_win->w, &name)) {
- tmp_win->icon_name = strdup(tmp_win->name);
- } else {
- if (name == NULL) {
- tmp_win->icon_name = strdup(tmp_win->name);
- } else {
- tmp_win->icon_name = strdup(name);
- free(name);
- }
+ tmp_win->icon_name = strdup(tmp_win->name);
+ }
+ else {
+ if (name == NULL) {
+ tmp_win->icon_name = strdup(tmp_win->name);
+ }
+ else {
+ tmp_win->icon_name = strdup(name);
+ free(name);
+ }
}
tmp_win->iconified = FALSE;
@@ -745,17 +751,16 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
* gotten one for anything up to here, however.
*/
if (XGetGeometry(dpy, tmp_win->w, &JunkRoot, &JunkX, &JunkY,
- &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0)
- {
- free(tmp_win);
- XUngrabServer(dpy);
- return(NULL);
+ &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth) == 0) {
+ free(tmp_win);
+ XUngrabServer(dpy);
+ return (NULL);
}
/* add the window into the twm list */
tmp_win->next = Scr->TwmRoot.next;
if (Scr->TwmRoot.next != NULL)
- Scr->TwmRoot.next->prev = tmp_win;
+ Scr->TwmRoot.next->prev = tmp_win;
tmp_win->prev = &Scr->TwmRoot;
Scr->TwmRoot.next = tmp_win;
@@ -771,28 +776,27 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
tmp_win->iconc.back = Scr->IconC.back;
GetColorFromList(Scr->BorderColorL, tmp_win->full_name, &tmp_win->class,
- &tmp_win->border);
+ &tmp_win->border);
GetColorFromList(Scr->IconBorderColorL, tmp_win->full_name, &tmp_win->class,
- &tmp_win->icon_border);
+ &tmp_win->icon_border);
GetColorFromList(Scr->BorderTileForegroundL, tmp_win->full_name,
- &tmp_win->class, &tmp_win->border_tile.fore);
+ &tmp_win->class, &tmp_win->border_tile.fore);
GetColorFromList(Scr->BorderTileBackgroundL, tmp_win->full_name,
- &tmp_win->class, &tmp_win->border_tile.back);
+ &tmp_win->class, &tmp_win->border_tile.back);
GetColorFromList(Scr->TitleForegroundL, tmp_win->full_name, &tmp_win->class,
- &tmp_win->title.fore);
+ &tmp_win->title.fore);
GetColorFromList(Scr->TitleBackgroundL, tmp_win->full_name, &tmp_win->class,
- &tmp_win->title.back);
+ &tmp_win->title.back);
GetColorFromList(Scr->IconForegroundL, tmp_win->full_name, &tmp_win->class,
- &tmp_win->iconc.fore);
+ &tmp_win->iconc.fore);
GetColorFromList(Scr->IconBackgroundL, tmp_win->full_name, &tmp_win->class,
- &tmp_win->iconc.back);
-
+ &tmp_win->iconc.back);
/* create windows */
tmp_win->frame_x = tmp_win->attr.x + tmp_win->old_bw - tmp_win->frame_bw;
tmp_win->frame_y = tmp_win->attr.y - tmp_win->title_height +
- tmp_win->old_bw - tmp_win->frame_bw;
+ tmp_win->old_bw - tmp_win->frame_bw;
tmp_win->frame_width = tmp_win->attr.width;
tmp_win->frame_height = tmp_win->attr.height + tmp_win->title_height;
@@ -801,94 +805,91 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
attributes.border_pixel = tmp_win->border;
attributes.cursor = Scr->FrameCursor;
attributes.event_mask = (SubstructureRedirectMask |
- ButtonPressMask | ButtonReleaseMask |
- EnterWindowMask | LeaveWindowMask);
+ ButtonPressMask | ButtonReleaseMask |
+ EnterWindowMask | LeaveWindowMask);
if (tmp_win->attr.save_under) {
- attributes.save_under = True;
- valuemask |= CWSaveUnder;
+ attributes.save_under = True;
+ valuemask |= CWSaveUnder;
}
- tmp_win->frame = XCreateWindow (dpy, Scr->Root, tmp_win->frame_x,
- tmp_win->frame_y,
- (unsigned int) tmp_win->frame_width,
- (unsigned int) tmp_win->frame_height,
- (unsigned int) tmp_win->frame_bw,
- Scr->d_depth,
- (unsigned int) CopyFromParent,
- Scr->d_visual, valuemask, &attributes);
-
- if (tmp_win->title_height)
- {
- valuemask = (CWEventMask | CWBorderPixel | CWBackPixel);
- attributes.event_mask = (KeyPressMask | ButtonPressMask |
- ButtonReleaseMask | ExposureMask);
- attributes.border_pixel = tmp_win->border;
- attributes.background_pixel = tmp_win->title.back;
- tmp_win->title_w = XCreateWindow (dpy, tmp_win->frame,
- -tmp_win->frame_bw,
- -tmp_win->frame_bw,
- (unsigned int) tmp_win->attr.width,
- (unsigned int) Scr->TitleHeight,
- (unsigned int) tmp_win->frame_bw,
- Scr->d_depth,
- (unsigned int) CopyFromParent,
- Scr->d_visual, valuemask,
- &attributes);
+ tmp_win->frame = XCreateWindow(dpy, Scr->Root, tmp_win->frame_x,
+ tmp_win->frame_y,
+ (unsigned int) tmp_win->frame_width,
+ (unsigned int) tmp_win->frame_height,
+ (unsigned int) tmp_win->frame_bw,
+ Scr->d_depth,
+ (unsigned int) CopyFromParent,
+ Scr->d_visual, valuemask, &attributes);
+
+ if (tmp_win->title_height) {
+ valuemask = (CWEventMask | CWBorderPixel | CWBackPixel);
+ attributes.event_mask = (KeyPressMask | ButtonPressMask |
+ ButtonReleaseMask | ExposureMask);
+ attributes.border_pixel = tmp_win->border;
+ attributes.background_pixel = tmp_win->title.back;
+ tmp_win->title_w = XCreateWindow(dpy, tmp_win->frame,
+ -tmp_win->frame_bw,
+ -tmp_win->frame_bw,
+ (unsigned int) tmp_win->attr.width,
+ (unsigned int) Scr->TitleHeight,
+ (unsigned int) tmp_win->frame_bw,
+ Scr->d_depth,
+ (unsigned int) CopyFromParent,
+ Scr->d_visual, valuemask, &attributes);
}
else {
- tmp_win->title_w = 0;
- tmp_win->squeeze_info = NULL;
+ tmp_win->title_w = 0;
+ tmp_win->squeeze_info = NULL;
}
- if (tmp_win->highlight)
- {
- tmp_win->gray = XCreatePixmapFromBitmapData(dpy, Scr->Root,
- gray_bits, gray_width, gray_height,
- tmp_win->border_tile.fore, tmp_win->border_tile.back,
- (unsigned)Scr->d_depth);
+ if (tmp_win->highlight) {
+ tmp_win->gray = XCreatePixmapFromBitmapData(dpy, Scr->Root,
+ gray_bits, gray_width,
+ gray_height,
+ tmp_win->border_tile.fore,
+ tmp_win->border_tile.back,
+ (unsigned) Scr->d_depth);
- SetBorder (tmp_win, False);
+ SetBorder(tmp_win, False);
}
else
- tmp_win->gray = None;
-
+ tmp_win->gray = None;
if (tmp_win->title_w) {
- CreateWindowTitlebarButtons (tmp_win);
- ComputeTitleLocation (tmp_win);
- XMoveWindow (dpy, tmp_win->title_w,
- tmp_win->title_x, tmp_win->title_y);
- XDefineCursor(dpy, tmp_win->title_w, Scr->TitleCursor);
+ CreateWindowTitlebarButtons(tmp_win);
+ ComputeTitleLocation(tmp_win);
+ XMoveWindow(dpy, tmp_win->title_w, tmp_win->title_x, tmp_win->title_y);
+ XDefineCursor(dpy, tmp_win->title_w, Scr->TitleCursor);
}
valuemask = (CWEventMask | CWDontPropagate);
attributes.event_mask = (StructureNotifyMask | PropertyChangeMask |
- ColormapChangeMask | VisibilityChangeMask |
- EnterWindowMask | LeaveWindowMask);
+ ColormapChangeMask | VisibilityChangeMask |
+ EnterWindowMask | LeaveWindowMask);
attributes.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask;
- XChangeWindowAttributes (dpy, tmp_win->w, valuemask, &attributes);
+ XChangeWindowAttributes(dpy, tmp_win->w, valuemask, &attributes);
if (HasShape)
- XShapeSelectInput (dpy, tmp_win->w, ShapeNotifyMask);
+ XShapeSelectInput(dpy, tmp_win->w, ShapeNotifyMask);
if (tmp_win->title_w) {
- XMapWindow (dpy, tmp_win->title_w);
+ XMapWindow(dpy, tmp_win->title_w);
}
if (HasShape) {
- int xws, yws, xbs, ybs;
- unsigned wws, hws, wbs, hbs;
- int boundingShaped, clipShaped;
-
- XShapeSelectInput (dpy, tmp_win->w, ShapeNotifyMask);
- XShapeQueryExtents (dpy, tmp_win->w,
- &boundingShaped, &xws, &yws, &wws, &hws,
- &clipShaped, &xbs, &ybs, &wbs, &hbs);
- tmp_win->wShaped = (short)boundingShaped;
+ int xws, yws, xbs, ybs;
+ unsigned wws, hws, wbs, hbs;
+ int boundingShaped, clipShaped;
+
+ XShapeSelectInput(dpy, tmp_win->w, ShapeNotifyMask);
+ XShapeQueryExtents(dpy, tmp_win->w,
+ &boundingShaped, &xws, &yws, &wws, &hws,
+ &clipShaped, &xbs, &ybs, &wbs, &hbs);
+ tmp_win->wShaped = (short) boundingShaped;
}
if (!tmp_win->iconmgr)
- XAddToSaveSet(dpy, tmp_win->w);
+ XAddToSaveSet(dpy, tmp_win->w);
XReparentWindow(dpy, tmp_win->w, tmp_win->frame, 0, tmp_win->title_height);
/*
@@ -899,18 +900,17 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
*/
tmp_win->mapped = FALSE;
- SetupFrame (tmp_win, tmp_win->frame_x, tmp_win->frame_y,
- tmp_win->frame_width, tmp_win->frame_height, -1, True);
+ SetupFrame(tmp_win, tmp_win->frame_x, tmp_win->frame_y,
+ tmp_win->frame_width, tmp_win->frame_height, -1, True);
/* wait until the window is iconified and the icon window is mapped
* before creating the icon window
*/
tmp_win->icon_w = (Window) 0;
- if (!tmp_win->iconmgr)
- {
- GrabButtons(tmp_win);
- GrabKeys(tmp_win);
+ if (!tmp_win->iconmgr) {
+ GrabButtons(tmp_win);
+ GrabKeys(tmp_win);
}
(void) AddIconManager(tmp_win);
@@ -919,24 +919,23 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
XSaveContext(dpy, tmp_win->w, ScreenContext, (XPointer) Scr);
XSaveContext(dpy, tmp_win->frame, TwmContext, (XPointer) tmp_win);
XSaveContext(dpy, tmp_win->frame, ScreenContext, (XPointer) Scr);
- if (tmp_win->title_height)
- {
- int i;
- int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
-
- XSaveContext(dpy, tmp_win->title_w, TwmContext, (XPointer) tmp_win);
- XSaveContext(dpy, tmp_win->title_w, ScreenContext, (XPointer) Scr);
- for (i = 0; i < nb; i++) {
- XSaveContext(dpy, tmp_win->titlebuttons[i].window, TwmContext,
- (XPointer) tmp_win);
- XSaveContext(dpy, tmp_win->titlebuttons[i].window, ScreenContext,
- (XPointer) Scr);
- }
- if (tmp_win->hilite_w)
- {
- XSaveContext(dpy, tmp_win->hilite_w, TwmContext, (XPointer)tmp_win);
- XSaveContext(dpy, tmp_win->hilite_w, ScreenContext, (XPointer)Scr);
- }
+ if (tmp_win->title_height) {
+ int i;
+ int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
+
+ XSaveContext(dpy, tmp_win->title_w, TwmContext, (XPointer) tmp_win);
+ XSaveContext(dpy, tmp_win->title_w, ScreenContext, (XPointer) Scr);
+ for (i = 0; i < nb; i++) {
+ XSaveContext(dpy, tmp_win->titlebuttons[i].window, TwmContext,
+ (XPointer) tmp_win);
+ XSaveContext(dpy, tmp_win->titlebuttons[i].window, ScreenContext,
+ (XPointer) Scr);
+ }
+ if (tmp_win->hilite_w) {
+ XSaveContext(dpy, tmp_win->hilite_w, TwmContext,
+ (XPointer) tmp_win);
+ XSaveContext(dpy, tmp_win->hilite_w, ScreenContext, (XPointer) Scr);
+ }
}
XUngrabServer(dpy);
@@ -945,18 +944,17 @@ AddWindow(Window w, int iconm, IconMgr *iconp)
* the pointer
*/
if (RootFunction)
- ReGrab();
+ ReGrab();
return (tmp_win);
}
-
/**
* checks to see if we should really put a twm frame on the window
*
* \return TRUE - go ahead and place the window
* \return FALSE - don't frame the window
- * \param w the window to check
+ * \param w the window to check
*/
int
MappedNotOverride(Window w)
@@ -967,23 +965,24 @@ MappedNotOverride(Window w)
return ((wa.map_state != IsUnmapped) && (wa.override_redirect != True));
}
-
/**
* attach default bindings so that naive users don't get messed up if they
* provide a minimal twmrc.
*/
-static void do_add_binding (int button, int context, int 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 */
+ if (mb->func)
+ return; /* already defined */
mb->func = func;
mb->item = NULL;
}
void
-AddDefaultBindings (void)
+AddDefaultBindings(void)
{
/*
* The bindings are stored in Scr->Mouse, indexed by
@@ -992,20 +991,17 @@ AddDefaultBindings (void)
#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(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);
+ 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
}
-
-
-
/**
* grab needed buttons for the window
*
@@ -1016,21 +1012,18 @@ 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,
+ 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, (unsigned)i, (unsigned)j, tmp_win->frame,
- True, ButtonPressMask | ButtonReleaseMask,
- GrabModeAsync, GrabModeAsync, None,
- Scr->FrameCursor);
- }
- }
+ */
+ XGrabButton(dpy, (unsigned) i, (unsigned) j, tmp_win->frame,
+ True, ButtonPressMask | ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync, None,
+ Scr->FrameCursor);
+ }
+ }
}
}
@@ -1045,59 +1038,56 @@ 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, (unsigned)tmp->mods, tmp_win->w, True,
- GrabModeAsync, GrabModeAsync);
- break;
-
- case C_ICON:
- if (tmp_win->icon_w)
- XGrabKey(dpy, tmp->keycode, (unsigned)tmp->mods, tmp_win->icon_w, True,
- GrabModeAsync, GrabModeAsync);
-
- case C_TITLE:
- if (tmp_win->title_w)
- XGrabKey(dpy, tmp->keycode, (unsigned)tmp->mods, tmp_win->title_w, True,
- GrabModeAsync, GrabModeAsync);
- break;
-
- case C_NAME:
- XGrabKey(dpy, tmp->keycode, (unsigned)tmp->mods, tmp_win->w, True,
- GrabModeAsync, GrabModeAsync);
- if (tmp_win->icon_w)
- XGrabKey(dpy, tmp->keycode, (unsigned)tmp->mods, tmp_win->icon_w, True,
- GrabModeAsync, GrabModeAsync);
- if (tmp_win->title_w)
- XGrabKey(dpy, tmp->keycode, (unsigned)tmp->mods, tmp_win->title_w, True,
- GrabModeAsync, GrabModeAsync);
- break;
- /*
- 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) {
+ switch (tmp->cont) {
+ case C_WINDOW:
+ XGrabKey(dpy, tmp->keycode, (unsigned) tmp->mods, tmp_win->w, True,
+ GrabModeAsync, GrabModeAsync);
+ break;
+
+ case C_ICON:
+ if (tmp_win->icon_w)
+ XGrabKey(dpy, tmp->keycode, (unsigned) tmp->mods,
+ tmp_win->icon_w, True, GrabModeAsync, GrabModeAsync);
+
+ case C_TITLE:
+ if (tmp_win->title_w)
+ XGrabKey(dpy, tmp->keycode, (unsigned) tmp->mods,
+ tmp_win->title_w, True, GrabModeAsync, GrabModeAsync);
+ break;
+
+ case C_NAME:
+ XGrabKey(dpy, tmp->keycode, (unsigned) tmp->mods, tmp_win->w, True,
+ GrabModeAsync, GrabModeAsync);
+ if (tmp_win->icon_w)
+ XGrabKey(dpy, tmp->keycode, (unsigned) tmp->mods,
+ tmp_win->icon_w, True, GrabModeAsync, GrabModeAsync);
+ if (tmp_win->title_w)
+ XGrabKey(dpy, tmp->keycode, (unsigned) tmp->mods,
+ tmp_win->title_w, True, GrabModeAsync, GrabModeAsync);
+ break;
+ /*
+ 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, (unsigned)tmp->mods, p->twm_win->w);
- }
- }
+ 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, (unsigned) tmp->mods,
+ p->twm_win->w);
+ }
+ }
}
}
-static Window CreateHighlightWindow (TwmWindow *tmp_win)
+static Window
+CreateHighlightWindow(TwmWindow *tmp_win)
{
- XSetWindowAttributes attributes; /* attributes for create windows */
+ XSetWindowAttributes attributes; /* attributes for create windows */
Pixmap pm = None;
GC gc;
XGCValues gcv;
@@ -1105,7 +1095,6 @@ static Window CreateHighlightWindow (TwmWindow *tmp_win)
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
@@ -1119,160 +1108,167 @@ static Window CreateHighlightWindow (TwmWindow *tmp_win)
* solid line.
*/
if (!Scr->hilitePm) {
- Scr->hilitePm = XCreateBitmapFromData (dpy, tmp_win->title_w,
- gray_bits, gray_width,
- gray_height);
- Scr->hilite_pm_width = gray_width;
- Scr->hilite_pm_height = gray_height;
+ Scr->hilitePm = XCreateBitmapFromData(dpy, tmp_win->title_w,
+ gray_bits, gray_width,
+ gray_height);
+ Scr->hilite_pm_width = gray_width;
+ Scr->hilite_pm_height = gray_height;
}
if (Scr->hilitePm) {
- pm = XCreatePixmap (dpy, tmp_win->title_w,
- (unsigned)Scr->hilite_pm_width, (unsigned)Scr->hilite_pm_height,
- (unsigned)Scr->d_depth);
- gcv.foreground = tmp_win->title.fore;
- gcv.background = tmp_win->title.back;
- gcv.graphics_exposures = False;
- gc = XCreateGC (dpy, pm,
- (GCForeground|GCBackground|GCGraphicsExposures),
- &gcv);
- if (gc) {
- XCopyPlane (dpy, Scr->hilitePm, pm, gc, 0, 0,
- (unsigned)Scr->hilite_pm_width, (unsigned)Scr->hilite_pm_height,
- 0, 0, 1);
- XFreeGC (dpy, gc);
- } else {
- XFreePixmap (dpy, pm);
- pm = None;
- }
+ pm = XCreatePixmap(dpy, tmp_win->title_w,
+ (unsigned) Scr->hilite_pm_width,
+ (unsigned) Scr->hilite_pm_height,
+ (unsigned) Scr->d_depth);
+ gcv.foreground = tmp_win->title.fore;
+ gcv.background = tmp_win->title.back;
+ gcv.graphics_exposures = False;
+ gc = XCreateGC(dpy, pm,
+ (GCForeground | GCBackground | GCGraphicsExposures),
+ &gcv);
+ if (gc) {
+ XCopyPlane(dpy, Scr->hilitePm, pm, gc, 0, 0,
+ (unsigned) Scr->hilite_pm_width,
+ (unsigned) Scr->hilite_pm_height, 0, 0, 1);
+ XFreeGC(dpy, gc);
+ }
+ else {
+ XFreePixmap(dpy, pm);
+ pm = None;
+ }
}
if (pm) {
- valuemask = CWBackPixmap;
- attributes.background_pixmap = pm;
- } else {
- valuemask = CWBackPixel;
- attributes.background_pixel = tmp_win->title.fore;
+ valuemask = CWBackPixmap;
+ attributes.background_pixmap = pm;
+ }
+ else {
+ valuemask = CWBackPixel;
+ attributes.background_pixel = tmp_win->title.fore;
}
- w = XCreateWindow (dpy, tmp_win->title_w, 0, Scr->FramePadding,
- (unsigned int) Scr->TBInfo.width, (unsigned int) h,
- (unsigned int) 0,
- Scr->d_depth, (unsigned int) CopyFromParent,
- Scr->d_visual, valuemask, &attributes);
- if (pm) XFreePixmap (dpy, pm);
+ w = XCreateWindow(dpy, tmp_win->title_w, 0, Scr->FramePadding,
+ (unsigned int) Scr->TBInfo.width, (unsigned int) h,
+ (unsigned int) 0,
+ Scr->d_depth, (unsigned int) CopyFromParent,
+ Scr->d_visual, valuemask, &attributes);
+ if (pm)
+ XFreePixmap(dpy, pm);
return w;
}
-
-void ComputeCommonTitleOffsets (void)
+void
+ComputeCommonTitleOffsets(void)
{
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.leftx += Scr->ButtonIndent;
Scr->TBInfo.titlex = (Scr->TBInfo.leftx +
- (Scr->TBInfo.nleft * buttonwidth) - Scr->TBInfo.pad +
- Scr->TitlePadding);
+ (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));
+ Scr->TBInfo.rightoff += (Scr->ButtonIndent +
+ ((Scr->TBInfo.nright * buttonwidth) -
+ Scr->TBInfo.pad));
return;
}
-void ComputeWindowTitleOffsets (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->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;
+ 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;
}
-
/**
* 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 (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:
- basex = maxwidth / 2;
- break;
- }
- }
- } else { /* num/denom is fraction */
- basex = ((si->num * maxwidth) / si->denom);
- if (si->num < 0) basex += maxwidth;
- }
-
- /*
- * 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;
+ 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:
+ basex = maxwidth / 2;
+ break;
+ }
+ }
+ }
+ else { /* num/denom is fraction */
+ basex = ((si->num * maxwidth) / si->denom);
+ if (si->num < 0)
+ basex += maxwidth;
+ }
+
+ /*
+ * 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 (TwmWindow *tmp_win)
+static void
+CreateWindowTitlebarButtons(TwmWindow *tmp_win)
{
- unsigned long valuemask; /* mask for create windows */
- XSetWindowAttributes attributes; /* attributes for create windows */
+ 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;
+ 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);
+ ComputeWindowTitleOffsets(tmp_win, tmp_win->attr.width, False);
leftx = y = Scr->TBInfo.leftx;
rightx = tmp_win->rightx;
@@ -1281,88 +1277,94 @@ static void CreateWindowTitlebarButtons (TwmWindow *tmp_win)
attributes.background_pixel = tmp_win->title.back;
attributes.border_pixel = tmp_win->title.fore;
attributes.event_mask = (ButtonPressMask | ButtonReleaseMask |
- ExposureMask);
+ ExposureMask);
attributes.cursor = Scr->ButtonCursor;
valuemask = (CWWinGravity | CWBackPixel | CWBorderPixel | CWEventMask |
- CWCursor);
+ CWCursor);
tmp_win->titlebuttons = NULL;
nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
if (nb > 0) {
- tmp_win->titlebuttons = malloc ((size_t)nb * sizeof(TBWindow));
- if (!tmp_win->titlebuttons) {
- fprintf (stderr, "%s: unable to allocate %d titlebuttons\n",
- ProgramName, nb);
- } else {
- TBWindow *tbw;
- int boxwidth = (Scr->TBInfo.width + Scr->TBInfo.pad);
- unsigned h = (unsigned)(Scr->TBInfo.width - Scr->TBInfo.border * 2);
-
- for (tb = Scr->TBInfo.head, tbw = tmp_win->titlebuttons; tb;
- tb = tb->next, tbw++) {
- int x;
- if (tb->rightside) {
- x = rightx;
- rightx += boxwidth;
- attributes.win_gravity = NorthEastGravity;
- } else {
- x = leftx;
- leftx += boxwidth;
- attributes.win_gravity = NorthWestGravity;
- }
- tbw->window = XCreateWindow (dpy, tmp_win->title_w, x, y, h, h,
- (unsigned int) Scr->TBInfo.border,
- 0, (unsigned int) CopyFromParent,
- (Visual *) CopyFromParent,
- valuemask, &attributes);
- tbw->info = tb;
- }
- }
+ tmp_win->titlebuttons = malloc((size_t) nb * sizeof(TBWindow));
+ if (!tmp_win->titlebuttons) {
+ fprintf(stderr, "%s: unable to allocate %d titlebuttons\n",
+ ProgramName, nb);
+ }
+ else {
+ TBWindow *tbw;
+ int boxwidth = (Scr->TBInfo.width + Scr->TBInfo.pad);
+ unsigned h =
+ (unsigned) (Scr->TBInfo.width - Scr->TBInfo.border * 2);
+
+ for (tb = Scr->TBInfo.head, tbw = tmp_win->titlebuttons; tb;
+ tb = tb->next, tbw++) {
+ int x;
+
+ if (tb->rightside) {
+ x = rightx;
+ rightx += boxwidth;
+ attributes.win_gravity = NorthEastGravity;
+ }
+ else {
+ x = leftx;
+ leftx += boxwidth;
+ attributes.win_gravity = NorthWestGravity;
+ }
+ tbw->window = XCreateWindow(dpy, tmp_win->title_w, x, y, h, h,
+ (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);
+ ? CreateHighlightWindow(tmp_win) : None);
XMapSubwindows(dpy, tmp_win->title_w);
if (tmp_win->hilite_w)
- XUnmapWindow(dpy, tmp_win->hilite_w);
+ XUnmapWindow(dpy, tmp_win->hilite_w);
return;
}
-
void
-SetHighlightPixmap (char *filename)
+SetHighlightPixmap(char *filename)
{
- Pixmap pm = GetBitmap (filename);
+ Pixmap pm = GetBitmap(filename);
if (pm) {
- if (Scr->hilitePm) {
- XFreePixmap (dpy, Scr->hilitePm);
- }
- Scr->hilitePm = pm;
- Scr->hilite_pm_width = (int)JunkWidth;
- Scr->hilite_pm_height = (int)JunkHeight;
+ if (Scr->hilitePm) {
+ XFreePixmap(dpy, Scr->hilitePm);
+ }
+ Scr->hilitePm = pm;
+ Scr->hilite_pm_width = (int) JunkWidth;
+ Scr->hilite_pm_height = (int) JunkHeight;
}
}
-
void
-FetchWmProtocols (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 (protocols);
+ 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(protocols);
}
tmp->protocols = flags;
}
@@ -1371,11 +1373,12 @@ TwmColormap *
CreateTwmColormap(Colormap c)
{
TwmColormap *cmap;
+
cmap = malloc(sizeof(TwmColormap));
- if (!cmap ||
- XSaveContext(dpy, c, ColormapContext, (XPointer) cmap)) {
- if (cmap) free(cmap);
- return (NULL);
+ if (!cmap || XSaveContext(dpy, c, ColormapContext, (XPointer) cmap)) {
+ if (cmap)
+ free(cmap);
+ return (NULL);
}
cmap->c = c;
cmap->state = 0;
@@ -1394,53 +1397,54 @@ CreateColormapWindow(Window w, Bool creating_parent, Bool property_window)
cwin = malloc(sizeof(ColormapWindow));
if (cwin) {
- if (!XGetWindowAttributes(dpy, w, &attributes) ||
- XSaveContext(dpy, w, ColormapContext, (XPointer) cwin)) {
- free(cwin);
- return (NULL);
- }
-
- if (XFindContext(dpy, attributes.colormap, ColormapContext,
- (XPointer *)&cwin->colormap) == XCNOENT) {
- cwin->colormap = cmap = CreateTwmColormap(attributes.colormap);
- if (!cmap) {
- XDeleteContext(dpy, w, ColormapContext);
- free(cwin);
- return (NULL);
- }
- } else {
- cwin->colormap->refcnt++;
- }
-
- cwin->w = w;
- /*
- * Assume that windows in colormap list are
- * obscured if we are creating the parent window.
- * Otherwise, we assume they are unobscured.
- */
- cwin->visibility = creating_parent ?
- VisibilityPartiallyObscured : VisibilityUnobscured;
- 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));
- }
+ if (!XGetWindowAttributes(dpy, w, &attributes) ||
+ XSaveContext(dpy, w, ColormapContext, (XPointer) cwin)) {
+ free(cwin);
+ return (NULL);
+ }
+
+ if (XFindContext(dpy, attributes.colormap, ColormapContext,
+ (XPointer *) &cwin->colormap) == XCNOENT) {
+ cwin->colormap = cmap = CreateTwmColormap(attributes.colormap);
+ if (!cmap) {
+ XDeleteContext(dpy, w, ColormapContext);
+ free(cwin);
+ return (NULL);
+ }
+ }
+ else {
+ cwin->colormap->refcnt++;
+ }
+
+ cwin->w = w;
+ /*
+ * Assume that windows in colormap list are
+ * obscured if we are creating the parent window.
+ * Otherwise, we assume they are unobscured.
+ */
+ cwin->visibility = creating_parent ?
+ VisibilityPartiallyObscured : VisibilityUnobscured;
+ 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 (TwmWindow *tmp)
+FetchWmColormapWindows(TwmWindow *tmp)
{
register int i, j;
Window *cmap_windows = NULL;
@@ -1451,144 +1455,159 @@ FetchWmColormapWindows (TwmWindow *tmp)
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;
+ /* SUPPRESS 560 */
+ if ((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) {
-
- can_free_cmap_windows = False;
- /*
- * check if the top level is in the list, add to front if not
- */
- for (i = 0; i < number_cmap_windows; i++) {
- if (cmap_windows[i] == tmp->w) break;
- }
- if (i == number_cmap_windows) { /* not in list */
- Window *new_cmap_windows =
- malloc (sizeof(Window) * (size_t)(number_cmap_windows + 1));
-
- if (!new_cmap_windows) {
- fprintf (stderr,
- "%s: unable to allocate %d element colormap window array\n",
- ProgramName, number_cmap_windows+1);
- goto done;
- }
- new_cmap_windows[0] = tmp->w; /* add to front */
- for (i = 0; i < number_cmap_windows; i++) { /* append rest */
- new_cmap_windows[i+1] = cmap_windows[i];
- }
- XFree (cmap_windows);
- can_free_cmap_windows = True; /* do not use XFree any more */
- cmap_windows = new_cmap_windows;
- number_cmap_windows++;
- }
-
- cwins = malloc(sizeof(ColormapWindow *) * (size_t)number_cmap_windows);
- if (cwins) {
- for (i = 0; i < number_cmap_windows; i++) {
-
- /*
- * Copy any existing entries into new list.
- */
- for (j = 0; j < tmp->cmaps.number_cwins; j++) {
- if (tmp->cmaps.cwins[j]->w == cmap_windows[i]) {
- cwins[i] = tmp->cmaps.cwins[j];
- cwins[i]->refcnt++;
- break;
- }
- }
-
- /*
- * If the colormap window is not being pointed by
- * some other applications colormap window list,
- * create a new entry.
- */
- if (j == tmp->cmaps.number_cwins) {
- if (XFindContext(dpy, cmap_windows[i], ColormapContext,
- (XPointer *)&cwins[i]) == XCNOENT) {
- if ((cwins[i] = CreateColormapWindow(cmap_windows[i],
- (Bool) tmp->cmaps.number_cwins == 0,
- True)) == NULL) {
- int k;
- for (k = i + 1; k < number_cmap_windows; k++)
- cmap_windows[k-1] = cmap_windows[k];
- i--;
- number_cmap_windows--;
- }
- } else
- cwins[i]->refcnt++;
- }
- }
- }
+ if (XGetWMColormapWindows(dpy, tmp->w, &cmap_windows,
+ &number_cmap_windows) &&
+ number_cmap_windows > 0) {
+
+ can_free_cmap_windows = False;
+ /*
+ * check if the top level is in the list, add to front if not
+ */
+ for (i = 0; i < number_cmap_windows; i++) {
+ if (cmap_windows[i] == tmp->w)
+ break;
+ }
+ if (i == number_cmap_windows) { /* not in list */
+ Window *new_cmap_windows =
+ malloc(sizeof(Window) * (size_t) (number_cmap_windows + 1));
+
+ if (!new_cmap_windows) {
+ fprintf(stderr,
+ "%s: unable to allocate %d element colormap window array\n",
+ ProgramName, number_cmap_windows + 1);
+ goto done;
+ }
+ new_cmap_windows[0] = tmp->w; /* add to front */
+ for (i = 0; i < number_cmap_windows; i++) { /* append rest */
+ new_cmap_windows[i + 1] = cmap_windows[i];
+ }
+ XFree(cmap_windows);
+ can_free_cmap_windows = True; /* do not use XFree any more */
+ cmap_windows = new_cmap_windows;
+ number_cmap_windows++;
+ }
+
+ cwins = malloc(sizeof(ColormapWindow *) * (size_t) number_cmap_windows);
+ if (cwins) {
+ for (i = 0; i < number_cmap_windows; i++) {
+
+ /*
+ * Copy any existing entries into new list.
+ */
+ for (j = 0; j < tmp->cmaps.number_cwins; j++) {
+ if (tmp->cmaps.cwins[j]->w == cmap_windows[i]) {
+ cwins[i] = tmp->cmaps.cwins[j];
+ cwins[i]->refcnt++;
+ break;
+ }
+ }
+
+ /*
+ * If the colormap window is not being pointed by
+ * some other applications colormap window list,
+ * create a new entry.
+ */
+ if (j == tmp->cmaps.number_cwins) {
+ if (XFindContext(dpy, cmap_windows[i], ColormapContext,
+ (XPointer *) &cwins[i]) == XCNOENT) {
+ if ((cwins[i] = CreateColormapWindow(cmap_windows[i],
+ (Bool) tmp->cmaps.
+ number_cwins == 0,
+ True)) == NULL) {
+ int k;
+
+ for (k = i + 1; k < number_cmap_windows; k++)
+ cmap_windows[k - 1] = cmap_windows[k];
+ i--;
+ number_cmap_windows--;
+ }
+ }
+ else
+ cwins[i]->refcnt++;
+ }
+ }
+ }
}
/* No else here, in case we bailed out of clause above.
*/
if (number_cmap_windows == 0) {
- number_cmap_windows = 1;
-
- cwins = malloc(sizeof(ColormapWindow *));
- if (XFindContext(dpy, tmp->w, ColormapContext, (XPointer *)&cwins[0]) ==
- XCNOENT) {
- cwins[0] = CreateColormapWindow(tmp->w,
- (Bool) tmp->cmaps.number_cwins == 0, False);
- if (cwins[0] == NULL)
- number_cmap_windows = 0;
- } else
- cwins[0]->refcnt++;
+ number_cmap_windows = 1;
+
+ cwins = malloc(sizeof(ColormapWindow *));
+ if (XFindContext(dpy, tmp->w, ColormapContext, (XPointer *) &cwins[0])
+ == XCNOENT) {
+ cwins[0] =
+ CreateColormapWindow(tmp->w,
+ (Bool) tmp->cmaps.number_cwins == 0,
+ False);
+ if (cwins[0] == NULL)
+ number_cmap_windows = 0;
+ }
+ else
+ cwins[0]->refcnt++;
}
if (tmp->cmaps.number_cwins)
- free_cwins(tmp);
+ free_cwins(tmp);
tmp->cmaps.cwins = cwins;
tmp->cmaps.number_cwins = number_cmap_windows;
if (number_cmap_windows > 1)
- tmp->cmaps.scoreboard =
- calloc(1, ColormapsScoreboardLength(&tmp->cmaps));
+ tmp->cmaps.scoreboard =
+ calloc(1, ColormapsScoreboardLength(&tmp->cmaps));
if (previously_installed)
- InstallWindowColormaps(PropertyNotify, (TwmWindow *) NULL);
+ InstallWindowColormaps(PropertyNotify, (TwmWindow *) NULL);
- done:
+ done:
if (cmap_windows) {
- if (can_free_cmap_windows)
- free (cmap_windows);
- else
- XFree (cmap_windows);
+ if (can_free_cmap_windows)
+ free(cmap_windows);
+ else
+ XFree(cmap_windows);
}
return;
}
-
-void GetWindowSizeHints (TwmWindow *tmp)
+void
+GetWindowSizeHints(TwmWindow *tmp)
{
long supplied = 0;
- if (!XGetWMNormalHints (dpy, tmp->w, &tmp->hints, &supplied))
- tmp->hints.flags = 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 (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;
+ 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;
}
}
diff --git a/src/add_window.h b/src/add_window.h
index aba9874..df4e909 100644
--- a/src/add_window.h
+++ b/src/add_window.h
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/**********************************************************************
*
* AddWindow include file
@@ -65,22 +64,22 @@ in this Software without prior written authorization from The Open Group.
extern char NoName[];
-extern void AddDefaultBindings ( void );
-extern TwmWindow * AddWindow ( Window w, int iconm, IconMgr *iconp );
-extern ColormapWindow * CreateColormapWindow ( Window w, Bool creating_parent, Bool property_window );
-extern TwmColormap * CreateTwmColormap ( Colormap c );
-extern void FetchWmColormapWindows ( TwmWindow *tmp );
-extern void FetchWmProtocols ( TwmWindow *tmp );
-extern void GetGravityOffsets ( TwmWindow *tmp, int *xp, int *yp );
-extern void GetWindowSizeHints ( TwmWindow *tmp );
-extern void GrabButtons ( TwmWindow *tmp_win );
-extern void GrabKeys ( TwmWindow *tmp_win );
-extern int MappedNotOverride ( Window w );
-extern void SetHighlightPixmap ( char *filename );
+extern void AddDefaultBindings(void);
+extern TwmWindow *AddWindow(Window w, int iconm, IconMgr *iconp);
+extern ColormapWindow *CreateColormapWindow(Window w, Bool creating_parent,
+ Bool property_window);
+extern TwmColormap *CreateTwmColormap(Colormap c);
+extern void FetchWmColormapWindows(TwmWindow *tmp);
+extern void FetchWmProtocols(TwmWindow *tmp);
+extern void GetGravityOffsets(TwmWindow *tmp, int *xp, int *yp);
+extern void GetWindowSizeHints(TwmWindow *tmp);
+extern void GrabButtons(TwmWindow *tmp_win);
+extern void GrabKeys(TwmWindow *tmp_win);
+extern int MappedNotOverride(Window w);
+extern void SetHighlightPixmap(char *filename);
extern int AddingX;
extern int AddingY;
extern int AddingW;
extern int AddingH;
-#endif /* _ADD_WINDOW_ */
-
+#endif /* _ADD_WINDOW_ */
diff --git a/src/cursor.c b/src/cursor.c
index 9a0cb28..98a1256 100644
--- a/src/cursor.c
+++ b/src/cursor.c
@@ -37,6 +37,7 @@ in this Software without prior written authorization from The Open Group.
#include "screen.h"
#include "util.h"
+/* *INDENT-OFF* */
static struct _CursorName {
const char *name;
unsigned int shape;
@@ -121,25 +122,26 @@ static struct _CursorName {
{"watch", XC_watch, None},
{"xterm", XC_xterm, None},
};
+/* *INDENT-ON* */
void
-NewFontCursor (Cursor *cp, const char *str)
+NewFontCursor(Cursor *cp, const char *str)
{
int i;
- for (i = 0; (size_t)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;
- }
+ for (i = 0; (size_t) 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);
+ fprintf(stderr, "%s: unable to find font cursor \"%s\"\n",
+ ProgramName, str);
}
void
@@ -151,22 +153,23 @@ NewBitmapCursor(Cursor *cp, char *source, char *mask)
Pixmap spm, mpm;
spm = GetBitmap(source);
- if ((hotx = HotX) < 0) hotx = 0;
- if ((hoty = HotY) < 0) hoty = 0;
+ 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);
- return;
+ 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);
+ return;
}
*cp = XCreatePixmapCursor(dpy, spm, mpm, &Scr->PointerForeground,
- &Scr->PointerBackground,
- (unsigned)hotx, (unsigned)hoty);
+ &Scr->PointerBackground,
+ (unsigned) hotx, (unsigned) hoty);
}
diff --git a/src/events.c b/src/events.c
index ce66446..6c34261 100644
--- a/src/events.c
+++ b/src/events.c
@@ -49,12 +49,11 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* twm event handling
*
- * 17-Nov-87 Thomas E. LaStrange File created
+ * 17-Nov-87 Thomas E. LaStrange File created
*
***********************************************************************/
@@ -78,20 +77,20 @@ in this Software without prior written authorization from The Open Group.
#endif
#define MAX_X_EVENT 256
-event_proc EventHandler[MAX_X_EVENT]; /* event handler jump table */
+event_proc EventHandler[MAX_X_EVENT]; /* event handler jump table */
static const char *Action;
-int Context = C_NO_CONTEXT; /* current button press context */
-static TwmWindow *ButtonWindow; /* button press window structure */
-static XEvent ButtonEvent; /* button press event */
-XEvent Event; /* the current event */
-static TwmWindow *Tmp_win; /* the current twm window */
+int Context = C_NO_CONTEXT; /* current button press context */
+static TwmWindow *ButtonWindow; /* button press window structure */
+static XEvent ButtonEvent; /* button press event */
+XEvent Event; /* the current event */
+static TwmWindow *Tmp_win; /* the current twm window */
/** Used in HandleEnterNotify to remove border highlight from a window
* that has not recieved a LeaveNotify event because of a pointer grab
*/
static TwmWindow *UnHighLight_win = NULL;
-Window DragWindow; /* variables used in moving windows */
+Window DragWindow; /* variables used in moving windows */
int origDragX;
int origDragY;
int DragX;
@@ -105,38 +104,38 @@ 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 );
-static void RedoIconName ( void );
+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);
+static void RedoIconName(void);
int ButtonPressed = -1;
int Cancel = FALSE;
-
-void AutoRaiseWindow (TwmWindow *tmp)
+void
+AutoRaiseWindow(TwmWindow *tmp)
{
- XRaiseWindow (dpy, tmp->frame);
- XSync (dpy, 0);
+ XRaiseWindow(dpy, tmp->frame);
+ XSync(dpy, 0);
enter_win = NULL;
enter_flag = TRUE;
raise_win = tmp;
}
-void SetRaiseWindow (TwmWindow *tmp)
+void
+SetRaiseWindow(TwmWindow *tmp)
{
enter_flag = TRUE;
enter_win = NULL;
raise_win = tmp;
- XSync (dpy, 0);
+ XSync(dpy, 0);
}
-
-
/**
* initialize the event jump table.
*/
@@ -145,14 +144,13 @@ InitEvents(void)
{
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[i] = HandleUnknown;
EventHandler[Expose] = HandleExpose;
EventHandler[CreateNotify] = HandleCreateNotify;
@@ -172,141 +170,141 @@ InitEvents(void)
EventHandler[ColormapNotify] = HandleColormapNotify;
EventHandler[VisibilityNotify] = HandleVisibilityNotify;
if (HasShape)
- EventHandler[ShapeEventBase+ShapeNotify] = HandleShapeNotify;
+ EventHandler[ShapeEventBase + ShapeNotify] = HandleShapeNotify;
#ifdef HAVE_XRANDR
- if (HasXrandr)
- {
- int scrnum;
-
- EventHandler[XrandrEventBase+RRScreenChangeNotify] = HandleScreenChangeNotify;
- for (scrnum = 0; scrnum < NumScreens; scrnum++)
- {
- XRRSelectInput(dpy,ScreenList[scrnum]->Root,RRScreenChangeNotifyMask);
- }
+ if (HasXrandr) {
+ int scrnum;
+
+ EventHandler[XrandrEventBase + RRScreenChangeNotify] =
+ HandleScreenChangeNotify;
+ for (scrnum = 0; scrnum < NumScreens; scrnum++) {
+ XRRSelectInput(dpy, ScreenList[scrnum]->Root,
+ RRScreenChangeNotifyMask);
+ }
}
#endif
}
+Time lastTimestamp = CurrentTime; /* until Xlib does this for us */
-
-
-Time lastTimestamp = CurrentTime; /* until Xlib does this for us */
-
-Bool StashEventTime (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;
+ 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;
}
-
-
/**
* 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 (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).
*/
+ /* *INDENT-OFF* */
switch (e->type) {
case KeyPress:
- case KeyRelease: return e->xkey.window; /* same */
+ case KeyRelease: return e->xkey.window; /* same */
case ButtonPress:
- case ButtonRelease: return e->xbutton.window; /* same */
- case MotionNotify: return e->xmotion.window; /* same */
+ case ButtonRelease: return e->xbutton.window; /* same */
+ case MotionNotify: return e->xmotion.window; /* same */
case EnterNotify:
- case LeaveNotify: return e->xcrossing.window; /* same */
+ 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 */
- case VisibilityNotify: return e->xvisibility.window; /* same */
- case CreateNotify: return e->xcreatewindow.window; /* DIFF */
- case DestroyNotify: return e->xdestroywindow.window; /* DIFF */
- case UnmapNotify: return e->xunmap.window; /* DIFF */
- case MapNotify: return e->xmap.window; /* DIFF */
- case MapRequest: return e->xmaprequest.window; /* DIFF */
- case ReparentNotify: return e->xreparent.window; /* DIFF */
- case ConfigureNotify: return e->xconfigure.window; /* DIFF */
+ 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 */
+ case VisibilityNotify: return e->xvisibility.window; /* same */
+ case CreateNotify: return e->xcreatewindow.window; /* DIFF */
+ case DestroyNotify: return e->xdestroywindow.window; /* DIFF */
+ case UnmapNotify: return e->xunmap.window; /* DIFF */
+ case MapNotify: return e->xmap.window; /* DIFF */
+ case MapRequest: return e->xmaprequest.window; /* DIFF */
+ 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 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;
- }
+ 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;
+ }
+ /* *INDENT-ON* */
return None;
}
-
-
/**
* handle a single X event stored in global var Event
* this routine for is for a call during an f.move
*/
-Bool DispatchEvent2 (void)
+Bool
+DispatchEvent2(void)
{
Window w = Event.xany.window;
XPointer context_data;
- StashEventTime (&Event);
+ StashEventTime(&Event);
- if (XFindContext (dpy, w, TwmContext, &context_data) == 0)
- Tmp_win = (TwmWindow *) context_data;
+ if (XFindContext(dpy, w, TwmContext, &context_data) == 0)
+ Tmp_win = (TwmWindow *) context_data;
else
- Tmp_win = NULL;
+ Tmp_win = NULL;
- if (XFindContext (dpy, w, ScreenContext, &context_data) == 0)
- Scr = (struct ScreenInfo *) context_data;
+ if (XFindContext(dpy, w, ScreenContext, &context_data) == 0)
+ Scr = (struct ScreenInfo *) context_data;
else
- Scr = FindScreenInfo (WindowOfEvent (&Event));
+ Scr = FindScreenInfo(WindowOfEvent(&Event));
- if (!Scr) return False;
+ if (!Scr)
+ return False;
if (menuFromFrameOrWindowOrTitlebar && Event.type == Expose)
- HandleExpose();
+ HandleExpose();
- if (!menuFromFrameOrWindowOrTitlebar && Event.type>= 0 && Event.type < MAX_X_EVENT) {
- (*EventHandler[Event.type])();
+ if (!menuFromFrameOrWindowOrTitlebar && Event.type >= 0 &&
+ Event.type < MAX_X_EVENT) {
+ (*EventHandler[Event.type]) ();
}
return True;
@@ -315,62 +313,61 @@ Bool DispatchEvent2 (void)
/**
* handle a single X event stored in global var Event
*/
-Bool DispatchEvent (void)
+Bool
+DispatchEvent(void)
{
Window w = Event.xany.window;
XPointer context_data;
- StashEventTime (&Event);
+ StashEventTime(&Event);
- if (XFindContext (dpy, w, TwmContext, &context_data) == 0)
- Tmp_win = (TwmWindow *) context_data;
+ if (XFindContext(dpy, w, TwmContext, &context_data) == 0)
+ Tmp_win = (TwmWindow *) context_data;
else
- Tmp_win = NULL;
+ Tmp_win = NULL;
- if (XFindContext (dpy, w, ScreenContext, &context_data) == 0)
- Scr = (struct ScreenInfo *) context_data;
+ if (XFindContext(dpy, w, ScreenContext, &context_data) == 0)
+ Scr = (struct ScreenInfo *) context_data;
else
- Scr = FindScreenInfo (WindowOfEvent (&Event));
+ Scr = FindScreenInfo(WindowOfEvent(&Event));
- if (!Scr) return False;
+ if (!Scr)
+ return False;
- if (Event.type>= 0 && Event.type < MAX_X_EVENT) {
- (*EventHandler[Event.type])();
+ if (Event.type >= 0 && Event.type < MAX_X_EVENT) {
+ (*EventHandler[Event.type]) ();
}
return True;
}
-
-
/**
* handle X events
*/
void
HandleEvents(void)
{
- 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);
+ 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);
}
}
-
-
/**
* colormap notify event handler.
*
@@ -389,148 +386,135 @@ HandleColormapNotify(void)
XPointer context_data;
if (XFindContext(dpy, cevent->window, ColormapContext, &context_data) == 0)
- cwin = (ColormapWindow *) context_data;
+ cwin = (ColormapWindow *) context_data;
else
- return;
+ return;
cmap = cwin->colormap;
- if (cevent->new)
- {
- if (XFindContext(dpy, cevent->colormap, ColormapContext,
- &context_data) == XCNOENT)
- cwin->colormap = CreateTwmColormap(cevent->colormap);
- else
- {
- cwin->colormap = (TwmColormap *) context_data;
- cwin->colormap->refcnt++;
- }
-
- cmap->refcnt--;
-
- if (cevent->state == ColormapUninstalled)
- cmap->state &= ~CM_INSTALLED;
- else
- cmap->state |= CM_INSTALLED;
-
- if (cmap->state & CM_INSTALLABLE)
- InstallWindowColormaps(ColormapNotify, (TwmWindow *) NULL);
-
- if (cmap->refcnt == 0)
- {
- XDeleteContext(dpy, cmap->c, ColormapContext);
- free(cmap);
- }
-
- return;
- }
-
- if (cevent->state == ColormapUninstalled &&
- (cmap->state & CM_INSTALLABLE))
- {
- if (!(cmap->state & CM_INSTALLED))
- return;
- cmap->state &= ~CM_INSTALLED;
-
- if (!ColortableThrashing)
- {
- ColortableThrashing = TRUE;
- XSync(dpy, 0);
- }
-
- if (cevent->serial >= Scr->cmapInfo.first_req)
- {
- number_cwins = Scr->cmapInfo.cmaps->number_cwins;
-
- /*
- * Find out which colortables collided.
- */
-
- cwins = Scr->cmapInfo.cmaps->cwins;
- for (lost = won = -1, n = 0;
- (lost == -1 || won == -1) && n < number_cwins;
- n++)
- {
- if (lost == -1 && cwins[n] == cwin)
- {
- lost = n; /* This is the window which lost its colormap */
- continue;
- }
-
- if (won == -1 &&
- cwins[n]->colormap->install_req == cevent->serial)
- {
- won = n; /* This is the window whose colormap caused */
- continue; /* the de-install of the previous colormap */
- }
- }
-
- /*
- ** Cases are:
- ** Both the request and the window were found:
- ** One of the installs made honoring the WM_COLORMAP
- ** property caused another of the colormaps to be
- ** de-installed, just mark the scoreboard.
- **
- ** Only the request was found:
- ** One of the installs made honoring the WM_COLORMAP
- ** property caused a window not in the WM_COLORMAP
- ** list to lose its map. This happens when the map
- ** it is losing is one which is trying to be installed,
- ** but is getting getting de-installed by another map
- ** in this case, we'll get a scoreable event later,
- ** this one is meaningless.
- **
- ** Neither the request nor the window was found:
- ** Somebody called installcolormap, but it doesn't
- ** affect the WM_COLORMAP windows. This case will
- ** probably never occur.
- **
- ** Only the window was found:
- ** One of the WM_COLORMAP windows lost its colormap
- ** but it wasn't one of the requests known. This is
- ** probably because someone did an "InstallColormap".
- ** The colormap policy is "enforced" by re-installing
- ** the colormaps which are believed to be correct.
- */
-
- if (won != -1) {
- if (lost != -1)
- {
- /* lower diagonal index calculation */
- if (lost > won)
- n = lost*(lost-1)/2 + won;
- else
- n = won*(won-1)/2 + lost;
- Scr->cmapInfo.cmaps->scoreboard[n] = 1;
- } else
- {
- /*
- ** One of the cwin installs caused one of the cwin
- ** colormaps to be de-installed, so I'm sure to get an
- ** UninstallNotify for the cwin I know about later.
- ** I haven't got it yet, or the test of CM_INSTALLED
- ** above would have failed. Turning the CM_INSTALLED
- ** 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);
- }
- }
+ if (cevent->new) {
+ if (XFindContext(dpy, cevent->colormap, ColormapContext,
+ &context_data) == XCNOENT)
+ cwin->colormap = CreateTwmColormap(cevent->colormap);
+ else {
+ cwin->colormap = (TwmColormap *) context_data;
+ cwin->colormap->refcnt++;
+ }
+
+ cmap->refcnt--;
+
+ if (cevent->state == ColormapUninstalled)
+ cmap->state &= ~CM_INSTALLED;
+ else
+ cmap->state |= CM_INSTALLED;
+
+ if (cmap->state & CM_INSTALLABLE)
+ InstallWindowColormaps(ColormapNotify, (TwmWindow *) NULL);
+
+ if (cmap->refcnt == 0) {
+ XDeleteContext(dpy, cmap->c, ColormapContext);
+ free(cmap);
+ }
+
+ return;
+ }
+
+ if (cevent->state == ColormapUninstalled && (cmap->state & CM_INSTALLABLE)) {
+ if (!(cmap->state & CM_INSTALLED))
+ return;
+ cmap->state &= ~CM_INSTALLED;
+
+ if (!ColortableThrashing) {
+ ColortableThrashing = TRUE;
+ XSync(dpy, 0);
+ }
+
+ if (cevent->serial >= Scr->cmapInfo.first_req) {
+ number_cwins = Scr->cmapInfo.cmaps->number_cwins;
+
+ /*
+ * Find out which colortables collided.
+ */
+
+ cwins = Scr->cmapInfo.cmaps->cwins;
+ for (lost = won = -1, n = 0;
+ (lost == -1 || won == -1) && n < number_cwins; n++) {
+ if (lost == -1 && cwins[n] == cwin) {
+ lost = n; /* This is the window which lost its colormap */
+ continue;
+ }
+
+ if (won == -1 &&
+ cwins[n]->colormap->install_req == cevent->serial) {
+ won = n; /* This is the window whose colormap caused */
+ continue; /* the de-install of the previous colormap */
+ }
+ }
+
+ /*
+ ** Cases are:
+ ** Both the request and the window were found:
+ ** One of the installs made honoring the WM_COLORMAP
+ ** property caused another of the colormaps to be
+ ** de-installed, just mark the scoreboard.
+ **
+ ** Only the request was found:
+ ** One of the installs made honoring the WM_COLORMAP
+ ** property caused a window not in the WM_COLORMAP
+ ** list to lose its map. This happens when the map
+ ** it is losing is one which is trying to be installed,
+ ** but is getting getting de-installed by another map
+ ** in this case, we'll get a scoreable event later,
+ ** this one is meaningless.
+ **
+ ** Neither the request nor the window was found:
+ ** Somebody called installcolormap, but it doesn't
+ ** affect the WM_COLORMAP windows. This case will
+ ** probably never occur.
+ **
+ ** Only the window was found:
+ ** One of the WM_COLORMAP windows lost its colormap
+ ** but it wasn't one of the requests known. This is
+ ** probably because someone did an "InstallColormap".
+ ** The colormap policy is "enforced" by re-installing
+ ** the colormaps which are believed to be correct.
+ */
+
+ if (won != -1) {
+ if (lost != -1) {
+ /* lower diagonal index calculation */
+ if (lost > won)
+ n = lost * (lost - 1) / 2 + won;
+ else
+ n = won * (won - 1) / 2 + lost;
+ Scr->cmapInfo.cmaps->scoreboard[n] = 1;
+ }
+ else {
+ /*
+ ** One of the cwin installs caused one of the cwin
+ ** colormaps to be de-installed, so I'm sure to get an
+ ** UninstallNotify for the cwin I know about later.
+ ** I haven't got it yet, or the test of CM_INSTALLED
+ ** above would have failed. Turning the CM_INSTALLED
+ ** 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;
+ cmap->state &= ~CM_INSTALLED;
else if (cevent->state == ColormapInstalled)
- cmap->state |= CM_INSTALLED;
+ cmap->state |= CM_INSTALLED;
}
-
-
/**
* visibility notify event handler.
*
@@ -548,9 +532,9 @@ HandleVisibilityNotify(void)
XPointer context_data;
if (XFindContext(dpy, vevent->window, ColormapContext, &context_data) == 0)
- cwin = (ColormapWindow *) context_data;
+ cwin = (ColormapWindow *) context_data;
else
- return;
+ return;
/*
* when Saber complains about retreiving an <int> from an <unsigned int>
@@ -558,19 +542,16 @@ HandleVisibilityNotify(void)
*/
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;
+ 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;
}
-
-
-
int MovedFromKeyPress = False;
/**
@@ -584,112 +565,108 @@ HandleKeyPress(void)
int len;
unsigned int modifier;
- if (InfoLines) XUnmapWindow(dpy, Scr->InfoWindow);
+ 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)
- Context = C_ICON;
- if (Event.xany.window == Tmp_win->frame)
- Context = C_FRAME;
- if (Tmp_win->list && Event.xany.window == Tmp_win->list->w)
- Context = C_ICONMGR;
- if (Tmp_win->list && Event.xany.window == Tmp_win->list->icon)
- Context = C_ICONMGR;
+ 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)
+ Context = C_ICON;
+ if (Event.xany.window == Tmp_win->frame)
+ Context = C_FRAME;
+ if (Tmp_win->list && Event.xany.window == Tmp_win->list->w)
+ Context = C_ICONMGR;
+ if (Tmp_win->list && Event.xany.window == Tmp_win->list->icon)
+ Context = C_ICONMGR;
}
modifier = (Event.xkey.state & mods_used);
ks = XLookupKeysym((XKeyEvent *) &Event, /* KeySyms index */ 0);
- for (key = Scr->FuncKeyRoot.next; key != NULL; key = key->next)
- {
- if (key->keysym == ks &&
- (unsigned)key->mods == modifier &&
- (key->cont == Context || key->cont == C_NAME))
- {
- /* weed out the functions that don't make sense to execute
- * from a key press
- */
- if (key->func == F_RESIZE)
- return;
+
+ for (key = Scr->FuncKeyRoot.next; key != NULL; key = key->next) {
+ if (key->keysym == ks &&
+ (unsigned) key->mods == modifier &&
+ (key->cont == Context || key->cont == C_NAME)) {
+ /* weed out the functions that don't make sense to execute
+ * from a key press
+ */
+ if (key->func == F_RESIZE)
+ return;
/* special case for F_MOVE/F_FORCEMOVE activated from a keypress */
if (key->func == F_MOVE || key->func == F_FORCEMOVE)
MovedFromKeyPress = True;
- if (key->cont != C_NAME)
- {
- ExecuteFunction(key->func, key->action, Event.xany.window,
- Tmp_win, &Event, Context, FALSE);
- XUngrabPointer(dpy, CurrentTime);
- return;
- }
- else
- {
- int matched = FALSE;
- len = (int)strlen(key->win_name);
-
- /* try and match the name first */
- for (Tmp_win = Scr->TwmRoot.next; Tmp_win != NULL;
- Tmp_win = Tmp_win->next)
- {
- if (!strncmp(key->win_name, Tmp_win->name, (size_t)len))
- {
- matched = TRUE;
- ExecuteFunction(key->func, key->action, Tmp_win->frame,
- Tmp_win, &Event, C_FRAME, FALSE);
- XUngrabPointer(dpy, CurrentTime);
- }
- }
-
- /* now try the res_name */
- if (!matched)
- for (Tmp_win = Scr->TwmRoot.next; Tmp_win != NULL;
- Tmp_win = Tmp_win->next)
- {
- if (!strncmp(key->win_name, Tmp_win->class.res_name, (size_t)len))
- {
- matched = TRUE;
- ExecuteFunction(key->func, key->action, Tmp_win->frame,
- Tmp_win, &Event, C_FRAME, FALSE);
- XUngrabPointer(dpy, CurrentTime);
- }
- }
-
- /* now try the res_class */
- if (!matched)
- for (Tmp_win = Scr->TwmRoot.next; Tmp_win != NULL;
- Tmp_win = Tmp_win->next)
- {
- if (!strncmp(key->win_name, Tmp_win->class.res_class, (size_t)len))
- {
- matched = TRUE;
- ExecuteFunction(key->func, key->action, Tmp_win->frame,
- Tmp_win, &Event, C_FRAME, FALSE);
- XUngrabPointer(dpy, CurrentTime);
- }
- }
- if (matched)
- return;
- }
- }
+ if (key->cont != C_NAME) {
+ ExecuteFunction(key->func, key->action, Event.xany.window,
+ Tmp_win, &Event, Context, FALSE);
+ XUngrabPointer(dpy, CurrentTime);
+ return;
+ }
+ else {
+ int matched = FALSE;
+
+ len = (int) strlen(key->win_name);
+
+ /* try and match the name first */
+ for (Tmp_win = Scr->TwmRoot.next; Tmp_win != NULL;
+ Tmp_win = Tmp_win->next) {
+ if (!strncmp(key->win_name, Tmp_win->name, (size_t) len)) {
+ matched = TRUE;
+ ExecuteFunction(key->func, key->action, Tmp_win->frame,
+ Tmp_win, &Event, C_FRAME, FALSE);
+ XUngrabPointer(dpy, CurrentTime);
+ }
+ }
+
+ /* now try the res_name */
+ if (!matched)
+ for (Tmp_win = Scr->TwmRoot.next; Tmp_win != NULL;
+ Tmp_win = Tmp_win->next) {
+ if (!strncmp
+ (key->win_name, Tmp_win->class.res_name,
+ (size_t) len)) {
+ matched = TRUE;
+ ExecuteFunction(key->func, key->action,
+ Tmp_win->frame, Tmp_win, &Event,
+ C_FRAME, FALSE);
+ XUngrabPointer(dpy, CurrentTime);
+ }
+ }
+
+ /* now try the res_class */
+ if (!matched)
+ for (Tmp_win = Scr->TwmRoot.next; Tmp_win != NULL;
+ Tmp_win = Tmp_win->next) {
+ if (!strncmp
+ (key->win_name, Tmp_win->class.res_class,
+ (size_t) len)) {
+ matched = TRUE;
+ ExecuteFunction(key->func, key->action,
+ Tmp_win->frame, Tmp_win, &Event,
+ C_FRAME, FALSE);
+ XUngrabPointer(dpy, CurrentTime);
+ }
+ }
+ if (matched)
+ return;
+ }
+ }
}
/* 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 (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.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);
}
@@ -697,55 +674,54 @@ HandleKeyPress(void)
}
-
-
static void
-free_window_names (TwmWindow *tmp, Bool nukefull, Bool nukename, Bool 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);
+ 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 (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(cmap);
- }
- XDeleteContext(dpy, tmp->cmaps.cwins[i]->w, ColormapContext);
- free(tmp->cmaps.cwins[i]);
- }
- }
- free(tmp->cmaps.cwins);
- if (tmp->cmaps.number_cwins > 1) {
- free(tmp->cmaps.scoreboard);
- tmp->cmaps.scoreboard = NULL;
- }
- tmp->cmaps.number_cwins = 0;
+ 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(cmap);
+ }
+ XDeleteContext(dpy, tmp->cmaps.cwins[i]->w, ColormapContext);
+ free(tmp->cmaps.cwins[i]);
+ }
+ }
+ free(tmp->cmaps.cwins);
+ if (tmp->cmaps.number_cwins > 1) {
+ free(tmp->cmaps.scoreboard);
+ tmp->cmaps.scoreboard = NULL;
+ }
+ tmp->cmaps.number_cwins = 0;
}
}
-
-
/**
* property notify event handler
*/
@@ -753,208 +729,225 @@ void
HandlePropertyNotify(void)
{
char *name = NULL;
- unsigned long valuemask; /* mask for create windows */
- XSetWindowAttributes attributes; /* attributes for create windows */
+ 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);
- }
- return;
-
- case PropertyDelete:
- RemoveRGBColormap (Event.xproperty.atom);
- return;
- }
+ 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);
+ }
+ return;
+
+ case PropertyDelete:
+ RemoveRGBColormap(Event.xproperty.atom);
+
+ return;
+ }
}
- if (!Tmp_win) return; /* unknown window */
+ if (!Tmp_win)
+ return; /* unknown window */
-#define MAX_NAME_LEN 200L /* truncate to this many */
-#define MAX_ICON_NAME_LEN 200L /* ditto */
+#define MAX_NAME_LEN 200L /* truncate to this many */
+#define MAX_ICON_NAME_LEN 200L /* ditto */
switch (Event.xproperty.atom) {
- case XA_WM_NAME:
- if (!I18N_FetchName(dpy, Tmp_win->w, &name)) return;
- free_window_names (Tmp_win, True, True, False);
-
- Tmp_win->full_name = strdup(name ? name : NoName);
- Tmp_win->name = strdup(name ? name : NoName);
- if (name) free(name);
-
- Tmp_win->nameChanged = 1;
-
- Tmp_win->name_width = MyFont_TextWidth (&Scr->TitleBarFont,
- Tmp_win->name,
- (int)strlen (Tmp_win->name));
-
- SetupWindow (Tmp_win, Tmp_win->frame_x, Tmp_win->frame_y,
- Tmp_win->frame_width, Tmp_win->frame_height, -1);
-
- if (Tmp_win->title_w) XClearArea(dpy, Tmp_win->title_w, 0,0,0,0, True);
-
- /*
- * if the icon name is NoName, set the name of the icon to be
- * the same as the window
- */
- if (Tmp_win->icon_name == NoName) {
- Tmp_win->icon_name = Tmp_win->name;
- RedoIconName();
- }
- break;
-
- case XA_WM_ICON_NAME:
- if (!I18N_GetIconName(dpy, Tmp_win->w, &name)) return;
- free_window_names (Tmp_win, False, False, True);
- Tmp_win->icon_name = strdup(name ? name : NoName);
- if (name) free(name);
-
- RedoIconName();
- break;
-
- case XA_WM_HINTS:
- if (Tmp_win->wmhints) XFree (Tmp_win->wmhints);
- Tmp_win->wmhints = XGetWMHints(dpy, Event.xany.window);
-
- if (Tmp_win->wmhints && (Tmp_win->wmhints->flags & WindowGroupHint))
- Tmp_win->group = Tmp_win->wmhints->window_group;
-
- if (Tmp_win->icon_not_ours && Tmp_win->wmhints &&
- !(Tmp_win->wmhints->flags & IconWindowHint)) {
- /* IconWindowHint was formerly on, now off; revert
- // to a default icon */
- int icon_x = 0, icon_y = 0;
- XGetGeometry (dpy, Tmp_win->icon_w, &JunkRoot,
- &icon_x, &icon_y,
- &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth);
- XSelectInput (dpy, Tmp_win->icon_w, None);
- XDeleteContext (dpy, Tmp_win->icon_w, TwmContext);
- XDeleteContext (dpy, Tmp_win->icon_w, ScreenContext);
- CreateIconWindow(Tmp_win, icon_x, icon_y);
- break;
- }
-
- if (!Tmp_win->forced && Tmp_win->wmhints &&
- Tmp_win->wmhints->flags & IconWindowHint) {
- if (Tmp_win->icon_w) {
- int icon_x, icon_y;
-
- /*
- * There's already an icon window.
- * Try to find out where it is; if we succeed, move the new
- * window to where the old one is.
- */
- if (XGetGeometry (dpy, Tmp_win->icon_w, &JunkRoot, &icon_x,
- &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth)) {
- /*
- * Move the new icon window to where the old one was.
- */
- XMoveWindow(dpy, Tmp_win->wmhints->icon_window, icon_x,
- icon_y);
- }
-
- /*
- * If the window is iconic, map the new icon window.
- */
- if (Tmp_win->icon)
- XMapWindow(dpy, Tmp_win->wmhints->icon_window);
-
- /*
- * Now, if the old window isn't ours, unmap it, otherwise
- * just get rid of it completely.
- */
- if (Tmp_win->icon_not_ours) {
- if (Tmp_win->icon_w != Tmp_win->wmhints->icon_window)
- XUnmapWindow(dpy, Tmp_win->icon_w);
- } else
- XDestroyWindow(dpy, Tmp_win->icon_w);
-
- XDeleteContext(dpy, Tmp_win->icon_w, TwmContext);
- XDeleteContext(dpy, Tmp_win->icon_w, ScreenContext);
-
- /*
- * The new icon window isn't our window, so note that fact
- * so that we don't treat it as ours.
- */
- Tmp_win->icon_not_ours = TRUE;
-
- /*
- * Now make the new window the icon window for this window,
- * and set it up to work as such (select for key presses
- * and button presses/releases, set up the contexts for it,
- * and define the cursor for it).
- */
- Tmp_win->icon_w = Tmp_win->wmhints->icon_window;
- XSelectInput (dpy, Tmp_win->icon_w,
- KeyPressMask | ButtonPressMask | ButtonReleaseMask);
- XSaveContext(dpy, Tmp_win->icon_w, TwmContext, (XPointer)Tmp_win);
- XSaveContext(dpy, Tmp_win->icon_w, ScreenContext, (XPointer)Scr);
- XDefineCursor(dpy, Tmp_win->icon_w, Scr->IconCursor);
- }
- }
-
- if (Tmp_win->icon_w && !Tmp_win->forced && Tmp_win->wmhints &&
- (Tmp_win->wmhints->flags & IconPixmapHint)) {
- if (!XGetGeometry (dpy, Tmp_win->wmhints->icon_pixmap, &JunkRoot,
- &JunkX, &JunkY, (unsigned int *)&Tmp_win->icon_width,
- (unsigned int *)&Tmp_win->icon_height, &JunkBW, &JunkDepth)) {
- return;
- }
-
- pm = XCreatePixmap (dpy, Scr->Root, (unsigned)Tmp_win->icon_width,
- (unsigned)Tmp_win->icon_height, (unsigned)Scr->d_depth);
-
- FB(Tmp_win->iconc.fore, Tmp_win->iconc.back);
- XCopyPlane(dpy, Tmp_win->wmhints->icon_pixmap, pm,
- Scr->NormalGC,
- 0,0, (unsigned)Tmp_win->icon_width, (unsigned)Tmp_win->icon_height, 0, 0, 1 );
-
- valuemask = CWBackPixmap;
- attributes.background_pixmap = pm;
-
- if (Tmp_win->icon_bm_w)
- XDestroyWindow(dpy, Tmp_win->icon_bm_w);
-
- Tmp_win->icon_bm_w =
- XCreateWindow (dpy, Tmp_win->icon_w, 0, 0,
- (unsigned int) Tmp_win->icon_width,
- (unsigned int) Tmp_win->icon_height,
- (unsigned int) 0, Scr->d_depth,
- (unsigned int) CopyFromParent, Scr->d_visual,
- valuemask, &attributes);
-
- XFreePixmap (dpy, pm);
- RedoIconName();
- }
- 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;
+ case XA_WM_NAME:
+ if (!I18N_FetchName(dpy, Tmp_win->w, &name))
+ return;
+ free_window_names(Tmp_win, True, True, False);
+
+ Tmp_win->full_name = strdup(name ? name : NoName);
+ Tmp_win->name = strdup(name ? name : NoName);
+ if (name)
+ free(name);
+
+ Tmp_win->nameChanged = 1;
+
+ Tmp_win->name_width = MyFont_TextWidth(&Scr->TitleBarFont,
+ Tmp_win->name,
+ (int) strlen(Tmp_win->name));
+
+ SetupWindow(Tmp_win, Tmp_win->frame_x, Tmp_win->frame_y,
+ Tmp_win->frame_width, Tmp_win->frame_height, -1);
+
+ if (Tmp_win->title_w)
+ XClearArea(dpy, Tmp_win->title_w, 0, 0, 0, 0, True);
+
+ /*
+ * if the icon name is NoName, set the name of the icon to be
+ * the same as the window
+ */
+ if (Tmp_win->icon_name == NoName) {
+ Tmp_win->icon_name = Tmp_win->name;
+ RedoIconName();
+ }
+ break;
+
+ case XA_WM_ICON_NAME:
+ if (!I18N_GetIconName(dpy, Tmp_win->w, &name))
+ return;
+ free_window_names(Tmp_win, False, False, True);
+ Tmp_win->icon_name = strdup(name ? name : NoName);
+ if (name)
+ free(name);
+
+ RedoIconName();
+ break;
+
+ case XA_WM_HINTS:
+ if (Tmp_win->wmhints)
+ XFree(Tmp_win->wmhints);
+ Tmp_win->wmhints = XGetWMHints(dpy, Event.xany.window);
+
+ if (Tmp_win->wmhints && (Tmp_win->wmhints->flags & WindowGroupHint))
+ Tmp_win->group = Tmp_win->wmhints->window_group;
+
+ if (Tmp_win->icon_not_ours && Tmp_win->wmhints &&
+ !(Tmp_win->wmhints->flags & IconWindowHint)) {
+ /* IconWindowHint was formerly on, now off; revert
+ // to a default icon */
+ int icon_x = 0, icon_y = 0;
+
+ XGetGeometry(dpy, Tmp_win->icon_w, &JunkRoot,
+ &icon_x, &icon_y,
+ &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth);
+ XSelectInput(dpy, Tmp_win->icon_w, None);
+ XDeleteContext(dpy, Tmp_win->icon_w, TwmContext);
+ XDeleteContext(dpy, Tmp_win->icon_w, ScreenContext);
+ CreateIconWindow(Tmp_win, icon_x, icon_y);
+ break;
+ }
+
+ if (!Tmp_win->forced && Tmp_win->wmhints &&
+ Tmp_win->wmhints->flags & IconWindowHint) {
+ if (Tmp_win->icon_w) {
+ int icon_x, icon_y;
+
+ /*
+ * There's already an icon window.
+ * Try to find out where it is; if we succeed, move the new
+ * window to where the old one is.
+ */
+ if (XGetGeometry(dpy, Tmp_win->icon_w, &JunkRoot, &icon_x,
+ &icon_y, &JunkWidth, &JunkHeight, &JunkBW,
+ &JunkDepth)) {
+ /*
+ * Move the new icon window to where the old one was.
+ */
+ XMoveWindow(dpy, Tmp_win->wmhints->icon_window, icon_x,
+ icon_y);
+ }
+
+ /*
+ * If the window is iconic, map the new icon window.
+ */
+ if (Tmp_win->icon)
+ XMapWindow(dpy, Tmp_win->wmhints->icon_window);
+
+ /*
+ * Now, if the old window isn't ours, unmap it, otherwise
+ * just get rid of it completely.
+ */
+ if (Tmp_win->icon_not_ours) {
+ if (Tmp_win->icon_w != Tmp_win->wmhints->icon_window)
+ XUnmapWindow(dpy, Tmp_win->icon_w);
+ }
+ else
+ XDestroyWindow(dpy, Tmp_win->icon_w);
+
+ XDeleteContext(dpy, Tmp_win->icon_w, TwmContext);
+ XDeleteContext(dpy, Tmp_win->icon_w, ScreenContext);
+
+ /*
+ * The new icon window isn't our window, so note that fact
+ * so that we don't treat it as ours.
+ */
+ Tmp_win->icon_not_ours = TRUE;
+
+ /*
+ * Now make the new window the icon window for this window,
+ * and set it up to work as such (select for key presses
+ * and button presses/releases, set up the contexts for it,
+ * and define the cursor for it).
+ */
+ Tmp_win->icon_w = Tmp_win->wmhints->icon_window;
+ XSelectInput(dpy, Tmp_win->icon_w,
+ KeyPressMask | ButtonPressMask |
+ ButtonReleaseMask);
+ XSaveContext(dpy, Tmp_win->icon_w, TwmContext,
+ (XPointer) Tmp_win);
+ XSaveContext(dpy, Tmp_win->icon_w, ScreenContext,
+ (XPointer) Scr);
+ XDefineCursor(dpy, Tmp_win->icon_w, Scr->IconCursor);
+ }
+ }
+
+ if (Tmp_win->icon_w && !Tmp_win->forced && Tmp_win->wmhints &&
+ (Tmp_win->wmhints->flags & IconPixmapHint)) {
+ if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &JunkRoot,
+ &JunkX, &JunkY,
+ (unsigned int *) &Tmp_win->icon_width,
+ (unsigned int *) &Tmp_win->icon_height, &JunkBW,
+ &JunkDepth)) {
+ return;
+ }
+
+ pm = XCreatePixmap(dpy, Scr->Root, (unsigned) Tmp_win->icon_width,
+ (unsigned) Tmp_win->icon_height,
+ (unsigned) Scr->d_depth);
+
+ FB(Tmp_win->iconc.fore, Tmp_win->iconc.back);
+ XCopyPlane(dpy, Tmp_win->wmhints->icon_pixmap, pm,
+ Scr->NormalGC,
+ 0, 0, (unsigned) Tmp_win->icon_width,
+ (unsigned) Tmp_win->icon_height, 0, 0, 1);
+
+ valuemask = CWBackPixmap;
+ attributes.background_pixmap = pm;
+
+ if (Tmp_win->icon_bm_w)
+ XDestroyWindow(dpy, Tmp_win->icon_bm_w);
+
+ Tmp_win->icon_bm_w =
+ XCreateWindow(dpy, Tmp_win->icon_w, 0, 0,
+ (unsigned int) Tmp_win->icon_width,
+ (unsigned int) Tmp_win->icon_height,
+ (unsigned int) 0, Scr->d_depth,
+ (unsigned int) CopyFromParent, Scr->d_visual,
+ valuemask, &attributes);
+
+ XFreePixmap(dpy, pm);
+ RedoIconName();
+ }
+ 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 to re-position the icon window and name
*/
@@ -963,90 +956,79 @@ RedoIconName(void)
{
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 (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 (Scr->SortIconMgr)
+ SortIconManager(Tmp_win->list->iconmgr);
}
if (Tmp_win->icon_w == (Window) 0)
- return;
+ return;
if (Tmp_win->icon_not_ours)
- return;
+ return;
Tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont,
- Tmp_win->icon_name, (int)strlen(Tmp_win->icon_name));
+ Tmp_win->icon_name,
+ (int) strlen(Tmp_win->icon_name));
Tmp_win->icon_w_width += 6;
- if (Tmp_win->icon_w_width < Tmp_win->icon_width)
- {
- Tmp_win->icon_x = (Tmp_win->icon_width - Tmp_win->icon_w_width)/2;
- Tmp_win->icon_x += 3;
- Tmp_win->icon_w_width = Tmp_win->icon_width;
+ if (Tmp_win->icon_w_width < Tmp_win->icon_width) {
+ Tmp_win->icon_x = (Tmp_win->icon_width - Tmp_win->icon_w_width) / 2;
+ Tmp_win->icon_x += 3;
+ Tmp_win->icon_w_width = Tmp_win->icon_width;
}
- else
- {
- Tmp_win->icon_x = 3;
+ else {
+ Tmp_win->icon_x = 3;
}
if (Tmp_win->icon_w_width == Tmp_win->icon_width)
- x = 0;
+ x = 0;
else
- x = (Tmp_win->icon_w_width - Tmp_win->icon_width)/2;
+ x = (Tmp_win->icon_w_width - Tmp_win->icon_width) / 2;
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, (unsigned)Tmp_win->icon_w_width,
- (unsigned)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);
+ XResizeWindow(dpy, Tmp_win->icon_w, (unsigned) Tmp_win->icon_w_width,
+ (unsigned) 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);
+ if (Tmp_win->icon) {
+ XClearArea(dpy, Tmp_win->icon_w, 0, 0, 0, 0, True);
}
}
-
-
/**
*client message event handler
*/
void
HandleClientMessage(void)
{
- 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);
- }
- }
+ 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);
+ }
+ }
}
}
-
-
/**
* expose event handler
*/
@@ -1055,127 +1037,130 @@ HandleExpose(void)
{
XPointer context_data;
- if (XFindContext(dpy, Event.xany.window, MenuContext, &context_data) == 0)
- {
- MenuRoot *tmp = (MenuRoot *) context_data;
- PaintMenu(tmp, &Event);
- return;
+ if (XFindContext(dpy, Event.xany.window, MenuContext, &context_data) == 0) {
+ MenuRoot *tmp = (MenuRoot *) context_data;
+ 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,
- &Scr->DefaultFont);
-
- height = Scr->DefaultFont.height+2;
- for (i = 0; i < InfoLines; i++)
- {
- MyFont_DrawString(dpy, Scr->InfoWindow, &Scr->DefaultFont,
- Scr->NormalGC, 5, (i*height) + Scr->DefaultFont.y, Info[i],
- (int)strlen(Info[i]));
- }
- flush_expose (Event.xany.window);
- }
- else if (Tmp_win != NULL)
- {
- if (Event.xany.window == Tmp_win->title_w)
- {
- MyFont_ChangeGC(Tmp_win->title.fore, Tmp_win->title.back,
- &Scr->TitleBarFont);
-
- MyFont_DrawString (dpy, Tmp_win->title_w, &Scr->TitleBarFont,
- Scr->NormalGC, Scr->TBInfo.titlex, Scr->TitleBarFont.y,
- Tmp_win->name, (int)strlen(Tmp_win->name));
- flush_expose (Event.xany.window);
- }
- else if (Event.xany.window == Tmp_win->icon_w)
- {
- MyFont_ChangeGC(Tmp_win->iconc.fore, Tmp_win->iconc.back,
- &Scr->IconFont);
-
- MyFont_DrawString (dpy, Tmp_win->icon_w, &Scr->IconFont,
- Scr->NormalGC, Tmp_win->icon_x, Tmp_win->icon_y,
- Tmp_win->icon_name, (int)strlen(Tmp_win->icon_name));
- flush_expose (Event.xany.window);
- return;
- } else if (Tmp_win->titlebuttons) {
- int i;
- Window w = Event.xany.window;
- register TBWindow *tbw;
- int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
-
- for (i = 0, tbw = Tmp_win->titlebuttons; i < nb; i++, tbw++) {
- if (w == tbw->window) {
- register TitleButton *tb = tbw->info;
-
- FB(Tmp_win->title.fore, Tmp_win->title.back);
- XCopyPlane (dpy, tb->bitmap, w, Scr->NormalGC,
- tb->srcx, tb->srcy, tb->width, tb->height,
- tb->dstx, tb->dsty, 1);
- flush_expose (w);
- return;
- }
- }
- }
- if (Tmp_win->list) {
- if (Event.xany.window == Tmp_win->list->w)
- {
- MyFont_ChangeGC(Tmp_win->list->fore, Tmp_win->list->back,
- &Scr->IconManagerFont);
- MyFont_DrawString (dpy, Event.xany.window,
- &Scr->IconManagerFont, Scr->NormalGC,
- iconmgr_textx, Scr->IconManagerFont.y+4,
- Tmp_win->icon_name, (int)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, (unsigned)iconifybox_width, (unsigned)iconifybox_height, 0, 0, 1);
- flush_expose (Event.xany.window);
- return;
- }
- }
+ return;
+
+ if (Event.xany.window == Scr->InfoWindow && InfoLines) {
+ int i;
+ int height;
+
+ MyFont_ChangeGC(Scr->DefaultC.fore, Scr->DefaultC.back,
+ &Scr->DefaultFont);
+
+ height = Scr->DefaultFont.height + 2;
+ for (i = 0; i < InfoLines; i++) {
+ MyFont_DrawString(dpy, Scr->InfoWindow, &Scr->DefaultFont,
+ Scr->NormalGC, 5,
+ (i * height) + Scr->DefaultFont.y, Info[i],
+ (int) strlen(Info[i]));
+ }
+ flush_expose(Event.xany.window);
+ }
+ else if (Tmp_win != NULL) {
+ if (Event.xany.window == Tmp_win->title_w) {
+ MyFont_ChangeGC(Tmp_win->title.fore, Tmp_win->title.back,
+ &Scr->TitleBarFont);
+
+ MyFont_DrawString(dpy, Tmp_win->title_w, &Scr->TitleBarFont,
+ Scr->NormalGC, Scr->TBInfo.titlex,
+ Scr->TitleBarFont.y, Tmp_win->name,
+ (int) strlen(Tmp_win->name));
+ flush_expose(Event.xany.window);
+ }
+ else if (Event.xany.window == Tmp_win->icon_w) {
+ MyFont_ChangeGC(Tmp_win->iconc.fore, Tmp_win->iconc.back,
+ &Scr->IconFont);
+
+ MyFont_DrawString(dpy, Tmp_win->icon_w, &Scr->IconFont,
+ Scr->NormalGC, Tmp_win->icon_x, Tmp_win->icon_y,
+ Tmp_win->icon_name,
+ (int) strlen(Tmp_win->icon_name));
+ flush_expose(Event.xany.window);
+
+ return;
+ }
+ else if (Tmp_win->titlebuttons) {
+ int i;
+ Window w = Event.xany.window;
+ register TBWindow *tbw;
+ int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
+
+ for (i = 0, tbw = Tmp_win->titlebuttons; i < nb; i++, tbw++) {
+ if (w == tbw->window) {
+ register TitleButton *tb = tbw->info;
+
+ FB(Tmp_win->title.fore, Tmp_win->title.back);
+ XCopyPlane(dpy, tb->bitmap, w, Scr->NormalGC,
+ tb->srcx, tb->srcy, tb->width, tb->height,
+ tb->dstx, tb->dsty, 1);
+ flush_expose(w);
+ return;
+ }
+ }
+ }
+ if (Tmp_win->list) {
+ if (Event.xany.window == Tmp_win->list->w) {
+ MyFont_ChangeGC(Tmp_win->list->fore, Tmp_win->list->back,
+ &Scr->IconManagerFont);
+ MyFont_DrawString(dpy, Event.xany.window,
+ &Scr->IconManagerFont, Scr->NormalGC,
+ iconmgr_textx, Scr->IconManagerFont.y + 4,
+ Tmp_win->icon_name,
+ (int) 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, (unsigned) iconifybox_width,
+ (unsigned) iconifybox_height, 0, 0, 1);
+ flush_expose(Event.xany.window);
+
+ return;
+ }
+ }
}
}
-
-
-static void remove_window_from_ring (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;
+ enter_flag = FALSE;
+ enter_win = NULL;
}
- if (raise_win == Tmp_win) raise_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 (prev)
+ prev->ring.next = next;
+ if (next)
+ next->ring.prev = prev;
if (Scr->Ring == tmp)
- Scr->Ring = (next != tmp ? next : (TwmWindow *) NULL);
+ Scr->Ring = (next != tmp ? next : (TwmWindow *) NULL);
- if (!Scr->Ring || Scr->RingLeader == tmp) Scr->RingLeader = Scr->Ring;
+ if (!Scr->Ring || Scr->RingLeader == tmp)
+ Scr->RingLeader = Scr->Ring;
}
-
-
/**
* DestroyNotify event handler
*/
@@ -1191,43 +1176,40 @@ HandleDestroyNotify(void)
*/
if (Tmp_win == NULL)
- return;
+ return;
- if (Tmp_win == Scr->Focus)
- {
- FocusOnRoot();
+ if (Tmp_win == Scr->Focus) {
+ FocusOnRoot();
}
XDeleteContext(dpy, Tmp_win->w, TwmContext);
XDeleteContext(dpy, Tmp_win->w, ScreenContext);
XDeleteContext(dpy, Tmp_win->frame, TwmContext);
XDeleteContext(dpy, Tmp_win->frame, ScreenContext);
- if (Tmp_win->icon_w)
- {
- XDeleteContext(dpy, Tmp_win->icon_w, TwmContext);
- XDeleteContext(dpy, Tmp_win->icon_w, ScreenContext);
- }
- if (Tmp_win->title_height)
- {
- int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
- XDeleteContext(dpy, Tmp_win->title_w, TwmContext);
- XDeleteContext(dpy, Tmp_win->title_w, ScreenContext);
- if (Tmp_win->hilite_w)
- {
- XDeleteContext(dpy, Tmp_win->hilite_w, TwmContext);
- XDeleteContext(dpy, Tmp_win->hilite_w, ScreenContext);
- }
- if (Tmp_win->titlebuttons) {
- for (i = 0; i < nb; i++) {
- XDeleteContext (dpy, Tmp_win->titlebuttons[i].window,
- TwmContext);
- XDeleteContext (dpy, Tmp_win->titlebuttons[i].window,
- ScreenContext);
- }
+ if (Tmp_win->icon_w) {
+ XDeleteContext(dpy, Tmp_win->icon_w, TwmContext);
+ XDeleteContext(dpy, Tmp_win->icon_w, ScreenContext);
+ }
+ if (Tmp_win->title_height) {
+ int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
+
+ XDeleteContext(dpy, Tmp_win->title_w, TwmContext);
+ XDeleteContext(dpy, Tmp_win->title_w, ScreenContext);
+ if (Tmp_win->hilite_w) {
+ XDeleteContext(dpy, Tmp_win->hilite_w, TwmContext);
+ XDeleteContext(dpy, Tmp_win->hilite_w, ScreenContext);
+ }
+ if (Tmp_win->titlebuttons) {
+ for (i = 0; i < nb; i++) {
+ XDeleteContext(dpy, Tmp_win->titlebuttons[i].window,
+ TwmContext);
+ XDeleteContext(dpy, Tmp_win->titlebuttons[i].window,
+ ScreenContext);
+ }
}
}
if (Scr->cmapInfo.cmaps == &Tmp_win->cmaps)
- InstallWindowColormaps(DestroyNotify, &Scr->TwmRoot);
+ InstallWindowColormaps(DestroyNotify, &Scr->TwmRoot);
/*
* TwmWindows contain the following pointers
@@ -1244,54 +1226,54 @@ HandleDestroyNotify(void)
* 10. titlebuttons
* 11. window ring
*/
- if (Tmp_win->gray) XFreePixmap (dpy, Tmp_win->gray);
+ if (Tmp_win->gray)
+ XFreePixmap(dpy, Tmp_win->gray);
XDestroyWindow(dpy, Tmp_win->frame);
if (Tmp_win->icon_w && !Tmp_win->icon_not_ours) {
- XDestroyWindow(dpy, Tmp_win->icon_w);
- IconDown (Tmp_win);
+ XDestroyWindow(dpy, Tmp_win->icon_w);
+ IconDown(Tmp_win);
}
- RemoveIconManager(Tmp_win); /* 7 */
+ RemoveIconManager(Tmp_win); /* 7 */
Tmp_win->prev->next = Tmp_win->next;
if (Tmp_win->next != NULL)
- Tmp_win->next->prev = Tmp_win->prev;
- if (Tmp_win->auto_raise) Scr->NumAutoRaises--;
-
- free_window_names (Tmp_win, True, True, True); /* 1, 2, 3 */
- if (Tmp_win->wmhints) /* 4 */
- XFree (Tmp_win->wmhints);
- if (Tmp_win->class.res_name && Tmp_win->class.res_name != NoName) /* 5 */
- XFree (Tmp_win->class.res_name);
+ Tmp_win->next->prev = Tmp_win->prev;
+ if (Tmp_win->auto_raise)
+ Scr->NumAutoRaises--;
+
+ free_window_names(Tmp_win, True, True, True); /* 1, 2, 3 */
+ if (Tmp_win->wmhints) /* 4 */
+ XFree(Tmp_win->wmhints);
+ if (Tmp_win->class.res_name && Tmp_win->class.res_name != NoName) /* 5 */
+ XFree(Tmp_win->class.res_name);
if (Tmp_win->class.res_class && Tmp_win->class.res_class != NoName) /* 6 */
- XFree (Tmp_win->class.res_class);
- free_cwins (Tmp_win); /* 9 */
- if (Tmp_win->titlebuttons) /* 10 */
- free (Tmp_win->titlebuttons);
- remove_window_from_ring (Tmp_win); /* 11 */
+ XFree(Tmp_win->class.res_class);
+ free_cwins(Tmp_win); /* 9 */
+ if (Tmp_win->titlebuttons) /* 10 */
+ free(Tmp_win->titlebuttons);
+ remove_window_from_ring(Tmp_win); /* 11 */
if (UnHighLight_win == Tmp_win)
- UnHighLight_win = NULL;
+ UnHighLight_win = NULL;
free(Tmp_win);
}
-
-
void
HandleCreateNotify(void)
{
#ifdef DEBUG_EVENTS
fprintf(stderr, "CreateNotify w = 0x%x\n", Event.xcreatewindow.window);
+
fflush(stderr);
- Bell(XkbBI_Info,0,Event.xcreatewindow.window);
+ Bell(XkbBI_Info, 0, Event.xcreatewindow.window);
+
XSync(dpy, 0);
#endif
}
-
-
/**
- * HandleMapRequest - MapRequest event handler
+ * HandleMapRequest - MapRequest event handler
*/
void
HandleMapRequest(void)
@@ -1301,87 +1283,81 @@ HandleMapRequest(void)
Event.xany.window = Event.xmaprequest.window;
if (XFindContext(dpy, Event.xany.window, TwmContext, &context_data) == 0)
- Tmp_win = (TwmWindow *) context_data;
+ Tmp_win = (TwmWindow *) context_data;
+
else
- Tmp_win = NULL;
+ 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;
+ if (Tmp_win == NULL) {
+ /* Add decorations. */
+ Tmp_win = AddWindow(Event.xany.window, FALSE, (IconMgr *) NULL);
+
+ if (Tmp_win == NULL)
+ return;
}
- else
- {
- /*
- * If the window has been unmapped by the client, it won't be listed
- * in the icon manager. Add it again, if requested.
- */
- if (Tmp_win->list == NULL)
- (void) AddIconManager (Tmp_win);
+ else {
+ /*
+ * If the window has been unmapped by the client, it won't be listed
+ * in the icon manager. Add it again, if requested.
+ */
+ if (Tmp_win->list == NULL)
+ (void) AddIconManager(Tmp_win);
}
/* If it's not merely iconified, and we have hints, use them. */
- if ((! Tmp_win->icon) &&
- Tmp_win->wmhints && (Tmp_win->wmhints->flags & StateHint))
- {
- int state;
- Window icon;
-
- /* use WM_STATE if enabled */
- if (!(RestartPreviousState && GetWMState(Tmp_win->w, &state, &icon) &&
- (state == NormalState || state == IconicState)))
- state = Tmp_win->wmhints->initial_state;
-
- switch (state)
- {
- case DontCareState:
- case NormalState:
- case ZoomState:
- case InactiveState:
- XMapWindow(dpy, Tmp_win->w);
- XMapWindow(dpy, Tmp_win->frame);
- SetMapStateProp(Tmp_win, NormalState);
- SetRaiseWindow (Tmp_win);
- break;
-
- case IconicState:
- zoom_save = Scr->DoZoom;
- Scr->DoZoom = FALSE;
- Iconify(Tmp_win, 0, 0);
- Scr->DoZoom = (short)zoom_save;
- break;
- }
+ if ((!Tmp_win->icon) &&
+ Tmp_win->wmhints && (Tmp_win->wmhints->flags & StateHint)) {
+ int state;
+ Window icon;
+
+ /* use WM_STATE if enabled */
+ if (!(RestartPreviousState && GetWMState(Tmp_win->w, &state, &icon) &&
+ (state == NormalState || state == IconicState)))
+ state = Tmp_win->wmhints->initial_state;
+
+ switch (state) {
+ case DontCareState:
+ case NormalState:
+ case ZoomState:
+ case InactiveState:
+ XMapWindow(dpy, Tmp_win->w);
+ XMapWindow(dpy, Tmp_win->frame);
+ SetMapStateProp(Tmp_win, NormalState);
+ SetRaiseWindow(Tmp_win);
+ break;
+
+ case IconicState:
+ zoom_save = Scr->DoZoom;
+ Scr->DoZoom = FALSE;
+ Iconify(Tmp_win, 0, 0);
+ Scr->DoZoom = (short) zoom_save;
+ break;
+ }
}
/* If no hints, or currently an icon, just "deiconify" */
- else
- {
- DeIconify(Tmp_win);
- SetRaiseWindow (Tmp_win);
+ else {
+ DeIconify(Tmp_win);
+ SetRaiseWindow(Tmp_win);
}
}
-
-
void
-SimulateMapRequest (Window w)
+SimulateMapRequest(Window w)
{
Event.xmaprequest.window = w;
- HandleMapRequest ();
-}
-
+ HandleMapRequest();
+}
/**
- * MapNotify event handler
+ * MapNotify event handler
*/
void
HandleMapNotify(void)
{
if (Tmp_win == NULL)
- return;
+ return;
/*
* Need to do the grab to avoid race condition of having server send
@@ -1389,25 +1365,23 @@ HandleMapNotify(void)
* the client would think that the window has a chance of being viewable
* when it really isn't.
*/
- XGrabServer (dpy);
+ XGrabServer(dpy);
if (Tmp_win->icon_w)
- XUnmapWindow(dpy, 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->title_w);
XMapSubwindows(dpy, Tmp_win->frame);
if (Scr->Focus != Tmp_win && Tmp_win->hilite_w)
- XUnmapWindow(dpy, Tmp_win->hilite_w);
+ XUnmapWindow(dpy, Tmp_win->hilite_w);
XMapWindow(dpy, Tmp_win->frame);
- XUngrabServer (dpy);
- XFlush (dpy);
+ XUngrabServer(dpy);
+ XFlush(dpy);
Tmp_win->mapped = TRUE;
Tmp_win->icon = FALSE;
Tmp_win->icon_on = FALSE;
}
-
-
/**
* UnmapNotify event handler
*/
@@ -1426,18 +1400,18 @@ HandleUnmapNotify(void)
* 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, &context_data) == 0)
- Tmp_win = (TwmWindow *) context_data;
- else
- Tmp_win = NULL;
+ if (Tmp_win == NULL) {
+ Event.xany.window = Event.xunmap.window;
+ if (XFindContext(dpy, Event.xany.window,
+ TwmContext, &context_data) == 0)
+ Tmp_win = (TwmWindow *) context_data;
+
+ else
+ Tmp_win = NULL;
}
if (Tmp_win == NULL || (!Tmp_win->mapped && !Tmp_win->icon))
- return;
+ return;
/*
* The program may have unmapped the client window, from either
@@ -1448,33 +1422,35 @@ HandleUnmapNotify(void)
* that we've received a DestroyNotify).
*/
- XGrabServer (dpy);
- if (XTranslateCoordinates (dpy, Event.xunmap.window, Tmp_win->attr.root,
- 0, 0, &dstx, &dsty, &dumwin)) {
- XEvent ev;
- Bool reparented = XCheckTypedWindowEvent (dpy, Event.xunmap.window,
- ReparentNotify, &ev);
- SetMapStateProp (Tmp_win, WithdrawnState);
- if (reparented) {
- if (Tmp_win->old_bw) XSetWindowBorderWidth (dpy,
- Event.xunmap.window,
- (unsigned)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);
-}
+ XGrabServer(dpy);
+ if (XTranslateCoordinates(dpy, Event.xunmap.window, Tmp_win->attr.root,
+ 0, 0, &dstx, &dsty, &dumwin)) {
+ XEvent ev;
+ Bool reparented = XCheckTypedWindowEvent(dpy, Event.xunmap.window,
+ ReparentNotify, &ev);
+
+ SetMapStateProp(Tmp_win, WithdrawnState);
+ if (reparented) {
+ if (Tmp_win->old_bw)
+ XSetWindowBorderWidth(dpy,
+ Event.xunmap.window,
+ (unsigned) 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);
+}
/**
* MotionNotify event handler
@@ -1484,28 +1460,24 @@ HandleMotionNotify(void)
{
XPointer context_data;
- 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);
+ 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;
+ /* 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;
- if (XFindContext(dpy, ResizeWindow, TwmContext, &context_data) == 0)
- Tmp_win = (TwmWindow *) context_data;
- DoResize(Event.xmotion.x_root, Event.xmotion.y_root, Tmp_win);
+ if (XFindContext(dpy, ResizeWindow, TwmContext, &context_data) == 0)
+ Tmp_win = (TwmWindow *) context_data;
+ DoResize(Event.xmotion.x_root, Event.xmotion.y_root, Tmp_win);
}
}
-
-
/**
* ButtonRelease event handler
*/
@@ -1516,207 +1488,198 @@ HandleButtonRelease(void)
unsigned mask;
XPointer context_data;
- 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);
-
- if (XFindContext(dpy, DragWindow, TwmContext, &context_data) == 0)
- Tmp_win = (TwmWindow *) context_data;
- if (DragWindow == Tmp_win->frame)
- {
- xl = Event.xbutton.x_root - DragX - Tmp_win->frame_bw;
- yt = Event.xbutton.y_root - DragY - Tmp_win->frame_bw;
- w = DragWidth + 2 * Tmp_win->frame_bw;
- h = DragHeight + 2 * Tmp_win->frame_bw;
- }
- else
- {
- xl = Event.xbutton.x_root - DragX - Scr->IconBorderWidth;
- yt = Event.xbutton.y_root - DragY - Scr->IconBorderWidth;
- w = DragWidth + 2 * Scr->IconBorderWidth;
- h = DragHeight + 2 * Scr->IconBorderWidth;
- }
-
- if (ConstMove)
- {
- if (ConstMoveDir == MOVE_HORIZ)
- yt = ConstMoveY;
-
- if (ConstMoveDir == MOVE_VERT)
- xl = ConstMoveX;
-
- if (ConstMoveDir == MOVE_NONE)
- {
- yt = ConstMoveY;
- xl = ConstMoveX;
- }
- }
-
- if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE)
- {
- xr = xl + w;
- yb = yt + h;
-
- if (xl < 0)
- xl = 0;
- if (xr > Scr->MyDisplayWidth)
- xl = Scr->MyDisplayWidth - w;
-
- if (yt < 0)
- yt = 0;
- if (yb > Scr->MyDisplayHeight)
- yt = Scr->MyDisplayHeight - h;
- }
-
- CurrentDragX = xl;
- CurrentDragY = yt;
- if (DragWindow == Tmp_win->frame)
- SetupWindow (Tmp_win, xl, yt,
- Tmp_win->frame_width, Tmp_win->frame_height, -1);
- else
- XMoveWindow (dpy, DragWindow, xl, yt);
-
- if (!Scr->NoRaiseMove && !Scr->OpaqueMove) /* opaque already did */
- XRaiseWindow(dpy, DragWindow);
-
- if (!Scr->OpaqueMove)
- UninstallRootColormap();
- else
- XSync(dpy, 0);
-
- if (Scr->NumAutoRaises) {
- enter_flag = TRUE;
- enter_win = NULL;
- raise_win = ((DragWindow == Tmp_win->frame && !Scr->NoRaiseMove)
- ? Tmp_win : NULL);
- }
-
- DragWindow = (Window) 0;
- ConstMove = FALSE;
- }
-
- if (ResizeWindow != (Window) 0)
- {
- EndResize();
- }
-
- if (ActiveMenu != NULL && RootFunction == 0)
- {
- if (ActiveItem != NULL)
- {
- int func = ActiveItem->func;
- Action = ActiveItem->action;
- switch (func) {
- case F_MOVE:
- case F_FORCEMOVE:
- ButtonPressed = -1;
- break;
- case F_WARPTOSCREEN:
- XUngrabPointer(dpy, CurrentTime);
- /* fall through */
- case F_CIRCLEUP:
- case F_CIRCLEDOWN:
- case F_REFRESH:
- PopDownMenu();
- break;
- default:
- break;
- }
- ExecuteFunction(func, Action,
- ButtonWindow ? ButtonWindow->frame : None,
- ButtonWindow, &Event/*&ButtonEvent*/, Context, TRUE);
- Context = C_NO_CONTEXT;
- ButtonWindow = NULL;
-
- /* if we are not executing a defered command, then take down the
- * menu
- */
- if (RootFunction == 0)
- {
- PopDownMenu();
- }
- }
- else
- PopDownMenu();
- }
-
- mask = (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask);
- switch (Event.xbutton.button)
- {
- case Button1: mask &= (unsigned)(~Button1Mask); break;
- case Button2: mask &= (unsigned)(~Button2Mask); break;
- case Button3: mask &= (unsigned)(~Button3Mask); break;
- case Button4: mask &= (unsigned)(~Button4Mask); break;
- case Button5: mask &= (unsigned)(~Button5Mask); break;
- }
-
- if (RootFunction != 0 ||
- ResizeWindow != None ||
- DragWindow != None)
- ButtonPressed = -1;
+ 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);
+
+ if (XFindContext(dpy, DragWindow, TwmContext, &context_data) == 0)
+ Tmp_win = (TwmWindow *) context_data;
+ if (DragWindow == Tmp_win->frame) {
+ xl = Event.xbutton.x_root - DragX - Tmp_win->frame_bw;
+ yt = Event.xbutton.y_root - DragY - Tmp_win->frame_bw;
+
+ w = DragWidth + 2 * Tmp_win->frame_bw;
+ h = DragHeight + 2 * Tmp_win->frame_bw;
+ }
+ else {
+ xl = Event.xbutton.x_root - DragX - Scr->IconBorderWidth;
+ yt = Event.xbutton.y_root - DragY - Scr->IconBorderWidth;
+
+ w = DragWidth + 2 * Scr->IconBorderWidth;
+ h = DragHeight + 2 * Scr->IconBorderWidth;
+ }
+
+ if (ConstMove) {
+ if (ConstMoveDir == MOVE_HORIZ)
+ yt = ConstMoveY;
+
+ if (ConstMoveDir == MOVE_VERT)
+ xl = ConstMoveX;
+
+ if (ConstMoveDir == MOVE_NONE) {
+ yt = ConstMoveY;
+ xl = ConstMoveX;
+ }
+ }
+
+ if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) {
+ xr = xl + w;
+ yb = yt + h;
+
+ if (xl < 0)
+ xl = 0;
+ if (xr > Scr->MyDisplayWidth)
+ xl = Scr->MyDisplayWidth - w;
+
+ if (yt < 0)
+ yt = 0;
+ if (yb > Scr->MyDisplayHeight)
+ yt = Scr->MyDisplayHeight - h;
+ }
+
+ CurrentDragX = xl;
+ CurrentDragY = yt;
+ if (DragWindow == Tmp_win->frame)
+ SetupWindow(Tmp_win, xl, yt,
+ Tmp_win->frame_width, Tmp_win->frame_height, -1);
+ else
+ XMoveWindow(dpy, DragWindow, xl, yt);
+
+ if (!Scr->NoRaiseMove && !Scr->OpaqueMove) /* opaque already did */
+ XRaiseWindow(dpy, DragWindow);
+
+ if (!Scr->OpaqueMove)
+ UninstallRootColormap();
+ else
+ XSync(dpy, 0);
+
+ if (Scr->NumAutoRaises) {
+ enter_flag = TRUE;
+ enter_win = NULL;
+ raise_win = ((DragWindow == Tmp_win->frame && !Scr->NoRaiseMove)
+ ? Tmp_win : NULL);
+ }
+
+ DragWindow = (Window) 0;
+ ConstMove = FALSE;
+ }
+
+ if (ResizeWindow != (Window) 0) {
+ EndResize();
+ }
+
+ if (ActiveMenu != NULL && RootFunction == 0) {
+ if (ActiveItem != NULL) {
+ int func = ActiveItem->func;
+
+ Action = ActiveItem->action;
+ switch (func) {
+ case F_MOVE:
+ case F_FORCEMOVE:
+ ButtonPressed = -1;
+ break;
+ case F_WARPTOSCREEN:
+ XUngrabPointer(dpy, CurrentTime);
+ /* fall through */
+ case F_CIRCLEUP:
+ case F_CIRCLEDOWN:
+ case F_REFRESH:
+ PopDownMenu();
+ break;
+ default:
+ break;
+ }
+ ExecuteFunction(func, Action,
+ ButtonWindow ? ButtonWindow->frame : None,
+ ButtonWindow, &Event /*&ButtonEvent */ , Context,
+ TRUE);
+
+ Context = C_NO_CONTEXT;
+ ButtonWindow = NULL;
+
+ /* if we are not executing a defered command, then take down the
+ * menu
+ */
+ if (RootFunction == 0) {
+ PopDownMenu();
+ }
+ }
+ else
+ PopDownMenu();
+ }
+
+ mask =
+ (Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask);
+ switch (Event.xbutton.button) {
+ /* *INDENT-OFF* */
+ case Button1: mask &= (unsigned)(~Button1Mask); break;
+ case Button2: mask &= (unsigned)(~Button2Mask); break;
+ case Button3: mask &= (unsigned)(~Button3Mask); break;
+ case Button4: mask &= (unsigned)(~Button4Mask); break;
+ case Button5: mask &= (unsigned)(~Button5Mask); break;
+ /* *INDENT-ON* */
+ }
+
+ if (RootFunction != 0 || ResizeWindow != None || DragWindow != None)
+ ButtonPressed = -1;
if (RootFunction == 0 &&
- (Event.xbutton.state & mask) == 0 &&
- DragWindow == None &&
- 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;
+ (Event.xbutton.state & mask) == 0 &&
+ DragWindow == None && 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 (MenuRoot *menu, Window w)
+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);
+ XGrabServer(dpy);
if (w) {
- int h = Scr->TBInfo.width - Scr->TBInfo.border;
- Window child;
+ 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;
+ (void) XTranslateCoordinates(dpy, w, Scr->Root, 0, h, &x, &y, &child);
+ center = False;
}
- if (PopUpMenu (menu, x, y, center)) {
- UpdateMenu();
- } else {
- Bell(XkbBI_MinorError,0,w);
+ else {
+ center = True;
+ }
+ if (PopUpMenu(menu, x, y, center)) {
+ UpdateMenu();
+ }
+ else {
+ Bell(XkbBI_MinorError, 0, w);
}
}
-
-
/**
* ButtonPress event handler
*/
@@ -1728,194 +1691,188 @@ HandleButtonPress(void)
/* too much code relies on this assumption */
if (Event.xbutton.button > MAX_BUTTONS)
- return;
+ 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
- * down, we need to cancel the operation we were doing
- */
- Cancel = TRUE;
- CurrentDragX = origDragX;
- CurrentDragY = origDragY;
- if (!menuFromFrameOrWindowOrTitlebar) {
- if (Scr->OpaqueMove && DragWindow != None) {
- XMoveWindow (dpy, DragWindow, origDragX, origDragY);
- } else {
- MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
- }
- }
- XUnmapWindow(dpy, Scr->SizeWindow);
- if (!Scr->OpaqueMove)
- UninstallRootColormap();
- ResizeWindow = None;
- DragWindow = None;
- cur = LeftButt;
- if (Event.xbutton.button == Button2)
- cur = MiddleButt;
- else if (Event.xbutton.button >= Button3)
- cur = RightButt;
-
- XGrabPointer(dpy, Scr->Root, True,
- ButtonReleaseMask | ButtonPressMask,
- GrabModeAsync, GrabModeAsync,
- Scr->Root, cur, CurrentTime);
-
- return;
+ 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
+ * down, we need to cancel the operation we were doing
+ */
+ Cancel = TRUE;
+ CurrentDragX = origDragX;
+ CurrentDragY = origDragY;
+ if (!menuFromFrameOrWindowOrTitlebar) {
+ if (Scr->OpaqueMove && DragWindow != None) {
+ XMoveWindow(dpy, DragWindow, origDragX, origDragY);
+ }
+ else {
+ MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
+ }
+ }
+ XUnmapWindow(dpy, Scr->SizeWindow);
+ if (!Scr->OpaqueMove)
+ UninstallRootColormap();
+ ResizeWindow = None;
+ DragWindow = None;
+ cur = LeftButt;
+ if (Event.xbutton.button == Button2)
+ cur = MiddleButt;
+ else if (Event.xbutton.button >= Button3)
+ cur = RightButt;
+
+ XGrabPointer(dpy, Scr->Root, True,
+ ButtonReleaseMask | ButtonPressMask,
+ GrabModeAsync, GrabModeAsync, Scr->Root, cur, CurrentTime);
+
+ return;
}
else
- ButtonPressed = (int)Event.xbutton.button;
+ ButtonPressed = (int) Event.xbutton.button;
- if (ResizeWindow != None ||
- DragWindow != None ||
- ActiveMenu != NULL)
- return;
+ if (ResizeWindow != None || DragWindow != None || ActiveMenu != NULL)
+ return;
/* check the title bar buttons */
- if (Tmp_win && Tmp_win->title_height && Tmp_win->titlebuttons)
- {
- register int i;
- register TBWindow *tbw;
- int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
-
- for (i = 0, tbw = Tmp_win->titlebuttons; i < nb; i++, tbw++) {
- if (Event.xany.window == tbw->window) {
- if (tbw->info->func == F_MENU) {
- Context = C_TITLE;
- ButtonEvent = Event;
- ButtonWindow = Tmp_win;
- do_menu (tbw->info->menuroot, tbw->window);
- } else {
- ExecuteFunction (tbw->info->func, tbw->info->action,
- Event.xany.window, Tmp_win, &Event,
- C_TITLE, FALSE);
- }
- return;
- }
- }
+ if (Tmp_win && Tmp_win->title_height && Tmp_win->titlebuttons) {
+ register int i;
+ register TBWindow *tbw;
+ int nb = Scr->TBInfo.nleft + Scr->TBInfo.nright;
+
+ for (i = 0, tbw = Tmp_win->titlebuttons; i < nb; i++, tbw++) {
+ if (Event.xany.window == tbw->window) {
+ if (tbw->info->func == F_MENU) {
+ Context = C_TITLE;
+ ButtonEvent = Event;
+
+ ButtonWindow = Tmp_win;
+ do_menu(tbw->info->menuroot, tbw->window);
+ }
+ else {
+ ExecuteFunction(tbw->info->func, tbw->info->action,
+ Event.xany.window, Tmp_win, &Event,
+ C_TITLE, FALSE);
+ }
+ return;
+ }
+ }
}
Context = C_NO_CONTEXT;
if (Event.xany.window == Scr->InfoWindow)
- Context = C_IDENTIFY;
+ Context = C_IDENTIFY;
if (Event.xany.window == Scr->Root)
- Context = C_ROOT;
- if (Tmp_win)
- {
- if (Tmp_win->list && RootFunction != 0 &&
- (Event.xany.window == Tmp_win->list->w ||
- Event.xany.window == Tmp_win->list->icon))
- {
- Tmp_win = Tmp_win->list->iconmgr->twm_win;
- XTranslateCoordinates(dpy, Event.xany.window, Tmp_win->w,
- Event.xbutton.x, Event.xbutton.y,
- &JunkX, &JunkY, &JunkChild);
-
- Event.xbutton.x = JunkX;
- Event.xbutton.y = JunkY - Tmp_win->title_height;
- Event.xany.window = Tmp_win->w;
- Context = C_WINDOW;
- }
- else if (Event.xany.window == Tmp_win->title_w)
- {
- Context = C_TITLE;
- }
- else if (Event.xany.window == Tmp_win->w)
- {
- printf("ERROR! ERROR! ERROR! YOU SHOULD NOT BE HERE!!!\n");
- Context = C_WINDOW;
- }
- else if (Event.xany.window == Tmp_win->icon_w)
- {
- Context = C_ICON;
- }
- else if (Event.xany.window == Tmp_win->frame)
- {
- /* since we now place a button grab on the frame instead
+ Context = C_ROOT;
+ if (Tmp_win) {
+ if (Tmp_win->list && RootFunction != 0 &&
+ (Event.xany.window == Tmp_win->list->w ||
+ Event.xany.window == Tmp_win->list->icon)) {
+ Tmp_win = Tmp_win->list->iconmgr->twm_win;
+ XTranslateCoordinates(dpy, Event.xany.window, Tmp_win->w,
+ Event.xbutton.x, Event.xbutton.y,
+ &JunkX, &JunkY, &JunkChild);
+
+ Event.xbutton.x = JunkX;
+ Event.xbutton.y = JunkY - Tmp_win->title_height;
+ Event.xany.window = Tmp_win->w;
+
+ Context = C_WINDOW;
+ }
+ else if (Event.xany.window == Tmp_win->title_w) {
+ Context = C_TITLE;
+ }
+ else if (Event.xany.window == Tmp_win->w) {
+ printf("ERROR! ERROR! ERROR! YOU SHOULD NOT BE HERE!!!\n");
+ Context = C_WINDOW;
+ }
+ else if (Event.xany.window == Tmp_win->icon_w) {
+ Context = C_ICON;
+ }
+ else if (Event.xany.window == Tmp_win->frame) {
+ /* since we now place a button grab on the frame instead
* of the window, (see GrabButtons() in add_window.c), we
* need to figure out where the pointer exactly is before
* assigning Context. If the pointer is on the application
* window we will change the event structure to look as if
* it came from the application window.
- */
- if (Event.xbutton.subwindow == Tmp_win->w) {
- Event.xbutton.window = Tmp_win->w;
- Event.xbutton.y -= Tmp_win->title_height;
+ */
+ if (Event.xbutton.subwindow == Tmp_win->w) {
+ Event.xbutton.window = Tmp_win->w;
+ Event.xbutton.y -= Tmp_win->title_height;
+
/*****
Event.xbutton.x -= Tmp_win->frame_bw;
*****/
- Context = C_WINDOW;
- }
- else Context = C_FRAME;
- }
- else if (Tmp_win->list &&
- (Event.xany.window == Tmp_win->list->w ||
- Event.xany.window == Tmp_win->list->icon))
- {
- Tmp_win->list->down = TRUE;
- if (Scr->Highlight) DrawIconManagerBorder(Tmp_win->list);
- DownIconManager = Tmp_win->list;
- Context = C_ICONMGR;
- }
+ Context = C_WINDOW;
+ }
+ else
+ Context = C_FRAME;
+ }
+ else if (Tmp_win->list &&
+ (Event.xany.window == Tmp_win->list->w ||
+ Event.xany.window == Tmp_win->list->icon)) {
+ Tmp_win->list->down = TRUE;
+ if (Scr->Highlight)
+ DrawIconManagerBorder(Tmp_win->list);
+ DownIconManager = Tmp_win->list;
+ Context = C_ICONMGR;
+ }
}
/* this section of code checks to see if we were in the middle of
* a command executed from a menu
*/
- if (RootFunction != 0)
- {
- if (Event.xany.window == Scr->Root)
- {
- /* if the window was the Root, we don't know for sure it
- * it was the root. We must check to see if it happened to be
- * inside of a client that was getting button press events.
- */
- XPointer context_data;
-
- XTranslateCoordinates(dpy, Scr->Root, Scr->Root,
- Event.xbutton.x,
- Event.xbutton.y,
- &JunkX, &JunkY, &Event.xany.window);
-
- if (Event.xany.window == 0 ||
- (XFindContext(dpy, Event.xany.window, TwmContext,
- &context_data) == XCNOENT))
- {
- RootFunction = 0;
- Bell(XkbBI_MinorError,0,Event.xany.window);
- return;
- }
- else
- Tmp_win = (TwmWindow *) context_data;
-
- XTranslateCoordinates(dpy, Scr->Root, Event.xany.window,
- Event.xbutton.x,
- Event.xbutton.y,
- &JunkX, &JunkY, &JunkChild);
-
- Event.xbutton.x = JunkX;
- Event.xbutton.y = JunkY;
- Context = C_WINDOW;
- }
-
- /* make sure we are not trying to move an identify window */
- if (Event.xany.window != Scr->InfoWindow)
- ExecuteFunction(RootFunction, Action, Event.xany.window,
- Tmp_win, &Event, Context, FALSE);
-
- RootFunction = 0;
- return;
+ if (RootFunction != 0) {
+ if (Event.xany.window == Scr->Root) {
+ /* if the window was the Root, we don't know for sure it
+ * it was the root. We must check to see if it happened to be
+ * inside of a client that was getting button press events.
+ */
+ XPointer context_data;
+
+ XTranslateCoordinates(dpy, Scr->Root, Scr->Root,
+ Event.xbutton.x,
+ Event.xbutton.y,
+ &JunkX, &JunkY, &Event.xany.window);
+
+ if (Event.xany.window == 0 ||
+ (XFindContext(dpy, Event.xany.window, TwmContext,
+ &context_data) == XCNOENT)) {
+ RootFunction = 0;
+ Bell(XkbBI_MinorError, 0, Event.xany.window);
+
+ return;
+ }
+ else
+ Tmp_win = (TwmWindow *) context_data;
+
+ XTranslateCoordinates(dpy, Scr->Root, Event.xany.window,
+ Event.xbutton.x,
+ Event.xbutton.y, &JunkX, &JunkY, &JunkChild);
+
+ Event.xbutton.x = JunkX;
+ Event.xbutton.y = JunkY;
+
+ Context = C_WINDOW;
+ }
+
+ /* make sure we are not trying to move an identify window */
+ if (Event.xany.window != Scr->InfoWindow)
+ ExecuteFunction(RootFunction, Action, Event.xany.window,
+ Tmp_win, &Event, Context, FALSE);
+
+ RootFunction = 0;
+ return;
}
ButtonEvent = Event;
+
ButtonWindow = Tmp_win;
/* if we get to here, we have to execute a function or pop up a
@@ -1924,77 +1881,72 @@ HandleButtonPress(void)
modifier = (Event.xbutton.state & mods_used);
if (Context == C_NO_CONTEXT)
- return;
+ return;
RootFunction = 0;
- if (Scr->Mouse[Event.xbutton.button][Context][modifier].func == F_MENU)
- {
- do_menu (Scr->Mouse[Event.xbutton.button][Context][modifier].menu,
- (Window) None);
- }
- else if (Scr->Mouse[Event.xbutton.button][Context][modifier].func != 0)
- {
- Action = Scr->Mouse[Event.xbutton.button][Context][modifier].item ?
- Scr->Mouse[Event.xbutton.button][Context][modifier].item->action : NULL;
- ExecuteFunction(Scr->Mouse[Event.xbutton.button][Context][modifier].func,
- 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);
- }
+ if (Scr->Mouse[Event.xbutton.button][Context][modifier].func == F_MENU) {
+ do_menu(Scr->Mouse[Event.xbutton.button][Context][modifier].menu,
+ (Window) None);
+ }
+ else if (Scr->Mouse[Event.xbutton.button][Context][modifier].func != 0) {
+ Action = Scr->Mouse[Event.xbutton.button][Context][modifier].item ?
+ Scr->Mouse[Event.xbutton.button][Context][modifier].
+ item->action : NULL;
+ ExecuteFunction(Scr->
+ Mouse[Event.xbutton.button][Context][modifier].func,
+ 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);
+ }
}
}
-
-
/** \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.
+ * 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;
static Bool
HENQueueScanner(Display *dpy2 _X_UNUSED, 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;
+ 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);
}
-
-
/**
* EnterNotify event handler
*/
@@ -2012,177 +1964,178 @@ HandleEnterNotify(void)
* 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);
+ 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;
+ UnHighLight_win = NULL;
else if (Tmp_win)
- UnHighLight_win = Tmp_win;
+ UnHighLight_win = Tmp_win;
/*
* if we aren't in the middle of menu processing
*/
if (!ActiveMenu) {
- /*
- * We're not interested in pseudo Enter/Leave events generated
- * from grab initiations.
- */
- if (ewp->mode == NotifyGrab)
- return;
-
- /*
- * Scan for Leave and Enter Notify events to see if we can avoid some
- * unnecessary processing.
- */
- scanArgs.w = ewp->window;
- scanArgs.leaves = scanArgs.enters = False;
- (void) XCheckIfEvent(dpy, &dummy, HENQueueScanner, (char *) &scanArgs);
-
- /*
- * if entering root window, restore twm default colormap so that
- * titlebars are legible
- */
- if (ewp->window == Scr->Root) {
- if (!scanArgs.leaves && !scanArgs.enters)
- InstallWindowColormaps(EnterNotify, &Scr->TwmRoot);
- return;
- }
-
- /*
- * if we have an event for a specific one of our windows
- */
- if (Tmp_win) {
- /*
- * If currently in PointerRoot mode (indicated by FocusRoot), then
- * focus on this window
- */
- if (Scr->FocusRoot && (!scanArgs.leaves || scanArgs.inferior)) {
- if (Tmp_win->list) ActiveIconManager(Tmp_win->list);
- if (Tmp_win->mapped) {
- /*
- * unhighlight old focus window
- */
- if (Scr->Focus &&
- Scr->Focus != Tmp_win && Tmp_win->hilite_w)
- XUnmapWindow(dpy, Scr->Focus->hilite_w);
-
- /*
- * If entering the frame or the icon manager, then do
- * "window activation things":
- *
- * 1. turn on highlight window (if any)
- * 2. install frame colormap
- * 3. set frame and highlight window (if any) border
- * 4. focus on client window to forward typing
- * 4a. same as 4 but for icon mgr w/with NoTitlebar on.
- * 5. send WM_TAKE_FOCUS if requested
- */
- if (ewp->window == Tmp_win->frame ||
- (Tmp_win->list && ewp->window == Tmp_win->list->w)) {
- if (Tmp_win->hilite_w) /* 1 */
- XMapWindow (dpy, Tmp_win->hilite_w);
- if (!scanArgs.leaves && !scanArgs.enters)
- InstallWindowColormaps (EnterNotify, /* 2 */
- &Scr->TwmRoot);
- SetBorder (Tmp_win, True); /* 3 */
- if (Tmp_win->title_w && Scr->TitleFocus && /* 4 */
- Tmp_win->wmhints && Tmp_win->wmhints->input)
- SetFocus (Tmp_win, ewp->time);
- if (Scr->NoTitlebar && Scr->TitleFocus && /*4a */
- Tmp_win->wmhints && Tmp_win->wmhints->input)
- SetFocus (Tmp_win, ewp->time);
- if (Tmp_win->protocols & DoesWmTakeFocus) /* 5 */
- SendTakeFocusMessage (Tmp_win, ewp->time);
- Scr->Focus = Tmp_win;
- } else if (ewp->window == Tmp_win->w) {
- /*
- * If we are entering the application window, install
- * its colormap(s).
- */
- if (!scanArgs.leaves || scanArgs.inferior)
- InstallWindowColormaps(EnterNotify, Tmp_win);
- }
- } /* end if Tmp_win->mapped */
- if (Tmp_win->wmhints != NULL &&
- ewp->window == Tmp_win->wmhints->icon_window &&
- (!scanArgs.leaves || scanArgs.inferior))
- InstallWindowColormaps(EnterNotify, Tmp_win);
- } /* end if FocusRoot */
- /*
- * If this window is to be autoraised, mark it so
- */
- if (Tmp_win->auto_raise) {
- enter_win = Tmp_win;
- if (enter_flag == FALSE) AutoRaiseWindow (Tmp_win);
- } else if (enter_flag && raise_win == Tmp_win)
- enter_win = Tmp_win;
- /*
- * set ring leader
- */
- if (Tmp_win->ring.next && (!enter_flag || raise_win == enter_win))
- Scr->RingLeader = Tmp_win;
- XSync (dpy, 0);
- return;
- } /* end if Tmp_win */
- } /* end if !ActiveMenu */
+ /*
+ * We're not interested in pseudo Enter/Leave events generated
+ * from grab initiations.
+ */
+ if (ewp->mode == NotifyGrab)
+ return;
+
+ /*
+ * Scan for Leave and Enter Notify events to see if we can avoid some
+ * unnecessary processing.
+ */
+ scanArgs.w = ewp->window;
+ scanArgs.leaves = scanArgs.enters = False;
+ (void) XCheckIfEvent(dpy, &dummy, HENQueueScanner, (char *) &scanArgs);
+
+ /*
+ * if entering root window, restore twm default colormap so that
+ * titlebars are legible
+ */
+ if (ewp->window == Scr->Root) {
+ if (!scanArgs.leaves && !scanArgs.enters)
+ InstallWindowColormaps(EnterNotify, &Scr->TwmRoot);
+ return;
+ }
+
+ /*
+ * if we have an event for a specific one of our windows
+ */
+ if (Tmp_win) {
+ /*
+ * If currently in PointerRoot mode (indicated by FocusRoot), then
+ * focus on this window
+ */
+ if (Scr->FocusRoot && (!scanArgs.leaves || scanArgs.inferior)) {
+ if (Tmp_win->list)
+ ActiveIconManager(Tmp_win->list);
+ if (Tmp_win->mapped) {
+ /*
+ * unhighlight old focus window
+ */
+ if (Scr->Focus &&
+ Scr->Focus != Tmp_win && Tmp_win->hilite_w)
+ XUnmapWindow(dpy, Scr->Focus->hilite_w);
+
+ /*
+ * If entering the frame or the icon manager, then do
+ * "window activation things":
+ *
+ * 1. turn on highlight window (if any)
+ * 2. install frame colormap
+ * 3. set frame and highlight window (if any) border
+ * 4. focus on client window to forward typing
+ * 4a. same as 4 but for icon mgr w/with NoTitlebar on.
+ * 5. send WM_TAKE_FOCUS if requested
+ */
+ if (ewp->window == Tmp_win->frame ||
+ (Tmp_win->list && ewp->window == Tmp_win->list->w)) {
+ if (Tmp_win->hilite_w) /* 1 */
+ XMapWindow(dpy, Tmp_win->hilite_w);
+ if (!scanArgs.leaves && !scanArgs.enters)
+ InstallWindowColormaps(EnterNotify, /* 2 */
+ &Scr->TwmRoot);
+ SetBorder(Tmp_win, True); /* 3 */
+ if (Tmp_win->title_w && Scr->TitleFocus && /* 4 */
+ Tmp_win->wmhints && Tmp_win->wmhints->input)
+ SetFocus(Tmp_win, ewp->time);
+ if (Scr->NoTitlebar && Scr->TitleFocus && /*4a */
+ Tmp_win->wmhints && Tmp_win->wmhints->input)
+ SetFocus(Tmp_win, ewp->time);
+ if (Tmp_win->protocols & DoesWmTakeFocus) /* 5 */
+ SendTakeFocusMessage(Tmp_win, ewp->time);
+ Scr->Focus = Tmp_win;
+ }
+ else if (ewp->window == Tmp_win->w) {
+ /*
+ * If we are entering the application window, install
+ * its colormap(s).
+ */
+ if (!scanArgs.leaves || scanArgs.inferior)
+ InstallWindowColormaps(EnterNotify, Tmp_win);
+ }
+ } /* end if Tmp_win->mapped */
+ if (Tmp_win->wmhints != NULL &&
+ ewp->window == Tmp_win->wmhints->icon_window &&
+ (!scanArgs.leaves || scanArgs.inferior))
+ InstallWindowColormaps(EnterNotify, Tmp_win);
+ } /* end if FocusRoot */
+ /*
+ * If this window is to be autoraised, mark it so
+ */
+ if (Tmp_win->auto_raise) {
+ enter_win = Tmp_win;
+ if (enter_flag == FALSE)
+ AutoRaiseWindow(Tmp_win);
+ }
+ else if (enter_flag && raise_win == Tmp_win)
+ enter_win = Tmp_win;
+ /*
+ * set ring leader
+ */
+ if (Tmp_win->ring.next && (!enter_flag || raise_win == enter_win))
+ Scr->RingLeader = Tmp_win;
+ XSync(dpy, 0);
+ return;
+ } /* end if Tmp_win */
+ } /* end if !ActiveMenu */
/*
* Find the menu that we are dealing with now; punt if unknown
*/
- if (XFindContext (dpy, ewp->window, MenuContext, &context_data) == 0)
- mr = (MenuRoot *) context_data;
+ if (XFindContext(dpy, ewp->window, MenuContext, &context_data) == 0)
+ mr = (MenuRoot *) context_data;
else
- return;
+ return;
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--;
+ 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;
}
-
-
/** \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.
+ * 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;
static Bool
HLNQueueScanner(Display *dpy2 _X_UNUSED, 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;
+ ((HLNScanArgs *) args)->enters = True;
+ if (ev->xcrossing.window == ((HLNScanArgs *) args)->w)
+ ((HLNScanArgs *) args)->matches = True;
}
return (False);
}
-
-
/**
* LeaveNotify event handler
*/
@@ -2192,74 +2145,74 @@ HandleLeaveNotify(void)
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);
-
- if (Scr->RingLeader && Scr->RingLeader == Tmp_win &&
- (Event.xcrossing.detail != NotifyInferior &&
- Event.xcrossing.window != Tmp_win->w)) {
- if (!inicon) {
- if (Tmp_win->mapped) {
- Tmp_win->ring.cursor_valid = False;
- } else {
- Tmp_win->ring.cursor_valid = True;
- Tmp_win->ring.curs_x = (Event.xcrossing.x_root -
- Tmp_win->frame_x);
- Tmp_win->ring.curs_y = (Event.xcrossing.y_root -
- Tmp_win->frame_y);
- }
- }
- Scr->RingLeader = (TwmWindow *) NULL;
- }
- if (Scr->FocusRoot) {
-
- if (Event.xcrossing.detail != NotifyInferior) {
-
- /*
- * Scan for EnterNotify events to see if we can avoid some
- * unnecessary processing.
- */
- scanArgs.w = Event.xcrossing.window;
- scanArgs.enters = scanArgs.matches = False;
- (void) XCheckIfEvent(dpy, &dummy, HLNQueueScanner,
- (char *) &scanArgs);
-
- if ((Event.xcrossing.window == Tmp_win->frame &&
- !scanArgs.matches) || inicon) {
- if (Tmp_win->list) NotActiveIconManager(Tmp_win->list);
- 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;
+ 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);
+
+ if (Scr->RingLeader && Scr->RingLeader == Tmp_win &&
+ (Event.xcrossing.detail != NotifyInferior &&
+ Event.xcrossing.window != Tmp_win->w)) {
+ if (!inicon) {
+ if (Tmp_win->mapped) {
+ Tmp_win->ring.cursor_valid = False;
+ }
+ else {
+ Tmp_win->ring.cursor_valid = True;
+ Tmp_win->ring.curs_x = (Event.xcrossing.x_root -
+ Tmp_win->frame_x);
+ Tmp_win->ring.curs_y = (Event.xcrossing.y_root -
+ Tmp_win->frame_y);
+ }
+ }
+ Scr->RingLeader = (TwmWindow *) NULL;
+ }
+ if (Scr->FocusRoot) {
+
+ if (Event.xcrossing.detail != NotifyInferior) {
+
+ /*
+ * Scan for EnterNotify events to see if we can avoid some
+ * unnecessary processing.
+ */
+ scanArgs.w = Event.xcrossing.window;
+
+ scanArgs.enters = scanArgs.matches = False;
+ (void) XCheckIfEvent(dpy, &dummy, HLNQueueScanner,
+ (char *) &scanArgs);
+
+ if ((Event.xcrossing.window == Tmp_win->frame &&
+ !scanArgs.matches) ||inicon) {
+ if (Tmp_win->list)
+ NotActiveIconManager(Tmp_win->list);
+ 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;
}
}
-
-
/**
- * HandleConfigureRequest - ConfigureRequest event handler
+ * HandleConfigureRequest - ConfigureRequest event handler
*/
void
HandleConfigureRequest(void)
@@ -2274,29 +2227,29 @@ HandleConfigureRequest(void)
#ifdef DEBUG_EVENTS
fprintf(stderr, "ConfigureRequest\n");
if (cre->value_mask & CWX)
- fprintf(stderr, " x = %d\n", cre->x);
+ fprintf(stderr, " x = %d\n", cre->x);
if (cre->value_mask & CWY)
- fprintf(stderr, " y = %d\n", cre->y);
+ fprintf(stderr, " y = %d\n", cre->y);
if (cre->value_mask & CWWidth)
- fprintf(stderr, " width = %d\n", cre->width);
+ fprintf(stderr, " width = %d\n", cre->width);
if (cre->value_mask & CWHeight)
- fprintf(stderr, " height = %d\n", cre->height);
+ fprintf(stderr, " height = %d\n", cre->height);
if (cre->value_mask & CWSibling)
- fprintf(stderr, " above = 0x%x\n", cre->above);
+ fprintf(stderr, " above = 0x%x\n", cre->above);
if (cre->value_mask & CWStackMode)
- fprintf(stderr, " stack = %d\n", cre->detail);
+ fprintf(stderr, " stack = %d\n", cre->detail);
#endif
/*
* Event.xany.window is Event.xconfigurerequest.parent, so Tmp_win will
* be wrong
*/
- Event.xany.window = cre->window; /* mash parent field */
- if (XFindContext (dpy, cre->window, TwmContext, &context_data) == 0)
- Tmp_win = (TwmWindow *) context_data;
- else
- Tmp_win = NULL;
+ Event.xany.window = cre->window; /* mash parent field */
+ if (XFindContext(dpy, cre->window, TwmContext, &context_data) == 0)
+ Tmp_win = (TwmWindow *) context_data;
+ else
+ Tmp_win = NULL;
/*
* According to the July 27, 1988 ICCCM draft, we should ignore size and
@@ -2305,32 +2258,32 @@ HandleConfigureRequest(void)
* to configuration requests for windows which have never been mapped.
*/
if (!Tmp_win || Tmp_win->icon_w == cre->window) {
- xwcm = cre->value_mask &
- (CWX | CWY | CWWidth | CWHeight | CWBorderWidth);
- xwc.x = cre->x;
- xwc.y = cre->y;
- xwc.width = cre->width;
- xwc.height = cre->height;
- xwc.border_width = cre->border_width;
- XConfigureWindow(dpy, Event.xany.window, (unsigned)xwcm, &xwc);
- return;
+ xwcm = cre->value_mask &
+ (CWX | CWY | CWWidth | CWHeight | CWBorderWidth);
+ xwc.x = cre->x;
+ xwc.y = cre->y;
+ xwc.width = cre->width;
+ xwc.height = cre->height;
+ xwc.border_width = cre->border_width;
+ XConfigureWindow(dpy, Event.xany.window, (unsigned) xwcm, &xwc);
+
+ return;
}
if ((cre->value_mask & CWStackMode) && Tmp_win->stackmode) {
- TwmWindow *otherwin = NULL;
+ TwmWindow *otherwin = NULL;
- if (cre->value_mask & CWSibling) {
- if (XFindContext (dpy, cre->above, TwmContext, &context_data) == 0)
- otherwin = (TwmWindow *) context_data;
- }
+ if (cre->value_mask & CWSibling) {
+ if (XFindContext(dpy, cre->above, TwmContext, &context_data) == 0)
+ otherwin = (TwmWindow *) context_data;
+ }
- xwc.sibling = (otherwin != NULL) ? otherwin->frame : cre->above;
- xwc.stack_mode = cre->detail;
- XConfigureWindow (dpy, Tmp_win->frame,
- cre->value_mask & (CWSibling | CWStackMode), &xwc);
+ xwc.sibling = (otherwin != NULL) ? otherwin->frame : cre->above;
+ xwc.stack_mode = cre->detail;
+ XConfigureWindow(dpy, Tmp_win->frame,
+ cre->value_mask & (CWSibling | CWStackMode), &xwc);
}
-
/* Don't modify frame_XXX fields before calling SetupWindow! */
x = Tmp_win->frame_x;
y = Tmp_win->frame_y;
@@ -2348,37 +2301,39 @@ HandleConfigureRequest(void)
* allow border width changes, we will need to send the synthetic
* ConfigureNotify event.
*/
- GetGravityOffsets (Tmp_win, &gravx, &gravy);
+ GetGravityOffsets(Tmp_win, &gravx, &gravy);
if (cre->value_mask & CWBorderWidth) {
- int bwdelta = cre->border_width - Tmp_win->old_bw; /* posit growth */
- if (bwdelta && Scr->ClientBorderWidth) { /* if change allowed */
- x += gravx * bwdelta; /* change default values only */
- y += gravy * bwdelta; /* ditto */
- bw = cre->border_width;
- if (Tmp_win->title_height) height += bwdelta;
- x += (gravx < 0) ? bwdelta : -bwdelta;
- y += (gravy < 0) ? bwdelta : -bwdelta;
- }
- Tmp_win->old_bw = cre->border_width; /* for restoring */
+ int bwdelta = cre->border_width - Tmp_win->old_bw; /* posit growth */
+
+ if (bwdelta && Scr->ClientBorderWidth) { /* if change allowed */
+ x += gravx * bwdelta; /* change default values only */
+ y += gravy * bwdelta; /* ditto */
+ bw = cre->border_width;
+ if (Tmp_win->title_height)
+ height += bwdelta;
+ x += (gravx < 0) ? bwdelta : -bwdelta;
+ y += (gravy < 0) ? bwdelta : -bwdelta;
+ }
+ Tmp_win->old_bw = cre->border_width; /* for restoring */
}
- if (cre->value_mask & CWX) { /* override even if border change */
- x = cre->x - bw;
+ if (cre->value_mask & CWX) { /* override even if border change */
+ x = cre->x - bw;
}
if (cre->value_mask & CWY) {
- y = cre->y - ((gravy < 0) ? 0 : Tmp_win->title_height) - bw;
+ y = cre->y - ((gravy < 0) ? 0 : Tmp_win->title_height) - bw;
}
if (cre->value_mask & CWWidth) {
- width = cre->width;
+ width = cre->width;
}
if (cre->value_mask & CWHeight) {
- height = cre->height + Tmp_win->title_height;
+ height = cre->height + Tmp_win->title_height;
}
if (width != Tmp_win->frame_width || height != Tmp_win->frame_height)
- Tmp_win->zoomed = ZOOM_NONE;
+ Tmp_win->zoomed = ZOOM_NONE;
/*
* SetupWindow (x,y) are the location of the upper-left outer corner and
@@ -2387,58 +2342,49 @@ HandleConfigureRequest(void)
* 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);
+ SetupWindow(Tmp_win, x, y, width, height, bw);
}
-
-
/**
* shape notification event handler
*/
void
-HandleShapeNotify (void)
+HandleShapeNotify(void)
{
- XShapeEvent *sev = (XShapeEvent *) &Event;
+ XShapeEvent *sev = (XShapeEvent *) & Event;
if (Tmp_win == NULL)
- return;
+ return;
if (sev->kind != ShapeBounding)
- return;
+ return;
if (!Tmp_win->wShaped && sev->shaped) {
- XShapeCombineMask (dpy, Tmp_win->frame, ShapeClip, 0, 0, None,
- ShapeSet);
+ XShapeCombineMask(dpy, Tmp_win->frame, ShapeClip, 0, 0, None, ShapeSet);
}
- Tmp_win->wShaped = (short)sev->shaped;
- SetFrameShape (Tmp_win);
+ Tmp_win->wShaped = (short) sev->shaped;
+ SetFrameShape(Tmp_win);
}
-
-
#ifdef HAVE_XRANDR
/**
* xrandr screen configuration change-notification handler
*/
void
-HandleScreenChangeNotify (void)
+HandleScreenChangeNotify(void)
{
- XRRScreenChangeNotifyEvent *xev = (XRRScreenChangeNotifyEvent *) &Event;
+ XRRScreenChangeNotifyEvent *xev = (XRRScreenChangeNotifyEvent *) & Event;
int scrnum;
- for (scrnum = 0; scrnum < NumScreens; scrnum++)
- {
- if ( ScreenList[scrnum]->Root == xev->root )
- {
- ScreenList[scrnum]->MyDisplayWidth = xev->width;
- ScreenList[scrnum]->MyDisplayHeight = xev->height;
- }
+ for (scrnum = 0; scrnum < NumScreens; scrnum++) {
+ if (ScreenList[scrnum]->Root == xev->root) {
+ ScreenList[scrnum]->MyDisplayWidth = xev->width;
+ ScreenList[scrnum]->MyDisplayHeight = xev->height;
+ }
}
XRRUpdateConfiguration(&Event);
}
#endif
-
-
/**
* unknown event handler
*/
@@ -2450,15 +2396,13 @@ HandleUnknown(void)
#endif
}
-
-
/**
* checks to see if the window is a transient.
*
* \return TRUE if window is a transient
* \return FALSE if window is not a transient
*
- * \param w the window to check
+ * \param w the window to check
*/
int
Transient(Window w, Window *propw)
@@ -2466,8 +2410,6 @@ Transient(Window w, Window *propw)
return (XGetTransientForHint(dpy, w, propw));
}
-
-
/**
* get ScreenInfo struct associated with a given window
*
@@ -2482,39 +2424,35 @@ FindScreenInfo(Window w)
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];
- }
+ 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 (Window w)
+flush_expose(Window w)
{
XEvent dummy;
- /* SUPPRESS 530 */
- while (XCheckTypedWindowEvent (dpy, w, Expose, &dummy)) ;
+ /* SUPPRESS 530 */
+ while (XCheckTypedWindowEvent(dpy, w, Expose, &dummy));
}
-
-
/**
* install the colormaps for one twm window.
*
* \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.
+ * window structure, whose colormaps are to be installed.
*/
void
-InstallWindowColormaps (int type, TwmWindow *tmp)
+InstallWindowColormaps(int type, TwmWindow *tmp)
{
int i, j, n, number_cwins, state;
ColormapWindow **cwins, *cwin, **maxcwin = NULL;
@@ -2526,136 +2464,133 @@ InstallWindowColormaps (int type, TwmWindow *tmp)
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;
- /* Don't reload the currend window colormap list.
- */
- if (Scr->cmapInfo.cmaps == &tmp->cmaps)
- return;
- if (Scr->cmapInfo.cmaps)
- for (i = Scr->cmapInfo.cmaps->number_cwins,
- cwins = Scr->cmapInfo.cmaps->cwins; i-- > 0; cwins++)
- (*cwins)->colormap->state &= ~CM_INSTALLABLE;
- Scr->cmapInfo.cmaps = &tmp->cmaps;
- break;
+ /* 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;
+ /* Don't reload the currend window colormap list.
+ */
+ if (Scr->cmapInfo.cmaps == &tmp->cmaps)
+ return;
+ if (Scr->cmapInfo.cmaps)
+ for (i = Scr->cmapInfo.cmaps->number_cwins,
+ cwins = Scr->cmapInfo.cmaps->cwins; i-- > 0; cwins++)
+ (*cwins)->colormap->state &= ~CM_INSTALLABLE;
+ Scr->cmapInfo.cmaps = &tmp->cmaps;
+ break;
case PropertyNotify:
case VisibilityNotify:
case ColormapNotify:
- break;
+ break;
}
number_cwins = Scr->cmapInfo.cmaps->number_cwins;
cwins = Scr->cmapInfo.cmaps->cwins;
scoreboard = Scr->cmapInfo.cmaps->scoreboard;
- ColortableThrashing = FALSE; /* in case installation aborted */
+ ColortableThrashing = FALSE; /* in case installation aborted */
state = CM_INSTALLED;
- for (i = n = 0; i < number_cwins; i++) {
- cwin = cwins[i];
- cmap = cwin->colormap;
- cmap->state |= CM_INSTALLABLE;
- cmap->state &= ~CM_INSTALL;
- cmap->w = cwin->w;
- }
- for (i = n = 0; i < number_cwins; i++) {
- cwin = cwins[i];
- cmap = cwin->colormap;
- if (cwin->visibility != VisibilityFullyObscured &&
- n < Scr->cmapInfo.maxCmaps) {
- row = scoreboard + (i*(i-1)/2);
- for (j = 0; j < i; j++)
- if (row[j] && (cwins[j]->colormap->state & CM_INSTALL))
- break;
- if (j != i)
- continue;
- n++;
- maxcwin = &cwins[i];
- state &= (cmap->state & CM_INSTALLED);
- cmap->state |= CM_INSTALL;
- }
+ for (i = n = 0; i < number_cwins; i++) {
+ cwin = cwins[i];
+ cmap = cwin->colormap;
+ cmap->state |= CM_INSTALLABLE;
+ cmap->state &= ~CM_INSTALL;
+ cmap->w = cwin->w;
+ }
+ for (i = n = 0; i < number_cwins; i++) {
+ cwin = cwins[i];
+ cmap = cwin->colormap;
+ if (cwin->visibility != VisibilityFullyObscured &&
+ n < Scr->cmapInfo.maxCmaps) {
+ row = scoreboard + (i * (i - 1) / 2);
+ for (j = 0; j < i; j++)
+ if (row[j] && (cwins[j]->colormap->state & CM_INSTALL))
+ break;
+ if (j != i)
+ continue;
+ n++;
+ maxcwin = &cwins[i];
+ state &= (cmap->state & CM_INSTALLED);
+ cmap->state |= CM_INSTALL;
+ }
}
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--;
- }
+ 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
*
* 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.
+ * 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.
+ * 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(void)
{
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;
+ /*
+ * 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++;
}
-
-
static Bool
UninstallRootColormapQScanner(Display *dpy2 _X_UNUSED, 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)
+ if (ev->type == EnterNotify) {
+ if (ev->xcrossing.mode != NotifyGrab)
+ *args = 1;
+ }
+ else if (ev->type == LeaveNotify) {
+ if (ev->xcrossing.mode == NotifyNormal)
- *args = 1;
- }
+ *args = 1;
+ }
}
return (False);
}
-
void
UninstallRootColormap(void)
{
@@ -2663,69 +2598,71 @@ UninstallRootColormap(void)
XEvent dummy;
if (Scr->cmapInfo.root_pushes)
- 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 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);
+ if (!args)
+ InstallWindowColormaps(0, Scr->cmapInfo.pushed_window);
}
}
#ifdef TRACE
void
-dumpevent (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;
- case UnmapNotify: name = "UnmapNotify"; break;
- case MapNotify: name = "MapNotify"; break;
- case MapRequest: name = "MapRequest"; break;
- case ReparentNotify: name = "ReparentNotify"; break;
- case ConfigureNotify: name = "ConfigureNotify"; break;
- case ConfigureRequest: name = "ConfigureRequest"; break;
- case GravityNotify: name = "GravityNotify"; break;
- case ResizeRequest: name = "ResizeRequest"; break;
- case CirculateNotify: name = "CirculateNotify"; break;
- case CirculateRequest: name = "CirculateRequest"; break;
- case PropertyNotify: name = "PropertyNotify"; break;
- case SelectionClear: name = "SelectionClear"; break;
- case SelectionRequest: name = "SelectionRequest"; break;
- case SelectionNotify: name = "SelectionNotify"; break;
- case ColormapNotify: name = "ColormapNotify"; break;
- case ClientMessage: name = "ClientMessage"; break;
- case MappingNotify: name = "MappingNotify"; break;
+ /* *INDENT-OFF* */
+ 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;
+ case UnmapNotify: name = "UnmapNotify"; break;
+ case MapNotify: name = "MapNotify"; break;
+ case MapRequest: name = "MapRequest"; break;
+ case ReparentNotify: name = "ReparentNotify"; break;
+ case ConfigureNotify: name = "ConfigureNotify"; break;
+ case ConfigureRequest: name = "ConfigureRequest"; break;
+ case GravityNotify: name = "GravityNotify"; break;
+ case ResizeRequest: name = "ResizeRequest"; break;
+ case CirculateNotify: name = "CirculateNotify"; break;
+ case CirculateRequest: name = "CirculateRequest"; break;
+ case PropertyNotify: name = "PropertyNotify"; break;
+ case SelectionClear: name = "SelectionClear"; break;
+ case SelectionRequest: name = "SelectionRequest"; break;
+ case SelectionNotify: name = "SelectionNotify"; break;
+ case ColormapNotify: name = "ColormapNotify"; break;
+ case ClientMessage: name = "ClientMessage"; break;
+ case MappingNotify: name = "MappingNotify"; break;
+ /* *INDENT-ON* */
}
if (name) {
- printf ("event: %s, %d remaining\n", name, QLength(dpy));
- } else {
- printf ("unknown event %d, %d remaining\n", e->type, QLength(dpy));
+ printf("event: %s, %d remaining\n", name, QLength(dpy));
+ }
+ else {
+ printf("unknown event %d, %d remaining\n", e->type, QLength(dpy));
}
}
-#endif /* TRACE */
-
+#endif /* TRACE */
diff --git a/src/events.h b/src/events.h
index f554642..085439f 100644
--- a/src/events.h
+++ b/src/events.h
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* twm event handler include file
@@ -64,46 +63,47 @@ in this Software without prior written authorization from The Open Group.
#include "screen.h"
#include "twm.h"
-typedef void (*event_proc)(void);
+typedef void (*event_proc) (void);
extern Time lastTimestamp;
+
#define LastTimestamp() lastTimestamp
-extern void AutoRaiseWindow ( TwmWindow *tmp );
-extern void SetRaiseWindow ( TwmWindow *tmp );
-extern void InitEvents ( void );
-extern Bool StashEventTime ( XEvent *ev );
-extern Window WindowOfEvent ( XEvent *e );
-extern Bool DispatchEvent2 ( void );
-extern Bool DispatchEvent ( void );
-extern void HandleEvents ( void );
-extern void HandleColormapNotify ( void );
-extern void HandleVisibilityNotify ( void );
-extern void HandleKeyPress ( void );
-extern void free_cwins ( TwmWindow *tmp );
-extern void HandlePropertyNotify ( void );
-extern void HandleClientMessage ( void );
-extern void HandleExpose ( void );
-extern void HandleDestroyNotify ( void );
-extern void HandleCreateNotify ( void );
-extern void HandleMapRequest ( void );
-extern void SimulateMapRequest ( Window w );
-extern void HandleMapNotify ( void );
-extern void HandleUnmapNotify ( void );
-extern void HandleMotionNotify ( void );
-extern void HandleButtonRelease ( void );
-extern void HandleButtonPress ( void );
-extern void HandleEnterNotify ( void );
-extern void HandleLeaveNotify ( void );
-extern void HandleConfigureRequest ( void );
-extern void HandleShapeNotify ( void );
-extern void HandleScreenChangeNotify ( void );
-extern void HandleUnknown ( void );
-extern int Transient ( Window w, Window *propw );
-extern ScreenInfo * FindScreenInfo ( Window w );
-extern void InstallWindowColormaps ( int type, TwmWindow *tmp );
-extern void InstallRootColormap ( void );
-extern void UninstallRootColormap ( void );
+extern void AutoRaiseWindow(TwmWindow *tmp);
+extern void SetRaiseWindow(TwmWindow *tmp);
+extern void InitEvents(void);
+extern Bool StashEventTime(XEvent *ev);
+extern Window WindowOfEvent(XEvent *e);
+extern Bool DispatchEvent2(void);
+extern Bool DispatchEvent(void);
+extern void HandleEvents(void);
+extern void HandleColormapNotify(void);
+extern void HandleVisibilityNotify(void);
+extern void HandleKeyPress(void);
+extern void free_cwins(TwmWindow *tmp);
+extern void HandlePropertyNotify(void);
+extern void HandleClientMessage(void);
+extern void HandleExpose(void);
+extern void HandleDestroyNotify(void);
+extern void HandleCreateNotify(void);
+extern void HandleMapRequest(void);
+extern void SimulateMapRequest(Window w);
+extern void HandleMapNotify(void);
+extern void HandleUnmapNotify(void);
+extern void HandleMotionNotify(void);
+extern void HandleButtonRelease(void);
+extern void HandleButtonPress(void);
+extern void HandleEnterNotify(void);
+extern void HandleLeaveNotify(void);
+extern void HandleConfigureRequest(void);
+extern void HandleShapeNotify(void);
+extern void HandleScreenChangeNotify(void);
+extern void HandleUnknown(void);
+extern int Transient(Window w, Window *propw);
+extern ScreenInfo *FindScreenInfo(Window w);
+extern void InstallWindowColormaps(int type, TwmWindow *tmp);
+extern void InstallRootColormap(void);
+extern void UninstallRootColormap(void);
extern event_proc EventHandler[];
extern Window DragWindow;
@@ -127,4 +127,4 @@ extern unsigned int mods_used;
extern int MovedFromKeyPress;
-#endif /* _EVENTS_ */
+#endif /* _EVENTS_ */
diff --git a/src/gc.h b/src/gc.h
index 2d71509..4065ded 100644
--- a/src/gc.h
+++ b/src/gc.h
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/**********************************************************************
*
* GC related externs
@@ -61,6 +60,6 @@ in this Software without prior written authorization from The Open Group.
#ifndef _GC_
#define _GC_
-extern void CreateGCs( void );
+extern void CreateGCs(void);
-#endif /* _GC_ */
+#endif /* _GC_ */
diff --git a/src/iconmgr.c b/src/iconmgr.c
index 80457a1..e59f849 100644
--- a/src/iconmgr.c
+++ b/src/iconmgr.c
@@ -27,7 +27,7 @@ in this Software without prior written authorization from The Open Group.
*
* Icon Manager routines
*
- * 09-Mar-89 Tom LaStrange File Created
+ * 09-Mar-89 Tom LaStrange File Created
*
***********************************************************************/
@@ -42,9 +42,9 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xos.h>
#include <X11/Xmu/CharSet.h>
-static void InsertInIconManager ( IconMgr *ip, WList *tmp, TwmWindow *tmp_win );
+static void InsertInIconManager(IconMgr *ip, WList *tmp, TwmWindow *tmp_win);
-int iconmgr_textx = siconify_width+11;
+int iconmgr_textx = siconify_width + 11;
static WList *Active = NULL;
WList *DownIconManager = NULL;
int iconifybox_width = siconify_width;
@@ -64,51 +64,52 @@ CreateIconManagers(void)
const char *icon_name;
if (Scr->NoIconManagers)
- return;
+ return;
- if (Scr->siconifyPm == None)
- {
- Scr->siconifyPm = XCreatePixmapFromBitmapData(dpy, Scr->Root,
- (char *)siconify_bits, siconify_width, siconify_height, 1, 0, 1);
+ 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)
- {
- mask = XParseGeometry(p->geometry, &JunkX, &JunkY,
- (unsigned int *) &p->width, (unsigned int *)&p->height);
+ for (p = &Scr->iconmgr; p != NULL; p = p->next) {
+ mask = XParseGeometry(p->geometry, &JunkX, &JunkY,
+ (unsigned int *) &p->width,
+ (unsigned int *) &p->height);
- if (mask & XNegative)
- JunkX = Scr->MyDisplayWidth - p->width -
- (2 * Scr->BorderWidth) + JunkX;
+ if (mask & XNegative)
+ JunkX = Scr->MyDisplayWidth - p->width -
+ (2 * Scr->BorderWidth) + JunkX;
- if (mask & YNegative)
- JunkY = Scr->MyDisplayHeight - p->height -
- (2 * Scr->BorderWidth) + JunkY;
+ if (mask & YNegative)
+ JunkY = Scr->MyDisplayHeight - p->height -
+ (2 * Scr->BorderWidth) + JunkY;
- background = Scr->IconManagerC.back;
- GetColorFromList(Scr->IconManagerBL, p->name, (XClassHint *)NULL,
- &background);
+ background = Scr->IconManagerC.back;
+ GetColorFromList(Scr->IconManagerBL, p->name, (XClassHint *) NULL,
+ &background);
- p->w = XCreateSimpleWindow(dpy, Scr->Root,
- JunkX, JunkY, (unsigned)p->width, (unsigned)p->height, 1,
- Scr->Black, background);
+ p->w = XCreateSimpleWindow(dpy, Scr->Root,
+ JunkX, JunkY, (unsigned) p->width,
+ (unsigned) p->height, 1, Scr->Black,
+ background);
- snprintf(str, sizeof(str), "%s Icon Manager", p->name);
- snprintf(str1, sizeof(str1), "%s Icons", p->name);
- if (p->icon_name)
- icon_name = p->icon_name;
- else
- icon_name = str1;
+ snprintf(str, sizeof(str), "%s Icon Manager", p->name);
+ snprintf(str1, sizeof(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);
+ XSetStandardProperties(dpy, p->w, str, icon_name, None, NULL, 0, NULL);
- p->twm_win = AddWindow(p->w, TRUE, p);
- SetMapStateProp (p->twm_win, WithdrawnState);
+ 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);
+ for (p = &Scr->iconmgr; p != NULL; p = p->next) {
+ GrabButtons(p->twm_win);
+ GrabKeys(p->twm_win);
}
}
@@ -117,21 +118,22 @@ CreateIconManagers(void)
*
* \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
+ * \param geom a geometry string to eventually parse
+ * \param columns the number of columns this icon manager has
*/
-IconMgr *AllocateIconManager(char *name, char *icon_name, char *geom, 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);
+ name, icon_name, geom, columns);
#endif
if (Scr->NoIconManagers)
- return NULL;
+ return NULL;
p = malloc(sizeof(IconMgr));
p->name = name;
@@ -153,7 +155,7 @@ IconMgr *AllocateIconManager(char *name, char *icon_name, char *geom, int column
Scr->iconmgr.lasti = p;
p->next = NULL;
- return(p);
+ return (p);
}
/**
@@ -167,7 +169,8 @@ IconMgr *AllocateIconManager(char *name, char *icon_name, char *geom, int column
* - F_LEFTICONMGR: left one column
* - F_RIGHTICONMGR: right one column
*/
-void MoveIconManager(int dir)
+void
+MoveIconManager(int dir)
{
IconMgr *ip;
WList *tmp = NULL;
@@ -175,7 +178,8 @@ void MoveIconManager(int dir)
int row_inc, col_inc;
int got_it;
- if (!Active) return;
+ if (!Active)
+ return;
cur_row = Active->row;
cur_col = Active->col;
@@ -185,35 +189,34 @@ void MoveIconManager(int dir)
col_inc = 0;
got_it = FALSE;
- switch (dir)
- {
- case F_FORWICONMGR:
- if ((tmp = Active->next) == NULL)
- tmp = ip->first;
- got_it = TRUE;
- break;
-
- case F_BACKICONMGR:
- if ((tmp = Active->prev) == NULL)
- tmp = ip->last;
- got_it = TRUE;
- break;
-
- case F_UPICONMGR:
- row_inc = -1;
- break;
-
- case F_DOWNICONMGR:
- row_inc = 1;
- break;
-
- case F_LEFTICONMGR:
- col_inc = -1;
- break;
-
- case F_RIGHTICONMGR:
- col_inc = 1;
- break;
+ switch (dir) {
+ case F_FORWICONMGR:
+ if ((tmp = Active->next) == NULL)
+ tmp = ip->first;
+ got_it = TRUE;
+ break;
+
+ case F_BACKICONMGR:
+ if ((tmp = Active->prev) == NULL)
+ tmp = ip->last;
+ got_it = TRUE;
+ break;
+
+ case F_UPICONMGR:
+ row_inc = -1;
+ break;
+
+ case F_DOWNICONMGR:
+ row_inc = 1;
+ break;
+
+ case F_LEFTICONMGR:
+ col_inc = -1;
+ break;
+
+ case F_RIGHTICONMGR:
+ col_inc = 1;
+ break;
}
/* If got_it is FALSE ast this point then we got a left, right,
@@ -223,57 +226,55 @@ void MoveIconManager(int dir)
new_row = cur_row;
new_col = cur_col;
- while (!got_it)
- {
- new_row += row_inc;
- new_col += col_inc;
- if (new_row < 0)
- new_row = ip->cur_rows - 1;
- if (new_col < 0)
- new_col = ip->cur_columns - 1;
- if (new_row >= ip->cur_rows)
- new_row = 0;
- if (new_col >= ip->cur_columns)
- new_col = 0;
-
- /* Now let's go through the list to see if there is an entry with this
- * new position
- */
- for (tmp = ip->first; tmp != NULL; tmp = tmp->next)
- {
- if (tmp->row == new_row && tmp->col == new_col)
- {
- got_it = TRUE;
- break;
- }
- }
+ while (!got_it) {
+ new_row += row_inc;
+ new_col += col_inc;
+ if (new_row < 0)
+ new_row = ip->cur_rows - 1;
+ if (new_col < 0)
+ new_col = ip->cur_columns - 1;
+ if (new_row >= ip->cur_rows)
+ new_row = 0;
+ if (new_col >= ip->cur_columns)
+ new_col = 0;
+
+ /* Now let's go through the list to see if there is an entry with this
+ * new position
+ */
+ for (tmp = ip->first; tmp != NULL; tmp = tmp->next) {
+ if (tmp->row == new_row && tmp->col == new_col) {
+ got_it = TRUE;
+ break;
+ }
+ }
}
- if (!got_it)
- {
- fprintf (stderr,
- "%s: unable to find window (%d, %d) in icon manager\n",
- ProgramName, new_row, new_col);
- return;
+ if (!got_it) {
+ fprintf(stderr,
+ "%s: unable to find window (%d, %d) in icon manager\n",
+ ProgramName, new_row, new_col);
+ return;
}
if (tmp == NULL)
- return;
+ 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);
- }
+ 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);
+ }
}
}
@@ -284,44 +285,46 @@ void MoveIconManager(int dir)
* - F_PREVICONMGR - go to the previous one
*/
-void JumpIconManager(int dir)
+void
+JumpIconManager(int dir)
{
IconMgr *ip, *tmp_ip = NULL;
int got_it = FALSE;
ScreenInfo *sp;
int screen;
- if (!Active) return;
-
+ 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; }
+ { got_it = TRUE; break; }
ip = Active->iconmgr;
for (tmp_ip = ITER(ip); tmp_ip; tmp_ip = ITER(tmp_ip)) {
- TEST (tmp_ip);
+ TEST(tmp_ip);
}
if (!got_it) {
- int origscreen = ip->scr->screen;
- int inc = (dir == F_NEXTICONMGR ? 1 : -1);
-
- for (screen = origscreen + inc; ; screen += inc) {
- if (screen >= NumScreens)
- screen = 0;
- else if (screen < 0)
- screen = NumScreens - 1;
-
- sp = ScreenList[screen];
- if (sp) {
- for (tmp_ip = IPOFSP (sp); tmp_ip; tmp_ip = ITER(tmp_ip)) {
- TEST (tmp_ip);
- }
- }
- if (got_it || screen == origscreen) break;
- }
+ int origscreen = ip->scr->screen;
+ int inc = (dir == F_NEXTICONMGR ? 1 : -1);
+
+ for (screen = origscreen + inc;; screen += inc) {
+ if (screen >= NumScreens)
+ screen = 0;
+ else if (screen < 0)
+ screen = NumScreens - 1;
+
+ sp = ScreenList[screen];
+ if (sp) {
+ for (tmp_ip = IPOFSP(sp); tmp_ip; tmp_ip = ITER(tmp_ip)) {
+ TEST(tmp_ip);
+ }
+ }
+ if (got_it || screen == origscreen)
+ break;
+ }
}
#undef ITER
@@ -329,16 +332,16 @@ void JumpIconManager(int dir)
#undef TEST
if (!got_it) {
- Bell(XkbBI_MinorError,0,None);
- return;
+ 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);
+ 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);
+ XWarpPointer(dpy, None, tmp_ip->w, 0, 0, 0, 0, 5, 5);
}
/**
@@ -346,27 +349,28 @@ void JumpIconManager(int dir)
*
* \param tmp_win the TwmWindow structure
*/
-WList *AddIconManager(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 */
+ 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;
+ return NULL;
if (LookInList(Scr->IconMgrNoShow, tmp_win->full_name, &tmp_win->class))
- return NULL;
+ 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;
+ !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;
tmp = malloc(sizeof(WList));
tmp->iconmgr = ip;
@@ -383,15 +387,15 @@ WList *AddIconManager(TwmWindow *tmp_win)
tmp->highlight = Scr->IconManagerHighlight;
GetColorFromList(Scr->IconManagerFL, tmp_win->full_name, &tmp_win->class,
- &tmp->fore);
+ &tmp->fore);
GetColorFromList(Scr->IconManagerBL, tmp_win->full_name, &tmp_win->class,
- &tmp->back);
+ &tmp->back);
GetColorFromList(Scr->IconManagerHighlightL, tmp_win->full_name,
- &tmp_win->class, &tmp->highlight);
+ &tmp_win->class, &tmp->highlight);
h = Scr->IconManagerFont.height + 10;
if (h < (siconify_height + 4))
- h = siconify_height + 4;
+ h = siconify_height + 4;
ip->height = h * ip->count;
tmp->me = ip->count;
@@ -402,28 +406,27 @@ WList *AddIconManager(TwmWindow *tmp_win)
attributes.background_pixel = tmp->back;
attributes.border_pixel = tmp->back;
attributes.event_mask = (KeyPressMask | ButtonPressMask |
- ButtonReleaseMask | ExposureMask |
- EnterWindowMask | LeaveWindowMask);
+ ButtonReleaseMask | ExposureMask |
+ EnterWindowMask | LeaveWindowMask);
attributes.cursor = Scr->IconMgrCursor;
- tmp->w = XCreateWindow (dpy, ip->w, 0, 0, (unsigned int) 1,
- (unsigned int) h, (unsigned int) 0,
- CopyFromParent, (unsigned int) CopyFromParent,
- (Visual *) CopyFromParent, valuemask, &attributes);
-
+ tmp->w = XCreateWindow(dpy, ip->w, 0, 0, (unsigned int) 1,
+ (unsigned int) h, (unsigned int) 0,
+ CopyFromParent, (unsigned int) CopyFromParent,
+ (Visual *) CopyFromParent, valuemask, &attributes);
valuemask = (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor);
attributes.background_pixel = tmp->back;
attributes.border_pixel = Scr->Black;
- attributes.event_mask = (ButtonReleaseMask| ButtonPressMask |
- ExposureMask);
+ attributes.event_mask = (ButtonReleaseMask | ButtonPressMask |
+ ExposureMask);
attributes.cursor = Scr->ButtonCursor;
- tmp->icon = XCreateWindow (dpy, tmp->w, 5, (int) (h - siconify_height)/2,
- (unsigned int) siconify_width,
- (unsigned int) siconify_height,
- (unsigned int) 0, CopyFromParent,
- (unsigned int) CopyFromParent,
- (Visual *) CopyFromParent,
- valuemask, &attributes);
+ tmp->icon = XCreateWindow(dpy, tmp->w, 5, (int) (h - siconify_height) / 2,
+ (unsigned int) siconify_width,
+ (unsigned int) siconify_height,
+ (unsigned int) 0, CopyFromParent,
+ (unsigned int) CopyFromParent,
+ (Visual *) CopyFromParent,
+ valuemask, &attributes);
ip->count += 1;
PackIconManager(ip);
@@ -436,13 +439,13 @@ WList *AddIconManager(TwmWindow *tmp_win)
XSaveContext(dpy, tmp->icon, ScreenContext, (XPointer) Scr);
tmp_win->list = tmp;
- if (!ip->twm_win->icon)
- {
- XMapWindow(dpy, ip->w);
- XMapWindow(dpy, ip->twm_win->frame);
+ if (!ip->twm_win->icon) {
+ XMapWindow(dpy, ip->w);
+ XMapWindow(dpy, ip->twm_win->frame);
}
- if (Active == NULL) Active = tmp;
+ if (Active == NULL)
+ Active = tmp;
return (tmp);
}
@@ -453,72 +456,70 @@ WList *AddIconManager(TwmWindow *tmp_win)
* \param ip the icon manager pointer
* \param tmp the entry to insert
*/
-static void InsertInIconManager(IconMgr *ip, WList *tmp, TwmWindow *tmp_win)
+static void
+InsertInIconManager(IconMgr *ip, WList *tmp, TwmWindow *tmp_win)
{
WList *tmp1;
int added;
- int (*compar)(const char *, const char *)
- = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
+ 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;
+ 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)
- {
- tmp->next = tmp1;
- tmp->prev = tmp1->prev;
- tmp1->prev = tmp;
- if (tmp->prev == NULL)
- ip->first = tmp;
- else
- tmp->prev->next = tmp;
- added = TRUE;
- break;
- }
- }
+ else if (Scr->SortIconMgr) {
+ for (tmp1 = ip->first; tmp1 != NULL; tmp1 = tmp1->next) {
+ if ((*compar) (tmp_win->icon_name, tmp1->twm->icon_name) < 0) {
+ tmp->next = tmp1;
+ 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;
+ if (!added) {
+ ip->last->next = tmp;
+ tmp->prev = ip->last;
+ ip->last = tmp;
}
}
-static void RemoveFromIconManager(IconMgr *ip, WList *tmp)
+static void
+RemoveFromIconManager(IconMgr *ip, WList *tmp)
{
if (tmp->prev == NULL)
- ip->first = tmp->next;
+ ip->first = tmp->next;
else
- tmp->prev->next = tmp->next;
+ tmp->prev->next = tmp->next;
if (tmp->next == NULL)
- ip->last = tmp->prev;
+ ip->last = tmp->prev;
else
- tmp->next->prev = tmp->prev;
+ tmp->next->prev = tmp->prev;
}
/**
* remove a window from the icon manager
* \param tmp_win the TwmWindow structure
*/
-void RemoveIconManager(TwmWindow *tmp_win)
+void
+RemoveIconManager(TwmWindow *tmp_win)
{
IconMgr *ip;
WList *tmp;
if (tmp_win->list == NULL)
- return;
+ return;
tmp = tmp_win->list;
tmp_win->list = NULL;
@@ -538,14 +539,14 @@ void RemoveIconManager(TwmWindow *tmp_win)
PackIconManager(ip);
- if (ip->count == 0)
- {
- XUnmapWindow(dpy, ip->twm_win->frame);
+ if (ip->count == 0) {
+ XUnmapWindow(dpy, ip->twm_win->frame);
}
}
-void ActiveIconManager(WList *active)
+void
+ActiveIconManager(WList *active)
{
active->active = TRUE;
Active = active;
@@ -553,28 +554,33 @@ void ActiveIconManager(WList *active)
DrawIconManagerBorder(active);
}
-void NotActiveIconManager(WList *active)
+void
+NotActiveIconManager(WList *active)
{
active->active = FALSE;
DrawIconManagerBorder(active);
}
-void DrawIconManagerBorder(WList *tmp)
+void
+DrawIconManagerBorder(WList *tmp)
{
{
- XSetForeground(dpy, Scr->NormalGC, tmp->fore);
- XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 2, 2,
- (unsigned)(tmp->width-5), (unsigned)(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,
- (unsigned)(tmp->width-1), (unsigned)(tmp->height-1));
- XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 1, 1,
- (unsigned)(tmp->width-3), (unsigned)(tmp->height-3));
+ XSetForeground(dpy, Scr->NormalGC, tmp->fore);
+ XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 2, 2,
+ (unsigned) (tmp->width - 5),
+ (unsigned) (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,
+ (unsigned) (tmp->width - 1),
+ (unsigned) (tmp->height - 1));
+ XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 1, 1,
+ (unsigned) (tmp->width - 3),
+ (unsigned) (tmp->height - 3));
}
}
@@ -583,34 +589,31 @@ void DrawIconManagerBorder(WList *tmp)
*
* \param ip a pointer to the icon manager struture
*/
-void SortIconManager(IconMgr *ip)
+void
+SortIconManager(IconMgr *ip)
{
WList *tmp1, *tmp2;
int done;
- int (*compar)(const char *, const char *)
- = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
+ int (*compar) (const char *, const char *)
+ = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
if (ip == NULL)
- ip = Active->iconmgr;
+ 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;
- }
- }
+ 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);
@@ -618,20 +621,21 @@ void SortIconManager(IconMgr *ip)
/**
* pack the icon manager windows following
- * an addition or deletion
+ * an addition or deletion
*
* \param ip a pointer to the icon manager struture
*/
-void PackIconManager(IconMgr *ip)
+void
+PackIconManager(IconMgr *ip)
{
- int newwidth, i, row, col, maxcol, colinc, rowinc, wheight, wwidth;
+ 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;
+ wheight = siconify_height + 4;
wwidth = ip->width / ip->columns;
@@ -641,33 +645,32 @@ void PackIconManager(IconMgr *ip)
row = 0;
col = ip->columns;
maxcol = 0;
- for (i = 0, tmp = ip->first; tmp != NULL; i++, tmp = tmp->next)
- {
- tmp->me = i;
- if (++col >= ip->columns)
- {
- col = 0;
- row += 1;
- }
- if (col > maxcol)
- maxcol = col;
-
- new_x = col * colinc;
- new_y = (row-1) * rowinc;
-
- /* if the position or size has not changed, don't touch it */
- if (tmp->x != new_x || tmp->y != new_y ||
- tmp->width != wwidth || tmp->height != wheight)
- {
- XMoveResizeWindow(dpy, tmp->w, new_x, new_y, (unsigned)wwidth, (unsigned)wheight);
-
- tmp->row = row-1;
- tmp->col = col;
- tmp->x = new_x;
- tmp->y = new_y;
- tmp->width = wwidth;
- tmp->height = wheight;
- }
+ for (i = 0, tmp = ip->first; tmp != NULL; i++, tmp = tmp->next) {
+ tmp->me = i;
+ if (++col >= ip->columns) {
+ col = 0;
+ row += 1;
+ }
+ if (col > maxcol)
+ maxcol = col;
+
+ new_x = col * colinc;
+ new_y = (row - 1) * rowinc;
+
+ /* if the position or size has not changed, don't touch it */
+ if (tmp->x != new_x || tmp->y != new_y ||
+ tmp->width != wwidth || tmp->height != wheight) {
+ XMoveResizeWindow(dpy, tmp->w,
+ new_x, new_y,
+ (unsigned) wwidth, (unsigned) wheight);
+
+ tmp->row = row - 1;
+ tmp->col = col;
+ tmp->x = new_x;
+ tmp->y = new_y;
+ tmp->width = wwidth;
+ tmp->height = wheight;
+ }
}
maxcol += 1;
@@ -675,17 +678,17 @@ void PackIconManager(IconMgr *ip)
ip->cur_columns = maxcol;
ip->height = row * rowinc;
if (ip->height == 0)
- ip->height = rowinc;
+ ip->height = rowinc;
newwidth = maxcol * colinc;
if (newwidth == 0)
- newwidth = colinc;
+ newwidth = colinc;
- XResizeWindow(dpy, ip->w, (unsigned)newwidth, (unsigned)ip->height);
+ XResizeWindow(dpy, ip->w, (unsigned) newwidth, (unsigned) ip->height);
savewidth = ip->width;
if (ip->twm_win)
- SetupWindow (ip->twm_win,
- ip->twm_win->frame_x, ip->twm_win->frame_y,
- newwidth, ip->height + ip->twm_win->title_height, -1);
+ SetupWindow(ip->twm_win,
+ ip->twm_win->frame_x, ip->twm_win->frame_y,
+ newwidth, ip->height + ip->twm_win->title_height, -1);
ip->width = savewidth;
}
diff --git a/src/iconmgr.h b/src/iconmgr.h
index 6157fa3..c74ffb1 100644
--- a/src/iconmgr.h
+++ b/src/iconmgr.h
@@ -34,8 +34,7 @@ in this Software without prior written authorization from The Open Group.
#ifndef _ICONMGR_
#define _ICONMGR_
-typedef struct WList
-{
+typedef struct WList {
struct WList *next;
struct WList *prev;
struct TwmWindow *twm;
@@ -51,18 +50,17 @@ typedef struct WList
short down;
} WList;
-typedef struct IconMgr
-{
- struct IconMgr *next; /* pointer to the next icon manager */
- struct IconMgr *prev; /* pointer to the previous icon mgr */
- struct IconMgr *lasti; /* pointer to the last icon mgr */
- struct WList *first; /* first window in the list */
- struct WList *last; /* last window in the list */
- struct WList *active; /* the active entry */
- TwmWindow *twm_win; /* back pointer to the new parent */
- struct ScreenInfo *scr; /* the screen this thing is on */
- Window w; /* this icon manager window */
- const char *geometry; /* geometry string */
+typedef struct IconMgr {
+ struct IconMgr *next; /* pointer to the next icon manager */
+ struct IconMgr *prev; /* pointer to the previous icon mgr */
+ struct IconMgr *lasti; /* pointer to the last icon mgr */
+ struct WList *first; /* first window in the list */
+ struct WList *last; /* last window in the list */
+ struct WList *active; /* the active entry */
+ TwmWindow *twm_win; /* back pointer to the new parent */
+ struct ScreenInfo *scr; /* the screen this thing is on */
+ Window w; /* this icon manager window */
+ const char *geometry; /* geometry string */
const char *name;
const char *icon_name;
int x, y, width, height;
@@ -74,16 +72,17 @@ extern int iconmgr_textx;
extern WList *DownIconManager;
extern int iconifybox_width, iconifybox_height;
-extern void ActiveIconManager ( WList *active );
-extern WList *AddIconManager ( TwmWindow *tmp_win );
-extern IconMgr *AllocateIconManager ( char *name, char *icon_name, char *geom, int columns );
-extern void CreateIconManagers ( void );
-extern void DrawIconManagerBorder ( WList *tmp );
-extern void JumpIconManager ( int dir );
-extern void MoveIconManager ( int dir );
-extern void NotActiveIconManager ( WList *active );
-extern void PackIconManager ( IconMgr *ip );
-extern void RemoveIconManager ( TwmWindow *tmp_win );
-extern void SortIconManager ( IconMgr *ip );
+extern void ActiveIconManager(WList *active);
+extern WList *AddIconManager(TwmWindow *tmp_win);
+extern IconMgr *AllocateIconManager(char *name, char *icon_name, char *geom,
+ int columns);
+extern void CreateIconManagers(void);
+extern void DrawIconManagerBorder(WList *tmp);
+extern void JumpIconManager(int dir);
+extern void MoveIconManager(int dir);
+extern void NotActiveIconManager(WList *active);
+extern void PackIconManager(IconMgr *ip);
+extern void RemoveIconManager(TwmWindow *tmp_win);
+extern void SortIconManager(IconMgr *ip);
-#endif /* _ICONMGR_ */
+#endif /* _ICONMGR_ */
diff --git a/src/icons.c b/src/icons.c
index a3a6588..308ae9f 100644
--- a/src/icons.c
+++ b/src/icons.c
@@ -39,67 +39,69 @@ in this Software without prior written authorization from The Open Group.
#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)
+#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(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 (IconEntry *ie, int grav1, int grav2, int w, int h)
+splitEntry(IconEntry *ie, int grav1, int grav2, int w, int h)
{
- IconEntry *new;
+ 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 = 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;
- ie->y = new->y + new->h;
- } else
- new->y = ie->y + ie->h;
- }
- break;
+ if (w != ie->w)
+ splitEntry(ie, grav2, grav1, w, ie->h);
+ if (h != ie->h) {
+ new = 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;
+ ie->y = new->y + new->h;
+ }
+ else
+ new->y = ie->y + ie->h;
+ }
+ break;
case D_EAST:
case D_WEST:
- if (h != ie->h)
- splitEntry (ie, grav2, grav1, ie->w, h);
- if (w != ie->w) {
- new = malloc (sizeof (IconEntry));
- new->twm_win = 0;
- new->used = 0;
- new->next = ie->next;
- ie->next = new;
- new->y = ie->y;
- 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;
+ if (h != ie->h)
+ splitEntry(ie, grav2, grav1, ie->w, h);
+ if (w != ie->w) {
+ new = malloc(sizeof(IconEntry));
+ new->twm_win = 0;
+ new->used = 0;
+ new->next = ie->next;
+ ie->next = new;
+ new->y = ie->y;
+ 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;
}
}
static inline int
-roundUp (int v, int multiple)
+roundUp(int v, int multiple)
{
return ((v + multiple - 1) / multiple) * multiple;
}
@@ -107,58 +109,59 @@ roundUp (int v, int multiple)
static void
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;
+ 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;
+ 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;
+ 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 (TwmWindow *tmp_win, IconRegion **irp)
+FindIconEntry(TwmWindow *tmp_win, IconRegion **irp)
{
- IconRegion *ir;
- IconEntry *ie;
+ 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;
- }
+ for (ie = ir->entries; ie; ie = ie->next)
+ if (ie->twm_win == tmp_win) {
+ if (irp)
+ *irp = ir;
+ return ie;
+ }
}
return 0;
}
void
-IconUp (TwmWindow *tmp_win)
+IconUp(TwmWindow *tmp_win)
{
- int x, y;
- int defx, defy;
+ int x, y;
+ int defx, defy;
struct IconRegion *ir;
/*
@@ -167,42 +170,42 @@ IconUp (TwmWindow *tmp_win)
* icon region.
*/
if (tmp_win->wmhints && (tmp_win->wmhints->flags & IconPositionHint))
- return;
+ 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 */
+ 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 */
+ XMoveWindow(dpy, tmp_win->icon_w, x, y);
+ tmp_win->icon_moved = FALSE; /* since we've restored it */
}
}
static IconEntry *
-prevIconEntry (IconEntry *ie, IconRegion *ir)
+prevIconEntry(IconEntry *ie, IconRegion *ir)
{
- IconEntry *ip;
+ IconEntry *ip;
if (ie == ir->entries)
- return 0;
- for (ip = ir->entries; ip->next != ie; ip=ip->next)
- ;
+ return 0;
+ for (ip = ir->entries; ip->next != ie; ip = ip->next);
return ip;
}
@@ -211,52 +214,53 @@ prevIconEntry (IconEntry *ie, IconRegion *ir)
* regions together
*/
static void
-mergeEntries (IconEntry *old, IconEntry *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;
+ 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 (TwmWindow *tmp_win)
+IconDown(TwmWindow *tmp_win)
{
- IconEntry *ie, *ip, *in;
- IconRegion *ir;
+ IconEntry *ie, *ip, *in;
+ IconRegion *ir;
- ie = FindIconEntry (tmp_win, &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 (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 (in);
- in = ie->next;
- } else
- break;
- }
+ 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(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(in);
+ in = ie->next;
+ }
+ else
+ break;
+ }
}
}
@@ -269,29 +273,31 @@ AddIconRegion(char *geom, int grav1, int grav2, int stepx, int stepy)
ir = malloc(sizeof(IconRegion));
ir->next = NULL;
if (Scr->LastRegion)
- Scr->LastRegion->next = ir;
+ Scr->LastRegion->next = ir;
Scr->LastRegion = ir;
if (!Scr->FirstRegion)
- Scr->FirstRegion = ir;
+ Scr->FirstRegion = ir;
ir->entries = NULL;
ir->grav1 = grav1;
ir->grav2 = grav2;
if (stepx <= 0)
- stepx = 1;
+ stepx = 1;
if (stepy <= 0)
- stepy = 1;
+ stepy = 1;
ir->stepx = stepx;
ir->stepy = stepy;
ir->x = ir->y = ir->w = ir->h = 0;
- mask = XParseGeometry(geom, &ir->x, &ir->y, (unsigned int *)&ir->w, (unsigned int *)&ir->h);
+ mask =
+ XParseGeometry(geom, &ir->x, &ir->y, (unsigned int *) &ir->w,
+ (unsigned int *) &ir->h);
if (mask & XNegative)
- ir->x += Scr->MyDisplayWidth - ir->w;
+ ir->x += Scr->MyDisplayWidth - ir->w;
if (mask & YNegative)
- ir->y += Scr->MyDisplayHeight - ir->h;
+ ir->y += Scr->MyDisplayHeight - ir->h;
ir->entries = malloc(sizeof(IconEntry));
ir->entries->next = 0;
ir->entries->x = ir->x;
@@ -304,14 +310,13 @@ AddIconRegion(char *geom, int grav1, int grav2, int stepx, int stepy)
#ifdef comment
void
-FreeIconEntries (IconRegion *ir)
+FreeIconEntries(IconRegion *ir)
{
- IconEntry *ie, *tmp;
+ IconEntry *ie, *tmp;
- for (ie = ir->entries; ie; ie=tmp)
- {
- tmp = ie->next;
- free (ie);
+ for (ie = ir->entries; ie; ie = tmp) {
+ tmp = ie->next;
+ free(ie);
}
}
@@ -320,12 +325,11 @@ FreeIconRegions(void)
{
IconRegion *ir, *tmp;
- for (ir = Scr->FirstRegion; ir != NULL;)
- {
- tmp = ir;
- FreeIconEntries (ir);
- ir = ir->next;
- free(tmp);
+ for (ir = Scr->FirstRegion; ir != NULL;) {
+ tmp = ir;
+ FreeIconEntries(ir);
+ ir = ir->next;
+ free(tmp);
}
Scr->FirstRegion = NULL;
Scr->LastRegion = NULL;
@@ -336,13 +340,12 @@ void
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 */
+ 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;
@@ -352,41 +355,40 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y)
* set, then no matter what else is defined, the bitmap from the
* .twmrc file is used
*/
- if (Scr->ForceIcon)
- {
- char *icon_name;
- Pixmap bm;
+ if (Scr->ForceIcon) {
+ char *icon_name;
+ Pixmap bm;
- icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
+ icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
if (icon_name == NULL)
- icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
- &tmp_win->class);
-
- bm = None;
- if (icon_name != NULL)
- {
- if ((bm = (Pixmap)LookInNameList(Scr->Icons, icon_name)) == None)
- {
- if ((bm = GetBitmap (icon_name)) != None)
- AddToList(&Scr->Icons, icon_name, (char *)bm);
- }
- }
-
- if (bm != None)
- {
- XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
- (unsigned int *) &tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height,
- &JunkBW, &JunkDepth);
-
- pm = XCreatePixmap(dpy, Scr->Root, (unsigned)tmp_win->icon_width,
- (unsigned)tmp_win->icon_height, (unsigned)Scr->d_depth);
-
- /* the copy plane works on color ! */
- XCopyPlane(dpy, bm, pm, Scr->NormalGC,
- 0,0, (unsigned)tmp_win->icon_width, (unsigned)tmp_win->icon_height, 0, 0, 1 );
-
- tmp_win->forced = TRUE;
- }
+ icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
+ &tmp_win->class);
+
+ bm = None;
+ if (icon_name != NULL) {
+ if ((bm = (Pixmap) LookInNameList(Scr->Icons, icon_name)) == None) {
+ if ((bm = GetBitmap(icon_name)) != None)
+ AddToList(&Scr->Icons, icon_name, (char *) bm);
+ }
+ }
+
+ if (bm != None) {
+ XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
+ (unsigned int *) &tmp_win->icon_width,
+ (unsigned int *) &tmp_win->icon_height, &JunkBW,
+ &JunkDepth);
+
+ pm = XCreatePixmap(dpy, Scr->Root, (unsigned) tmp_win->icon_width,
+ (unsigned) tmp_win->icon_height,
+ (unsigned) Scr->d_depth);
+
+ /* the copy plane works on color ! */
+ XCopyPlane(dpy, bm, pm, Scr->NormalGC,
+ 0, 0, (unsigned) tmp_win->icon_width,
+ (unsigned) tmp_win->icon_height, 0, 0, 1);
+
+ tmp_win->forced = TRUE;
+ }
}
/* if the pixmap is still NULL, we didn't get one from the above code,
@@ -394,189 +396,185 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y)
* was not in the Icons list, now check the WM hints for an icon
*/
if (pm == None && tmp_win->wmhints &&
- tmp_win->wmhints->flags & IconPixmapHint)
- {
-
- XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap,
- &JunkRoot, &JunkX, &JunkY,
- (unsigned int *)&tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height, &JunkBW, &JunkDepth);
-
- pm = XCreatePixmap(dpy, Scr->Root,
- (unsigned)tmp_win->icon_width, (unsigned)tmp_win->icon_height,
- (unsigned)Scr->d_depth);
-
- XCopyPlane(dpy, tmp_win->wmhints->icon_pixmap, pm, Scr->NormalGC,
- 0,0, (unsigned)tmp_win->icon_width, (unsigned)tmp_win->icon_height, 0, 0, 1 );
+ tmp_win->wmhints->flags & IconPixmapHint) {
+
+ XGetGeometry(dpy, tmp_win->wmhints->icon_pixmap,
+ &JunkRoot, &JunkX, &JunkY,
+ (unsigned int *) &tmp_win->icon_width,
+ (unsigned int *) &tmp_win->icon_height, &JunkBW,
+ &JunkDepth);
+
+ pm = XCreatePixmap(dpy, Scr->Root,
+ (unsigned) tmp_win->icon_width,
+ (unsigned) tmp_win->icon_height,
+ (unsigned) Scr->d_depth);
+
+ XCopyPlane(dpy, tmp_win->wmhints->icon_pixmap, pm, Scr->NormalGC,
+ 0, 0, (unsigned) tmp_win->icon_width,
+ (unsigned) tmp_win->icon_height, 0, 0, 1);
}
/* if we still haven't got an icon, let's look in the Icon list
* if ForceIcon is not set
*/
- if (pm == None && !Scr->ForceIcon)
- {
- char *icon_name;
- Pixmap bm;
+ if (pm == None && !Scr->ForceIcon) {
+ char *icon_name;
+ Pixmap bm;
- icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
+ icon_name = LookInNameList(Scr->IconNames, tmp_win->full_name);
if (icon_name == NULL)
- icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
- &tmp_win->class);
-
- bm = None;
- if (icon_name != NULL)
- {
- if ((bm = (Pixmap)LookInNameList(Scr->Icons, icon_name)) == None)
- {
- if ((bm = GetBitmap (icon_name)) != None)
- AddToList(&Scr->Icons, icon_name, (char *)bm);
- }
- }
-
- if (bm != None)
- {
- XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
- (unsigned int *)&tmp_win->icon_width, (unsigned int *)&tmp_win->icon_height,
- &JunkBW, &JunkDepth);
-
- pm = XCreatePixmap(dpy, Scr->Root, (unsigned)tmp_win->icon_width,
- (unsigned)tmp_win->icon_height, (unsigned)Scr->d_depth);
-
- /* the copy plane works on color ! */
- XCopyPlane(dpy, bm, pm, Scr->NormalGC,
- 0,0, (unsigned)tmp_win->icon_width, (unsigned)tmp_win->icon_height, 0, 0, 1 );
- }
+ icon_name = LookInList(Scr->IconNames, tmp_win->full_name,
+ &tmp_win->class);
+
+ bm = None;
+ if (icon_name != NULL) {
+ if ((bm = (Pixmap) LookInNameList(Scr->Icons, icon_name)) == None) {
+ if ((bm = GetBitmap(icon_name)) != None)
+ AddToList(&Scr->Icons, icon_name, (char *) bm);
+ }
+ }
+
+ if (bm != None) {
+ XGetGeometry(dpy, bm, &JunkRoot, &JunkX, &JunkY,
+ (unsigned int *) &tmp_win->icon_width,
+ (unsigned int *) &tmp_win->icon_height, &JunkBW,
+ &JunkDepth);
+
+ pm = XCreatePixmap(dpy, Scr->Root, (unsigned) tmp_win->icon_width,
+ (unsigned) tmp_win->icon_height,
+ (unsigned) Scr->d_depth);
+
+ /* the copy plane works on color ! */
+ XCopyPlane(dpy, bm, pm, Scr->NormalGC,
+ 0, 0, (unsigned) tmp_win->icon_width,
+ (unsigned) tmp_win->icon_height, 0, 0, 1);
+ }
}
/* if we still don't have an icon, assign the UnknownIcon */
- if (pm == None && Scr->UnknownPm != None)
- {
- tmp_win->icon_width = Scr->UnknownWidth;
- tmp_win->icon_height = Scr->UnknownHeight;
+ if (pm == None && Scr->UnknownPm != None) {
+ tmp_win->icon_width = Scr->UnknownWidth;
+ tmp_win->icon_height = Scr->UnknownHeight;
- pm = XCreatePixmap(dpy, Scr->Root, (unsigned)tmp_win->icon_width,
- (unsigned)tmp_win->icon_height, (unsigned)Scr->d_depth);
+ pm = XCreatePixmap(dpy, Scr->Root, (unsigned) tmp_win->icon_width,
+ (unsigned) tmp_win->icon_height,
+ (unsigned) Scr->d_depth);
- /* the copy plane works on color ! */
- XCopyPlane(dpy, Scr->UnknownPm, pm, Scr->NormalGC,
- 0,0, (unsigned)tmp_win->icon_width, (unsigned)tmp_win->icon_height, 0, 0, 1 );
+ /* the copy plane works on color ! */
+ XCopyPlane(dpy, Scr->UnknownPm, pm, Scr->NormalGC,
+ 0, 0, (unsigned) tmp_win->icon_width,
+ (unsigned) tmp_win->icon_height, 0, 0, 1);
}
- if (pm == None)
- {
- tmp_win->icon_height = 0;
- tmp_win->icon_width = 0;
- valuemask = 0;
+ if (pm == None) {
+ tmp_win->icon_height = 0;
+ tmp_win->icon_width = 0;
+ valuemask = 0;
}
- else
- {
- valuemask = CWBackPixmap;
- attributes.background_pixmap = pm;
+ else {
+ valuemask = CWBackPixmap;
+ attributes.background_pixmap = pm;
}
tmp_win->icon_w_width = MyFont_TextWidth(&Scr->IconFont,
- tmp_win->icon_name, (int)strlen(tmp_win->icon_name));
+ tmp_win->icon_name,
+ (int) strlen(tmp_win->icon_name));
tmp_win->icon_w_width += 6;
- if (tmp_win->icon_w_width < tmp_win->icon_width)
- {
- tmp_win->icon_x = (tmp_win->icon_width - tmp_win->icon_w_width)/2;
- tmp_win->icon_x += 3;
- tmp_win->icon_w_width = tmp_win->icon_width;
+ if (tmp_win->icon_w_width < tmp_win->icon_width) {
+ tmp_win->icon_x = (tmp_win->icon_width - tmp_win->icon_w_width) / 2;
+ tmp_win->icon_x += 3;
+ tmp_win->icon_w_width = tmp_win->icon_width;
}
- else
- {
- tmp_win->icon_x = 3;
+ else {
+ tmp_win->icon_x = 3;
}
tmp_win->icon_y = tmp_win->icon_height + Scr->IconFont.height;
tmp_win->icon_w_height = tmp_win->icon_height + Scr->IconFont.height + 4;
event_mask = 0;
- if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)
- {
- tmp_win->icon_w = tmp_win->wmhints->icon_window;
- if (tmp_win->forced ||
- XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &JunkX, &JunkY,
- (unsigned int *)&tmp_win->icon_w_width, (unsigned int *)&tmp_win->icon_w_height,
- &JunkBW, &JunkDepth) == 0)
- {
- tmp_win->icon_w = None;
- tmp_win->wmhints->flags &= ~IconWindowHint;
- }
- else
- {
- tmp_win->icon_not_ours = TRUE;
- event_mask = EnterWindowMask | LeaveWindowMask;
- }
+ if (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint) {
+ tmp_win->icon_w = tmp_win->wmhints->icon_window;
+ if (tmp_win->forced ||
+ XGetGeometry(dpy, tmp_win->icon_w, &JunkRoot, &JunkX, &JunkY,
+ (unsigned int *) &tmp_win->icon_w_width,
+ (unsigned int *) &tmp_win->icon_w_height, &JunkBW,
+ &JunkDepth) == 0) {
+ tmp_win->icon_w = None;
+ tmp_win->wmhints->flags &= ~IconWindowHint;
+ }
+ else {
+ tmp_win->icon_not_ours = TRUE;
+ event_mask = EnterWindowMask | LeaveWindowMask;
+ }
}
- else
- {
- tmp_win->icon_w = None;
+ else {
+ tmp_win->icon_w = None;
}
- if (tmp_win->icon_w == None)
- {
- tmp_win->icon_w = XCreateSimpleWindow(dpy, Scr->Root,
- 0,0,
- (unsigned)tmp_win->icon_w_width, (unsigned)tmp_win->icon_w_height,
- (unsigned)Scr->IconBorderWidth, tmp_win->icon_border, tmp_win->iconc.back);
- event_mask = ExposureMask;
+ if (tmp_win->icon_w == None) {
+ tmp_win->icon_w = XCreateSimpleWindow(dpy, Scr->Root,
+ 0, 0,
+ (unsigned) tmp_win->icon_w_width,
+ (unsigned) tmp_win->icon_w_height,
+ (unsigned) Scr->IconBorderWidth,
+ tmp_win->icon_border,
+ tmp_win->iconc.back);
+ event_mask = ExposureMask;
}
- XSelectInput (dpy, tmp_win->icon_w,
- (long)(KeyPressMask | ButtonPressMask | ButtonReleaseMask |
- event_mask));
+ XSelectInput(dpy, tmp_win->icon_w,
+ (long) (KeyPressMask | ButtonPressMask | ButtonReleaseMask |
+ event_mask));
tmp_win->icon_bm_w = None;
if (pm != None &&
- (! (tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint)))
- {
- int y;
-
- y = 0;
- if (tmp_win->icon_w_width == tmp_win->icon_width)
- x = 0;
- else
- x = (tmp_win->icon_w_width - tmp_win->icon_width)/2;
-
- tmp_win->icon_bm_w = XCreateWindow (dpy, tmp_win->icon_w, x, y,
- (unsigned int)tmp_win->icon_width,
- (unsigned int)tmp_win->icon_height,
- (unsigned int) 0, Scr->d_depth,
- (unsigned int) CopyFromParent,
- Scr->d_visual, valuemask,
- &attributes);
+ (!(tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint))) {
+ int y;
+
+ y = 0;
+ if (tmp_win->icon_w_width == tmp_win->icon_width)
+ x = 0;
+ else
+ x = (tmp_win->icon_w_width - tmp_win->icon_width) / 2;
+
+ tmp_win->icon_bm_w = XCreateWindow(dpy, tmp_win->icon_w, x, y,
+ (unsigned int) tmp_win->icon_width,
+ (unsigned int) tmp_win->icon_height,
+ (unsigned int) 0, Scr->d_depth,
+ (unsigned int) CopyFromParent,
+ Scr->d_visual, valuemask,
+ &attributes);
}
/* I need to figure out where to put the icon window now, because
* getting here means that I am going to make the icon visible
*/
- if (tmp_win->wmhints &&
- tmp_win->wmhints->flags & IconPositionHint)
- {
- final_x = tmp_win->wmhints->icon_x;
- final_y = tmp_win->wmhints->icon_y;
+ if (tmp_win->wmhints && tmp_win->wmhints->flags & IconPositionHint) {
+ final_x = tmp_win->wmhints->icon_x;
+ final_y = tmp_win->wmhints->icon_y;
}
- else
- {
- PlaceIcon(tmp_win, def_x, def_y, &final_x, &final_y);
+ else {
+ PlaceIcon(tmp_win, def_x, def_y, &final_x, &final_y);
}
if (final_x > Scr->MyDisplayWidth)
- final_x = Scr->MyDisplayWidth - tmp_win->icon_w_width -
- (2 * Scr->IconBorderWidth);
+ final_x = Scr->MyDisplayWidth - tmp_win->icon_w_width -
+ (2 * Scr->IconBorderWidth);
if (final_y > Scr->MyDisplayHeight)
- final_y = Scr->MyDisplayHeight - tmp_win->icon_height -
- Scr->IconFont.height - 4 - (2 * Scr->IconBorderWidth);
+ final_y = Scr->MyDisplayHeight - tmp_win->icon_height -
+ Scr->IconFont.height - 4 - (2 * Scr->IconBorderWidth);
XMoveWindow(dpy, tmp_win->icon_w, final_x, final_y);
tmp_win->iconified = TRUE;
XMapSubwindows(dpy, tmp_win->icon_w);
- XSaveContext(dpy, tmp_win->icon_w, TwmContext, (XPointer)tmp_win);
- XSaveContext(dpy, tmp_win->icon_w, ScreenContext, (XPointer)Scr);
+ XSaveContext(dpy, tmp_win->icon_w, TwmContext, (XPointer) tmp_win);
+ XSaveContext(dpy, tmp_win->icon_w, ScreenContext, (XPointer) Scr);
XDefineCursor(dpy, tmp_win->icon_w, Scr->IconCursor);
- if (pm) XFreePixmap (dpy, pm);
+ if (pm)
+ XFreePixmap(dpy, pm);
return;
}
diff --git a/src/icons.h b/src/icons.h
index f05e8ff..4945967 100644
--- a/src/icons.h
+++ b/src/icons.h
@@ -34,27 +34,25 @@ in this Software without prior written authorization from The Open Group.
#ifndef ICONS_H
#define ICONS_H
-typedef struct IconRegion
-{
- struct IconRegion *next;
- int x, y, w, h;
- int grav1, grav2;
- int stepx, stepy; /* allocation granularity */
- struct IconEntry *entries;
+typedef struct IconRegion {
+ struct IconRegion *next;
+ int x, y, w, h;
+ int grav1, grav2;
+ int stepx, stepy; /* allocation granularity */
+ struct IconEntry *entries;
} IconRegion;
-typedef struct IconEntry
-{
- struct IconEntry *next;
- int x, y, w, h;
- TwmWindow *twm_win;
- short used;
-}IconEntry;
-
-extern void IconUp ( TwmWindow *tmp_win );
-extern void IconDown ( TwmWindow *tmp_win );
-extern void AddIconRegion ( char *geom, int grav1, int grav2,
- int stepx, int stepy );
-extern void CreateIconWindow ( TwmWindow *tmp_win, int def_x, int def_y );
-
-#endif /* ICONS_H */
+typedef struct IconEntry {
+ struct IconEntry *next;
+ int x, y, w, h;
+ TwmWindow *twm_win;
+ short used;
+} IconEntry;
+
+extern void IconUp(TwmWindow *tmp_win);
+extern void IconDown(TwmWindow *tmp_win);
+extern void AddIconRegion(char *geom, int grav1, int grav2,
+ int stepx, int stepy);
+extern void CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y);
+
+#endif /* ICONS_H */
diff --git a/src/list.c b/src/list.c
index 2fa41d3..9d9bec8 100644
--- a/src/list.c
+++ b/src/list.c
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/**********************************************************************
*
* TWM code to deal with the name lists for the NoTitle list and
@@ -65,8 +64,7 @@ in this Software without prior written authorization from The Open Group.
#include "gram.h"
#include "util.h"
-struct name_list_struct
-{
+struct name_list_struct {
name_list *next; /**< pointer to the next name */
char *name; /**< the name of the window */
char *ptr; /**< list dependent data */
@@ -75,34 +73,34 @@ struct name_list_struct
/**
* add a window name to the appropriate list.
*
- * 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.
+ * 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(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 */
+ if (!list_head)
+ return; /* ignore empty inserts */
nptr = 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);
+ 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;
+ nptr->ptr = (ptr == NULL) ? (char *) TRUE : ptr;
*list_head = nptr;
}
@@ -110,39 +108,38 @@ AddToList(name_list **list_head, char *name, char *ptr)
* look through a list for a window name, or class
*
* \return the ptr field of the list structure or NULL if the name
- * or class was not found in the list
+ * or class was not found in the list
*
- * \param list a pointer to the head of a list
- * \param name a pointer to the name 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(name_list *list_head, const char *name, XClassHint *class)
+LookInList(name_list * list_head, const 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);
+ 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(name_list *list_head, const char *name)
+LookInNameList(name_list * list_head, const char *name)
{
return (LookInList(list_head, name, NULL));
}
@@ -156,45 +153,42 @@ LookInNameList(name_list *list_head, const char *name)
* \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
+ * \param[out] ptr fill in the list value if the name was found
*/
-int GetColorFromList(name_list *list_head, const char *name, XClassHint *class,
- Pixel *ptr)
+int
+GetColorFromList(name_list * list_head, const 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 = (short)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 = (short)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 = (short)save;
- return (TRUE);
- }
+ if (strcmp(name, nptr->name) == 0) {
+ save = Scr->FirstTime;
+ Scr->FirstTime = TRUE;
+ GetColor(Scr->Monochrome, ptr, nptr->ptr);
+ Scr->FirstTime = (short) 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 = (short) 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 = (short) save;
+ return (TRUE);
+ }
}
return (FALSE);
}
@@ -202,16 +196,16 @@ int GetColorFromList(name_list *list_head, const char *name, XClassHint *class,
/**
* free up a list
*/
-void FreeList(name_list **list)
+void
+FreeList(name_list ** list)
{
name_list *nptr;
name_list *tmp;
- for (nptr = *list; nptr != NULL; )
- {
- tmp = nptr->next;
- free(nptr);
- nptr = tmp;
+ for (nptr = *list; nptr != NULL;) {
+ tmp = nptr->next;
+ free(nptr);
+ nptr = tmp;
}
*list = NULL;
}
diff --git a/src/list.h b/src/list.h
index bb6fbc8..d9a4acd 100644
--- a/src/list.h
+++ b/src/list.h
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/**********************************************************************
*
* TWM list handling external definitions
@@ -67,15 +66,13 @@ in this Software without prior written authorization from The Open Group.
typedef struct name_list_struct name_list;
-extern void AddToList ( name_list **list_head, char *name, char *ptr );
-extern void FreeList ( name_list **list );
-
-extern int GetColorFromList ( name_list *list_head, const char *name,
- XClassHint *class, Pixel *ptr );
-extern char * LookInList ( name_list *list_head, const char *name,
- XClassHint *class );
-extern char * LookInNameList ( name_list *list_head, const char *name );
-
+extern void AddToList(name_list ** list_head, char *name, char *ptr);
+extern void FreeList(name_list ** list);
-#endif /* _LIST_ */
+extern int GetColorFromList(name_list * list_head, const char *name,
+ XClassHint *class, Pixel *ptr);
+extern char *LookInList(name_list * list_head, const char *name,
+ XClassHint *class);
+extern char *LookInNameList(name_list * list_head, const char *name);
+#endif /* _LIST_ */
diff --git a/src/menus.c b/src/menus.c
index 4401101..7ce0e49 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -49,17 +49,16 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* twm menu code
*
- * 17-Nov-87 Thomas E. LaStrange File created
+ * 17-Nov-87 Thomas E. LaStrange File created
*
***********************************************************************/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
@@ -84,13 +83,13 @@ in this Software without prior written authorization from The Open Group.
#include <X11/SM/SMlib.h>
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;
@@ -104,31 +103,28 @@ int ConstMoveYB;
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 );
-static void BumpWindowColormap ( TwmWindow *tmp, int inc );
-static int DeferExecution ( int context, int func, Cursor cursor );
-static Bool NeedToDefer ( MenuRoot *root );
-static void DestroyMenu ( MenuRoot *menu );
-static void MakeMenu ( MenuRoot *mr );
-static void Execute ( const char *s );
-static void HideIconManager ( void );
-static void WarpAlongRing ( XButtonEvent *ev, Bool forward );
-static int WarpThere ( TwmWindow * t );
-static void WarpToWindow ( TwmWindow *t );
-
-#define SHADOWWIDTH 5 /* in pixels */
-
-
-
+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);
+static void BumpWindowColormap(TwmWindow *tmp, int inc);
+static int DeferExecution(int context, int func, Cursor cursor);
+static Bool NeedToDefer(MenuRoot *root);
+static void DestroyMenu(MenuRoot *menu);
+static void MakeMenu(MenuRoot *mr);
+static void Execute(const char *s);
+static void HideIconManager(void);
+static void WarpAlongRing(XButtonEvent *ev, Bool forward);
+static int WarpThere(TwmWindow *t);
+static void WarpToWindow(TwmWindow *t);
+
+#define SHADOWWIDTH 5 /* in pixels */
/**
* initialize menu roots
@@ -139,33 +135,28 @@ InitMenus(void)
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;
- }
+ 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(tmp);
- }
- Scr->FuncKeyRoot.next = NULL;
+ if (FirstScreen) {
+ for (key = Scr->FuncKeyRoot.next; key != NULL;) {
+ free(key->name);
+ tmp = key;
+ key = key->next;
+ free(tmp);
+ }
+ Scr->FuncKeyRoot.next = NULL;
}
}
-
-
/**
* add a function key to the list
*
@@ -176,8 +167,9 @@ InitMenus(void)
* \param win_name the window name (if any)
* \param action the action string associated with the function (if any)
*/
-Bool AddFuncKey (char *name, int cont, int mods2, int func, char *win_name,
- char *action)
+Bool
+AddFuncKey(char *name, int cont, int mods2, int func, char *win_name,
+ char *action)
{
FuncKey *tmp;
KeySym keysym;
@@ -188,25 +180,20 @@ Bool AddFuncKey (char *name, int cont, int mods2, int func, char *win_name,
* XGrabKey call in GrabKeys().
*/
if ((keysym = XStringToKeysym(name)) == NoSymbol ||
- (keycode = XKeysymToKeycode(dpy, keysym)) == 0)
- {
- return False;
+ (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 &&
- tmp->mods == mods2)
- break;
+ for (tmp = Scr->FuncKeyRoot.next; tmp != NULL; tmp = tmp->next) {
+ if (tmp->keysym == keysym && tmp->cont == cont && tmp->mods == mods2)
+ break;
}
- if (tmp == NULL)
- {
- tmp = malloc(sizeof(FuncKey));
- tmp->next = Scr->FuncKeyRoot.next;
- Scr->FuncKeyRoot.next = tmp;
+ if (tmp == NULL) {
+ tmp = malloc(sizeof(FuncKey));
+ tmp->next = Scr->FuncKeyRoot.next;
+ Scr->FuncKeyRoot.next = tmp;
}
tmp->name = name;
@@ -221,33 +208,33 @@ Bool AddFuncKey (char *name, int cont, int mods2, int func, char *win_name,
return True;
}
-
-
-int CreateTitleButton (const char *name, int func, const char *action,
- MenuRoot *menuroot, Bool rightside, Bool append)
+int
+CreateTitleButton(const char *name, int func, const char *action,
+ MenuRoot *menuroot, Bool rightside, Bool append)
{
- TitleButton *tb = malloc (sizeof(TitleButton));
+ TitleButton *tb = malloc(sizeof(TitleButton));
if (!tb) {
- fprintf (stderr,
- "%s: unable to allocate %ld bytes for title button\n",
- ProgramName, (unsigned long)sizeof(TitleButton));
- return 0;
+ 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->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) {
- Scr->TBInfo.nright++;
- } else {
- Scr->TBInfo.nleft++;
+ Scr->TBInfo.nright++;
+ }
+ else {
+ Scr->TBInfo.nleft++;
}
/*
@@ -260,40 +247,44 @@ int CreateTitleButton (const char *name, int func, const char *action,
* Do not refer to widths and heights yet since buttons not created
* (since fonts not loaded and heights not known).
*/
- if ((!Scr->TBInfo.head) || ((!append) && (!rightside))) { /* 1 */
- tb->next = Scr->TBInfo.head;
- Scr->TBInfo.head = tb;
- } else if (append && rightside) { /* 3 */
- register TitleButton *t;
- for /* SUPPRESS 530 */
- (t = Scr->TBInfo.head; t->next; t = t->next);
- t->next = tb;
- 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;
- }
+ if ((!Scr->TBInfo.head) || ((!append) && (!rightside))) { /* 1 */
+ tb->next = Scr->TBInfo.head;
+ Scr->TBInfo.head = tb;
+ }
+ else if (append && rightside) { /* 3 */
+ register TitleButton *t;
+
+ /* SUPPRESS 530 */
+ for (t = Scr->TBInfo.head; t->next; t = t->next);
+ t->next = tb;
+ 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;
}
-
-
/**
* 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 (void)
+void
+InitTitlebarButtons(void)
{
TitleButton *tb;
int h;
@@ -302,9 +293,9 @@ void InitTitlebarButtons (void)
* initialize dimensions
*/
Scr->TBInfo.width = (Scr->TitleHeight -
- 2 * (Scr->FramePadding + Scr->ButtonIndent));
+ 2 * (Scr->FramePadding + Scr->ButtonIndent));
Scr->TBInfo.pad = ((Scr->TitlePadding > 1)
- ? ((Scr->TitlePadding + 1) / 2) : 1);
+ ? ((Scr->TitlePadding + 1) / 2) : 1);
h = Scr->TBInfo.width - 2 * Scr->TBInfo.border;
/*
@@ -312,57 +303,55 @@ void InitTitlebarButtons (void)
* use the system.
*/
if (!Scr->NoDefaults) {
- /* insert extra buttons */
- if (!CreateTitleButton (TBPM_ICONIFY, F_ICONIFY, "", (MenuRoot *) NULL,
- False, False)) {
- fprintf (stderr, "%s: unable to add iconify button\n",
- ProgramName);
- }
- if (!CreateTitleButton (TBPM_RESIZE, F_RESIZE, "", (MenuRoot *) NULL,
- True, True)) {
- fprintf (stderr, "%s: unable to add resize button\n",
- ProgramName);
- }
- AddDefaultBindings ();
- }
- ComputeCommonTitleOffsets ();
+ /* insert extra buttons */
+ if (!CreateTitleButton(TBPM_ICONIFY, F_ICONIFY, "", (MenuRoot *) NULL,
+ False, False)) {
+ fprintf(stderr, "%s: unable to add iconify button\n", ProgramName);
+ }
+ if (!CreateTitleButton(TBPM_RESIZE, F_RESIZE, "", (MenuRoot *) NULL,
+ True, True)) {
+ fprintf(stderr, "%s: unable to add resize button\n", ProgramName);
+ }
+ AddDefaultBindings();
+ }
+ ComputeCommonTitleOffsets();
/*
* load in images and do appropriate centering
*/
for (tb = Scr->TBInfo.head; tb; tb = tb->next) {
- tb->bitmap = FindBitmap (tb->name, &tb->width, &tb->height);
- if (!tb->bitmap) {
- tb->bitmap = FindBitmap (TBPM_QUESTION, &tb->width, &tb->height);
- if (!tb->bitmap) { /* cannot happen (see util.c) */
- fprintf (stderr,
- "%s: unable to add titlebar button \"%s\"\n",
- ProgramName, tb->name);
- }
- }
-
- tb->dstx = (int)(((unsigned)h - tb->width + 1) / 2);
- if (tb->dstx < 0) { /* clip to minimize copying */
- tb->srcx = -(tb->dstx);
- tb->width = (unsigned)h;
- tb->dstx = 0;
- } else {
- tb->srcx = 0;
- }
- tb->dsty = (int)(((unsigned)h - tb->height + 1) / 2);
- if (tb->dsty < 0) {
- tb->srcy = -(tb->dsty);
- tb->height = (unsigned)h;
- tb->dsty = 0;
- } else {
- tb->srcy = 0;
- }
+ tb->bitmap = FindBitmap(tb->name, &tb->width, &tb->height);
+ if (!tb->bitmap) {
+ tb->bitmap = FindBitmap(TBPM_QUESTION, &tb->width, &tb->height);
+ if (!tb->bitmap) { /* cannot happen (see util.c) */
+ fprintf(stderr,
+ "%s: unable to add titlebar button \"%s\"\n",
+ ProgramName, tb->name);
+ }
+ }
+
+ tb->dstx = (int) (((unsigned) h - tb->width + 1) / 2);
+ if (tb->dstx < 0) { /* clip to minimize copying */
+ tb->srcx = -(tb->dstx);
+ tb->width = (unsigned) h;
+ tb->dstx = 0;
+ }
+ else {
+ tb->srcx = 0;
+ }
+ tb->dsty = (int) (((unsigned) h - tb->height + 1) / 2);
+ if (tb->dsty < 0) {
+ tb->srcy = -(tb->dsty);
+ tb->height = (unsigned) h;
+ tb->dsty = 0;
+ }
+ else {
+ tb->srcy = 0;
+ }
}
}
-
-
void
PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure)
{
@@ -376,109 +365,99 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure)
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,
- (unsigned)mr->width, (unsigned)Scr->EntryHeight);
-
- MyFont_ChangeGC(mi->hi_fore, mi->hi_back, &Scr->MenuFont);
-
- MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, Scr->NormalGC, mi->x,
- text_y, mi->item, mi->strlen);
-
- gc = Scr->NormalGC;
- }
- else
- {
- if (mi->user_colors || !exposure)
- {
- XSetForeground(dpy, Scr->NormalGC, mi->back);
-
- XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset,
- (unsigned)mr->width, (unsigned)Scr->EntryHeight);
-
- MyFont_ChangeGC(mi->fore, mi->back, &Scr->MenuFont);
- gc = Scr->NormalGC;
- }
- else
- gc = Scr->MenuGC;
-
- MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, gc,
- mi->x, text_y, mi->item, mi->strlen);
-
- }
-
- if (mi->func == F_MENU)
- {
- /* create the pull right pixmap if needed */
- if (Scr->pullPm == None)
- {
- Scr->pullPm = CreateMenuIcon (Scr->MenuFont.height,
- &Scr->pullW, &Scr->pullH);
- }
- x = (int)((unsigned)mr->width - (Scr->pullW + 5));
- y = (int)((unsigned)y_offset + (((unsigned)Scr->MenuFont.height - Scr->pullH) / 2));
- XCopyPlane(dpy, Scr->pullPm, mr->w, gc, 0, 0,
- Scr->pullW, Scr->pullH, x, y, 1);
- }
+ 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,
+ (unsigned) mr->width, (unsigned) Scr->EntryHeight);
+
+ MyFont_ChangeGC(mi->hi_fore, mi->hi_back, &Scr->MenuFont);
+
+ MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, Scr->NormalGC, mi->x,
+ text_y, mi->item, mi->strlen);
+
+ gc = Scr->NormalGC;
+ }
+ else {
+ if (mi->user_colors || !exposure) {
+ XSetForeground(dpy, Scr->NormalGC, mi->back);
+
+ XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset,
+ (unsigned) mr->width,
+ (unsigned) Scr->EntryHeight);
+
+ MyFont_ChangeGC(mi->fore, mi->back, &Scr->MenuFont);
+ gc = Scr->NormalGC;
+ }
+ else
+ gc = Scr->MenuGC;
+
+ MyFont_DrawString(dpy, mr->w, &Scr->MenuFont, gc,
+ mi->x, text_y, mi->item, mi->strlen);
+
+ }
+
+ if (mi->func == F_MENU) {
+ /* create the pull right pixmap if needed */
+ if (Scr->pullPm == None) {
+ Scr->pullPm = CreateMenuIcon(Scr->MenuFont.height,
+ &Scr->pullW, &Scr->pullH);
+ }
+ x = (int) ((unsigned) mr->width - (Scr->pullW + 5));
+ y = (int) ((unsigned) y_offset +
+ (((unsigned) Scr->MenuFont.height - Scr->pullH) / 2));
+ XCopyPlane(dpy, Scr->pullPm, mr->w, gc, 0, 0, Scr->pullW,
+ Scr->pullH, x, y, 1);
+ }
}
- else
- {
- int y;
+ else {
+ int y;
- XSetForeground(dpy, Scr->NormalGC, mi->back);
+ XSetForeground(dpy, Scr->NormalGC, mi->back);
- /* fill the rectangle with the title background color */
- XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset,
- (unsigned)mr->width, (unsigned)Scr->EntryHeight);
+ /* fill the rectangle with the title background color */
+ XFillRectangle(dpy, mr->w, Scr->NormalGC, 0, y_offset,
+ (unsigned) mr->width, (unsigned) Scr->EntryHeight);
- {
- 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);
- }
+ {
+ 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);
+ 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(MenuRoot *mr, XEvent *e)
{
MenuItem *mi;
- for (mi = mr->first; mi != NULL; mi = mi->next)
- {
- int y_offset = mi->item_num * Scr->EntryHeight;
+ 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);
- }
+ /* 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);
}
-
-
static Bool fromMenu;
void
@@ -492,135 +471,126 @@ UpdateMenu(void)
fromMenu = TRUE;
- while (TRUE)
- {
- /* block until there is an event */
+ while (TRUE) {
+ /* block until there is an event */
if (!menuFromFrameOrWindowOrTitlebar) {
- XMaskEvent(dpy,
- ButtonPressMask | ButtonReleaseMask |
- EnterWindowMask | ExposureMask |
- VisibilityChangeMask | LeaveWindowMask |
- ButtonMotionMask, &Event);
- }
- if (Event.type == MotionNotify) {
- /* discard any extra motion events before a release */
- while(XCheckMaskEvent(dpy,
- ButtonMotionMask | ButtonReleaseMask, &Event))
- if (Event.type == ButtonRelease)
- break;
- }
-
- if (!DispatchEvent ())
- continue;
-
- if (Event.type == ButtonRelease || Cancel) {
- menuFromFrameOrWindowOrTitlebar = FALSE;
- fromMenu = FALSE;
- return;
- }
-
- if (Event.type != MotionNotify)
- continue;
-
- if (!ActiveMenu)
+ XMaskEvent(dpy,
+ ButtonPressMask | ButtonReleaseMask |
+ EnterWindowMask | ExposureMask |
+ VisibilityChangeMask | LeaveWindowMask |
+ ButtonMotionMask, &Event);
+ }
+ if (Event.type == MotionNotify) {
+ /* discard any extra motion events before a release */
+ while (XCheckMaskEvent(dpy,
+ ButtonMotionMask | ButtonReleaseMask,
+ &Event))
+ if (Event.type == ButtonRelease)
+ break;
+ }
+
+ if (!DispatchEvent())
continue;
- done = FALSE;
- XQueryPointer( dpy, ActiveMenu->w, &JunkRoot, &JunkChild,
- &x_root, &y_root, &x, &y, &JunkMask);
-
- /* if we haven't recieved the enter notify yet, wait */
- if (!ActiveMenu->entered)
- continue;
-
- if (XFindContext(dpy, ActiveMenu->w, ScreenContext, &context_data) == 0)
- Scr = (struct ScreenInfo *) context_data;
-
- if (x < 0 || y < 0 ||
- x >= ActiveMenu->width || y >= ActiveMenu->height)
- {
- if (ActiveItem && ActiveItem->func != F_TITLE)
- {
- ActiveItem->state = 0;
- PaintEntry(ActiveMenu, ActiveItem, False);
- }
- ActiveItem = NULL;
- continue;
- }
-
- /* look for the entry that the mouse is in */
- entry = y / Scr->EntryHeight;
- for (i = 0, mi = ActiveMenu->first; mi != NULL; i++, mi=mi->next)
- {
- if (i == entry)
- break;
- }
-
- /* if there is an active item, we might have to turn it off */
- if (ActiveItem)
- {
- /* is the active item the one we are on ? */
- if (ActiveItem->item_num == entry && ActiveItem->state)
- done = TRUE;
-
- /* if we weren't on the active entry, let's turn the old
- * active one off
- */
- if (!done && ActiveItem->func != F_TITLE)
- {
- ActiveItem->state = 0;
- PaintEntry(ActiveMenu, ActiveItem, False);
- }
- }
-
- /* if we weren't on the active item, change the active item and turn
- * it on
- */
- if (!done)
- {
- ActiveItem = mi;
- if (ActiveItem && ActiveItem->func != F_TITLE && !ActiveItem->state)
- {
- ActiveItem->state = 1;
- PaintEntry(ActiveMenu, ActiveItem, False);
- }
- }
-
- /* now check to see if we were over the arrow of a pull right entry */
- if (ActiveItem && ActiveItem->func == F_MENU &&
- ((ActiveMenu->width - x) < (ActiveMenu->width >> 1)))
- {
- MenuRoot *save = ActiveMenu;
- int savex = MenuOrigins[MenuDepth - 1].x;
- int savey = MenuOrigins[MenuDepth - 1].y;
-
- if (MenuDepth < MAXMENUDEPTH) {
- PopUpMenu (ActiveItem->sub,
- (savex + (ActiveMenu->width >> 1)),
- (savey + ActiveItem->item_num * Scr->EntryHeight)
- /*(savey + ActiveItem->item_num * Scr->EntryHeight +
- (Scr->EntryHeight >> 1))*/, False);
- } else if (!badItem) {
- 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);
+ if (Event.type == ButtonRelease || Cancel) {
+ menuFromFrameOrWindowOrTitlebar = FALSE;
+ fromMenu = FALSE;
+ return;
+ }
+
+ if (Event.type != MotionNotify)
+ continue;
+
+ if (!ActiveMenu)
+ continue;
+
+ done = FALSE;
+ XQueryPointer(dpy, ActiveMenu->w, &JunkRoot, &JunkChild,
+ &x_root, &y_root, &x, &y, &JunkMask);
+
+ /* if we haven't recieved the enter notify yet, wait */
+ if (!ActiveMenu->entered)
+ continue;
+
+ if (XFindContext(dpy, ActiveMenu->w, ScreenContext, &context_data) == 0)
+ Scr = (struct ScreenInfo *) context_data;
+
+ if (x < 0 || y < 0 || x >= ActiveMenu->width || y >= ActiveMenu->height) {
+ if (ActiveItem && ActiveItem->func != F_TITLE) {
+ ActiveItem->state = 0;
+ PaintEntry(ActiveMenu, ActiveItem, False);
+ }
+ ActiveItem = NULL;
+ continue;
+ }
+
+ /* look for the entry that the mouse is in */
+ entry = y / Scr->EntryHeight;
+ for (i = 0, mi = ActiveMenu->first; mi != NULL; i++, mi = mi->next) {
+ if (i == entry)
+ break;
+ }
+
+ /* if there is an active item, we might have to turn it off */
+ if (ActiveItem) {
+ /* is the active item the one we are on ? */
+ if (ActiveItem->item_num == entry && ActiveItem->state)
+ done = TRUE;
+
+ /* if we weren't on the active entry, let's turn the old
+ * active one off
+ */
+ if (!done && ActiveItem->func != F_TITLE) {
+ ActiveItem->state = 0;
+ PaintEntry(ActiveMenu, ActiveItem, False);
+ }
+ }
+
+ /* if we weren't on the active item, change the active item and turn
+ * it on
+ */
+ if (!done) {
+ ActiveItem = mi;
+ if (ActiveItem && ActiveItem->func != F_TITLE && !ActiveItem->state) {
+ ActiveItem->state = 1;
+ PaintEntry(ActiveMenu, ActiveItem, False);
+ }
+ }
+
+ /* now check to see if we were over the arrow of a pull right entry */
+ if (ActiveItem && ActiveItem->func == F_MENU &&
+ ((ActiveMenu->width - x) < (ActiveMenu->width >> 1))) {
+ MenuRoot *save = ActiveMenu;
+ int savex = MenuOrigins[MenuDepth - 1].x;
+ int savey = MenuOrigins[MenuDepth - 1].y;
+
+ if (MenuDepth < MAXMENUDEPTH) {
+ PopUpMenu(ActiveItem->sub,
+ (savex + (ActiveMenu->width >> 1)),
+ (savey + ActiveItem->item_num * Scr->EntryHeight)
+ /*(savey + ActiveItem->item_num * Scr->EntryHeight +
+ (Scr->EntryHeight >> 1)) */
+ , False);
+ }
+ else if (!badItem) {
+ 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
*
@@ -631,7 +601,7 @@ NewMenuRoot(const char *name)
{
MenuRoot *tmp;
-#define UNUSED_PIXEL ((unsigned long) (~0)) /* more than 24 bits */
+#define UNUSED_PIXEL ((unsigned long) (~0)) /* more than 24 bits */
tmp = malloc(sizeof(MenuRoot));
tmp->hi_fore = UNUSED_PIXEL;
@@ -648,32 +618,27 @@ NewMenuRoot(const char *name)
tmp->shadow = None;
tmp->real_menu = FALSE;
- if (Scr->MenuList == NULL)
- {
- Scr->MenuList = tmp;
- Scr->MenuList->next = NULL;
+ if (Scr->MenuList == NULL) {
+ Scr->MenuList = tmp;
+ Scr->MenuList->next = NULL;
}
- if (Scr->LastMenu == NULL)
- {
- Scr->LastMenu = tmp;
- Scr->LastMenu->next = NULL;
+ if (Scr->LastMenu == NULL) {
+ Scr->LastMenu = tmp;
+ Scr->LastMenu->next = NULL;
}
- else
- {
- Scr->LastMenu->next = tmp;
- 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;
+ Scr->Windows = tmp;
return (tmp);
}
-
-
/**
* add an item to a root menu
*
@@ -694,77 +659,71 @@ AddToMenu(MenuRoot *menu, const char *item, const char *action,
#ifdef DEBUG_MENUS
fprintf(stderr, "adding menu item=\"%s\", action=%s, sub=%d, f=%d\n",
- item, action, sub, func);
+ item, action, sub, func);
#endif
tmp = malloc(sizeof(MenuItem));
tmp->root = menu;
- if (menu->first == NULL)
- {
- menu->first = tmp;
- tmp->prev = NULL;
+ if (menu->first == NULL) {
+ menu->first = tmp;
+ tmp->prev = NULL;
}
- else
- {
- menu->last->next = tmp;
- tmp->prev = menu->last;
+ else {
+ menu->last->next = tmp;
+ tmp->prev = menu->last;
}
menu->last = tmp;
tmp->item = item;
- tmp->strlen = (short)strlen(item);
+ tmp->strlen = (short) strlen(item);
tmp->action = action;
tmp->next = NULL;
tmp->sub = NULL;
tmp->state = 0;
- tmp->func = (short)func;
+ tmp->func = (short) func;
- if (!Scr->HaveFonts) CreateFonts();
+ if (!Scr->HaveFonts)
+ CreateFonts();
width = MyFont_TextWidth(&Scr->MenuFont, item, tmp->strlen);
if (width <= 0)
- width = 1;
+ width = 1;
if (width > menu->width)
- menu->width = (short)width;
+ menu->width = (short) width;
tmp->user_colors = FALSE;
- if (Scr->Monochrome == COLOR && fore != NULL)
- {
- int save;
-
- save = Scr->FirstTime;
- Scr->FirstTime = TRUE;
- GetColor(COLOR, &tmp->fore, fore);
- GetColor(COLOR, &tmp->back, back);
- Scr->FirstTime = (short)save;
- tmp->user_colors = TRUE;
+ if (Scr->Monochrome == COLOR && fore != NULL) {
+ int save;
+
+ save = Scr->FirstTime;
+ Scr->FirstTime = TRUE;
+ GetColor(COLOR, &tmp->fore, fore);
+ GetColor(COLOR, &tmp->back, back);
+ Scr->FirstTime = (short) save;
+ tmp->user_colors = TRUE;
}
- if (sub != NULL)
- {
- tmp->sub = sub;
- menu->pull = TRUE;
+ if (sub != NULL) {
+ tmp->sub = sub;
+ menu->pull = TRUE;
}
tmp->item_num = menu->items++;
return (tmp);
}
-
void
MakeMenus(void)
{
MenuRoot *mr;
- for (mr = Scr->MenuList; mr != NULL; mr = mr->next)
- {
- if (mr->real_menu == FALSE)
- continue;
+ for (mr = Scr->MenuList; mr != NULL; mr = mr->next) {
+ if (mr->real_menu == FALSE)
+ continue;
- MakeMenu(mr);
+ MakeMenu(mr);
}
}
-
static void
MakeMenu(MenuRoot *mr)
{
@@ -783,181 +742,169 @@ MakeMenu(MenuRoot *mr)
Scr->EntryHeight = Scr->MenuFont.height + 4;
/* lets first size the window accordingly */
- if (mr->mapped == NEVER_MAPPED)
- {
- if (mr->pull == TRUE)
- {
- mr->width = (short)(mr->width + (16 + 10));
- }
-
- width = mr->width + 10;
-
- for (cur = mr->first; cur != NULL; cur = cur->next)
- {
- if (cur->func != F_TITLE)
- cur->x = 5;
- else
- {
- cur->x = (short)(width - MyFont_TextWidth(&Scr->MenuFont, cur->item,
- cur->strlen));
- cur->x /= 2;
- }
- }
- mr->height = (short)(mr->items * Scr->EntryHeight);
- mr->width = (short)(mr->width + 10);
-
- if (Scr->Shadow)
- {
- /*
- * Make sure that you don't draw into the shadow window or else
- * the background bits there will get saved
- */
- valuemask = (CWBackPixel | CWBorderPixel);
- attributes.background_pixel = Scr->MenuShadowColor;
- attributes.border_pixel = Scr->MenuShadowColor;
- if (Scr->SaveUnder) {
- valuemask |= CWSaveUnder;
- attributes.save_under = True;
- }
- mr->shadow = XCreateWindow (dpy, Scr->Root, 0, 0,
- (unsigned int) mr->width,
- (unsigned int) mr->height,
- (unsigned int)0,
- CopyFromParent,
- (unsigned int) CopyFromParent,
- (Visual *) CopyFromParent,
- valuemask, &attributes);
- }
-
- valuemask = (CWBackPixel | CWBorderPixel | CWEventMask);
- attributes.background_pixel = Scr->MenuC.back;
- attributes.border_pixel = Scr->MenuBorderColor;
- attributes.event_mask = (ExposureMask | EnterWindowMask);
- if (Scr->SaveUnder) {
- valuemask |= CWSaveUnder;
- attributes.save_under = True;
- }
- if (Scr->BackingStore) {
- valuemask |= CWBackingStore;
- attributes.backing_store = Always;
- }
- mr->w = XCreateWindow (dpy, Scr->Root, 0, 0, (unsigned int) mr->width,
- (unsigned int) mr->height,
- (unsigned int) Scr->MenuBorderWidth,
- CopyFromParent, (unsigned int) CopyFromParent,
- (Visual *) CopyFromParent,
- valuemask, &attributes);
-
-
- XSaveContext(dpy, mr->w, MenuContext, (XPointer)mr);
- XSaveContext(dpy, mr->w, ScreenContext, (XPointer)Scr);
-
- mr->mapped = UNMAPPED;
+ if (mr->mapped == NEVER_MAPPED) {
+ if (mr->pull == TRUE) {
+ mr->width = (short) (mr->width + (16 + 10));
+ }
+
+ width = mr->width + 10;
+
+ for (cur = mr->first; cur != NULL; cur = cur->next) {
+ if (cur->func != F_TITLE)
+ cur->x = 5;
+ else {
+ cur->x =
+ (short) (width -
+ MyFont_TextWidth(&Scr->MenuFont, cur->item,
+ cur->strlen));
+ cur->x /= 2;
+ }
+ }
+ mr->height = (short) (mr->items * Scr->EntryHeight);
+ mr->width = (short) (mr->width + 10);
+
+ if (Scr->Shadow) {
+ /*
+ * Make sure that you don't draw into the shadow window or else
+ * the background bits there will get saved
+ */
+ valuemask = (CWBackPixel | CWBorderPixel);
+ attributes.background_pixel = Scr->MenuShadowColor;
+ attributes.border_pixel = Scr->MenuShadowColor;
+ if (Scr->SaveUnder) {
+ valuemask |= CWSaveUnder;
+ attributes.save_under = True;
+ }
+ mr->shadow = XCreateWindow(dpy, Scr->Root, 0, 0,
+ (unsigned int) mr->width,
+ (unsigned int) mr->height,
+ (unsigned int) 0,
+ CopyFromParent,
+ (unsigned int) CopyFromParent,
+ (Visual *) CopyFromParent,
+ valuemask, &attributes);
+ }
+
+ valuemask = (CWBackPixel | CWBorderPixel | CWEventMask);
+ attributes.background_pixel = Scr->MenuC.back;
+ attributes.border_pixel = Scr->MenuBorderColor;
+ attributes.event_mask = (ExposureMask | EnterWindowMask);
+ if (Scr->SaveUnder) {
+ valuemask |= CWSaveUnder;
+ attributes.save_under = True;
+ }
+ if (Scr->BackingStore) {
+ valuemask |= CWBackingStore;
+ attributes.backing_store = Always;
+ }
+ mr->w = XCreateWindow(dpy, Scr->Root, 0, 0, (unsigned int) mr->width,
+ (unsigned int) mr->height,
+ (unsigned int) Scr->MenuBorderWidth,
+ CopyFromParent, (unsigned int) CopyFromParent,
+ (Visual *) CopyFromParent,
+ valuemask, &attributes);
+
+ XSaveContext(dpy, mr->w, MenuContext, (XPointer) mr);
+ XSaveContext(dpy, mr->w, ScreenContext, (XPointer) Scr);
+
+ mr->mapped = UNMAPPED;
}
/* get the default colors into the menus */
- for (tmp = mr->first; tmp != NULL; tmp = tmp->next)
- {
- if (!tmp->user_colors) {
- if (tmp->func != F_TITLE) {
- tmp->fore = Scr->MenuC.fore;
- tmp->back = Scr->MenuC.back;
- } else {
- tmp->fore = Scr->MenuTitleC.fore;
- tmp->back = Scr->MenuTitleC.back;
- }
- }
-
- if (mr->hi_fore != UNUSED_PIXEL)
- {
- tmp->hi_fore = mr->hi_fore;
- tmp->hi_back = mr->hi_back;
- }
- else
- {
- tmp->hi_fore = tmp->back;
- tmp->hi_back = tmp->fore;
- }
+ for (tmp = mr->first; tmp != NULL; tmp = tmp->next) {
+ if (!tmp->user_colors) {
+ if (tmp->func != F_TITLE) {
+ tmp->fore = Scr->MenuC.fore;
+ tmp->back = Scr->MenuC.back;
+ }
+ else {
+ tmp->fore = Scr->MenuTitleC.fore;
+ tmp->back = Scr->MenuTitleC.back;
+ }
+ }
+
+ if (mr->hi_fore != UNUSED_PIXEL) {
+ tmp->hi_fore = mr->hi_fore;
+ tmp->hi_back = mr->hi_back;
+ }
+ else {
+ tmp->hi_fore = tmp->back;
+ tmp->hi_back = tmp->fore;
+ }
}
if (Scr->Monochrome == MONOCHROME || !Scr->InterpolateMenuColors)
- return;
+ return;
start = mr->first;
- while (TRUE)
- {
- for (; start != NULL; start = start->next)
- {
- if (start->user_colors)
- break;
- }
- if (start == NULL)
- break;
-
- for (end = start->next; end != NULL; end = end->next)
- {
- if (end->user_colors)
- break;
- }
- if (end == NULL)
- break;
-
- /* we have a start and end to interpolate between */
- num = end->item_num - start->item_num;
-
- f1.pixel = start->fore;
- XQueryColor(dpy, cmap, &f1);
- f2.pixel = end->fore;
- XQueryColor(dpy, cmap, &f2);
-
- b1.pixel = start->back;
- XQueryColor(dpy, cmap, &b1);
- b2.pixel = end->back;
- XQueryColor(dpy, cmap, &b2);
-
- fred = ((int)f2.red - (int)f1.red) / num;
- fgreen = ((int)f2.green - (int)f1.green) / num;
- fblue = ((int)f2.blue - (int)f1.blue) / num;
-
- bred = ((int)b2.red - (int)b1.red) / num;
- bgreen = ((int)b2.green - (int)b1.green) / num;
- bblue = ((int)b2.blue - (int)b1.blue) / num;
-
- f3 = f1;
- f3.flags = DoRed | DoGreen | DoBlue;
-
- b3 = b1;
- b3.flags = DoRed | DoGreen | DoBlue;
-
- num -= 1;
- for (i = 0, cur = start->next; i < num && cur; i++, cur = cur->next)
- {
+ while (TRUE) {
+ for (; start != NULL; start = start->next) {
+ if (start->user_colors)
+ break;
+ }
+ if (start == NULL)
+ break;
+
+ for (end = start->next; end != NULL; end = end->next) {
+ if (end->user_colors)
+ break;
+ }
+ if (end == NULL)
+ break;
+
+ /* we have a start and end to interpolate between */
+ num = end->item_num - start->item_num;
+
+ f1.pixel = start->fore;
+ XQueryColor(dpy, cmap, &f1);
+ f2.pixel = end->fore;
+ XQueryColor(dpy, cmap, &f2);
+
+ b1.pixel = start->back;
+ XQueryColor(dpy, cmap, &b1);
+ b2.pixel = end->back;
+ XQueryColor(dpy, cmap, &b2);
+
+ fred = ((int) f2.red - (int) f1.red) / num;
+ fgreen = ((int) f2.green - (int) f1.green) / num;
+ fblue = ((int) f2.blue - (int) f1.blue) / num;
+
+ bred = ((int) b2.red - (int) b1.red) / num;
+ bgreen = ((int) b2.green - (int) b1.green) / num;
+ bblue = ((int) b2.blue - (int) b1.blue) / num;
+
+ f3 = f1;
+ f3.flags = DoRed | DoGreen | DoBlue;
+
+ b3 = b1;
+ b3.flags = DoRed | DoGreen | DoBlue;
+
+ num -= 1;
+ for (i = 0, cur = start->next; i < num && cur; i++, cur = cur->next) {
#define AddColor(target,source) target = (unsigned short)(target + source)
- AddColor(f3.red, fred);
- AddColor(f3.green, fgreen);
- AddColor(f3.blue, fblue);
- save_fore = f3;
-
- AddColor(b3.red, bred);
- AddColor(b3.green, bgreen);
- AddColor(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;
+ AddColor(f3.red, fred);
+ AddColor(f3.green, fgreen);
+ AddColor(f3.blue, fblue);
+ save_fore = f3;
+
+ AddColor(b3.red, bred);
+ AddColor(b3.green, bgreen);
+ AddColor(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;
}
}
-
-
/**
* pop up a pull down menu.
*
@@ -966,51 +913,47 @@ MakeMenu(MenuRoot *mr)
* \param center whether or not to center horizontally over position
*/
Bool
-PopUpMenu (MenuRoot *menu, int x, int y, Bool center)
+PopUpMenu(MenuRoot *menu, int x, int y, Bool center)
{
int WindowNameCount;
TwmWindow **WindowNames;
- TwmWindow *tmp_win2,*tmp_win3;
+ TwmWindow *tmp_win2, *tmp_win3;
int i;
- int (*compar)(const char *, const char *) =
- (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
+ int (*compar) (const char *, const char *) =
+ (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);
- if (!menu) return False;
+ if (!menu)
+ return False;
InstallRootColormap();
- if (menu == Scr->Windows)
- {
- TwmWindow *tmp_win;
+ if (menu == Scr->Windows) {
+ TwmWindow *tmp_win;
- /* this is the twm windows menu, let's go ahead and build it */
+ /* this is the twm windows menu, let's go ahead and build it */
- DestroyMenu (menu);
+ DestroyMenu(menu);
- menu->first = NULL;
- menu->last = NULL;
- menu->items = 0;
- menu->width = 0;
- menu->mapped = NEVER_MAPPED;
- AddToMenu(menu, "TWM Windows", NULLSTR, NULL, F_TITLE,NULLSTR,NULLSTR);
+ menu->first = NULL;
+ menu->last = NULL;
+ menu->items = 0;
+ menu->width = 0;
+ menu->mapped = NEVER_MAPPED;
+ AddToMenu(menu, "TWM Windows", NULLSTR, NULL, F_TITLE, NULLSTR,
+ NULLSTR);
- for(tmp_win = Scr->TwmRoot.next , WindowNameCount=0;
- tmp_win != NULL;
- tmp_win = tmp_win->next)
- WindowNameCount++;
- if (WindowNameCount != 0)
- {
- WindowNames = malloc(sizeof(TwmWindow *) * (size_t)WindowNameCount);
+ for (tmp_win = Scr->TwmRoot.next, WindowNameCount = 0;
+ tmp_win != NULL; tmp_win = tmp_win->next)
+ WindowNameCount++;
+ if (WindowNameCount != 0) {
+ WindowNames =
+ malloc(sizeof(TwmWindow *) * (size_t) WindowNameCount);
WindowNames[0] = Scr->TwmRoot.next;
- for(tmp_win = Scr->TwmRoot.next->next , WindowNameCount=1;
- tmp_win != NULL;
- tmp_win = tmp_win->next,WindowNameCount++)
- {
+ for (tmp_win = Scr->TwmRoot.next->next, WindowNameCount = 1;
+ tmp_win != NULL; tmp_win = tmp_win->next, WindowNameCount++) {
tmp_win2 = tmp_win;
- for (i=0;i<WindowNameCount;i++)
- {
- if ((*compar)(tmp_win2->name,WindowNames[i]->name) < 0)
- {
+ for (i = 0; i < WindowNameCount; i++) {
+ if ((*compar) (tmp_win2->name, WindowNames[i]->name) < 0) {
tmp_win3 = tmp_win2;
tmp_win2 = WindowNames[i];
WindowNames[i] = tmp_win3;
@@ -1018,21 +961,22 @@ PopUpMenu (MenuRoot *menu, int x, int y, Bool center)
}
WindowNames[WindowNameCount] = tmp_win2;
}
- for (i=0; i<WindowNameCount; i++)
- {
- AddToMenu(menu, WindowNames[i]->name, (char *)WindowNames[i],
- NULL, F_POPUP,NULL,NULL);
+ for (i = 0; i < WindowNameCount; i++) {
+ AddToMenu(menu, WindowNames[i]->name, (char *) WindowNames[i],
+ NULL, F_POPUP, NULL, NULL);
}
free(WindowNames);
}
- MakeMenu(menu);
+ MakeMenu(menu);
}
- if (menu->w == None || menu->items == 0) return False;
+ if (menu->w == None || menu->items == 0)
+ return False;
/* Prevent recursively bringing up menus. */
- if (menu->mapped == MAPPED) return False;
+ if (menu->mapped == MAPPED)
+ return False;
/*
* Dynamically set the parent; this allows pull-ups to also be main
@@ -1041,31 +985,33 @@ PopUpMenu (MenuRoot *menu, int x, int y, Bool center)
menu->prev = ActiveMenu;
XGrabPointer(dpy, Scr->Root, True,
- ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask | PointerMotionHintMask,
- GrabModeAsync, GrabModeAsync,
- Scr->Root, Scr->MenuCursor, CurrentTime);
+ ButtonPressMask | ButtonReleaseMask |
+ ButtonMotionMask | PointerMotionHintMask,
+ GrabModeAsync, GrabModeAsync,
+ Scr->Root, Scr->MenuCursor, CurrentTime);
ActiveMenu = menu;
menu->mapped = MAPPED;
menu->entered = FALSE;
if (center) {
- x -= (menu->width / 2);
- y -= (Scr->EntryHeight / 2); /* sticky menus would be nice here */
+ x -= (menu->width / 2);
+ y -= (Scr->EntryHeight / 2); /* sticky menus would be nice here */
}
/*
* clip to screen
*/
if (x + menu->width > Scr->MyDisplayWidth) {
- x = Scr->MyDisplayWidth - menu->width;
+ x = Scr->MyDisplayWidth - menu->width;
}
- if (x < 0) x = 0;
+ if (x < 0)
+ x = 0;
if (y + menu->height > Scr->MyDisplayHeight) {
- y = Scr->MyDisplayHeight - menu->height;
+ y = Scr->MyDisplayHeight - menu->height;
}
- if (y < 0) y = 0;
+ if (y < 0)
+ y = 0;
MenuOrigins[MenuDepth].x = x;
MenuOrigins[MenuDepth].y = y;
@@ -1073,21 +1019,19 @@ PopUpMenu (MenuRoot *menu, int x, int y, Bool center)
XMoveWindow(dpy, menu->w, x, y);
if (Scr->Shadow) {
- XMoveWindow (dpy, menu->shadow, x + SHADOWWIDTH, y + SHADOWWIDTH);
+ XMoveWindow(dpy, menu->shadow, x + SHADOWWIDTH, y + SHADOWWIDTH);
}
if (Scr->Shadow) {
- XRaiseWindow (dpy, menu->shadow);
+ XRaiseWindow(dpy, menu->shadow);
}
XMapRaised(dpy, menu->w);
if (Scr->Shadow) {
- XMapWindow (dpy, menu->shadow);
+ XMapWindow(dpy, menu->shadow);
}
XSync(dpy, 0);
return True;
}
-
-
/**
* unhighlight the current menu selection and take down the menus
*/
@@ -1097,22 +1041,20 @@ PopDownMenu(void)
MenuRoot *tmp;
if (ActiveMenu == NULL)
- return;
+ return;
- if (ActiveItem)
- {
- ActiveItem->state = 0;
- PaintEntry(ActiveMenu, ActiveItem, False);
+ 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();
+ 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);
@@ -1120,11 +1062,9 @@ PopDownMenu(void)
ActiveItem = NULL;
MenuDepth = 0;
if (Context == C_WINDOW || Context == C_FRAME || Context == C_TITLE)
- menuFromFrameOrWindowOrTitlebar = TRUE;
+ menuFromFrameOrWindowOrTitlebar = TRUE;
}
-
-
/**
* look for a menu root
*
@@ -1137,129 +1077,119 @@ FindMenuRoot(const char *name)
{
MenuRoot *tmp;
- for (tmp = Scr->MenuList; tmp != NULL; tmp = tmp->next)
- {
- if (strcmp(name, tmp->name) == 0)
- return (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 (TwmWindow *t, Window w)
+belongs_to_twm_window(TwmWindow *t, Window w)
{
- if (!t) return False;
+ 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;
+ 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;
- }
+ 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;
}
-
-
static void
resizeFromCenter(Window w, TwmWindow *tmp_win)
{
- int lastx, lasty, bw2;
- XEvent event;
+ int lastx, lasty, bw2;
+ XEvent event;
+
#if 0
- int namelen;
- int width, height;
+ int namelen;
+ int width, height;
- namelen = strlen (tmp_win->name);
+ 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;
+ 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;
+ 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);
- XWarpPointer(dpy, None, w,
- 0, 0, 0, 0, DragWidth/2, DragHeight/2);
- XQueryPointer (dpy, Scr->Root, &JunkRoot,
- &JunkChild, &JunkX, &JunkY,
- &AddingX, &AddingY, &JunkMask);
+ XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY,
+ (unsigned int *) &DragWidth, (unsigned int *) &DragHeight,
+ &JunkBW, &JunkDepth);
+ XWarpPointer(dpy, None, w, 0, 0, 0, 0, DragWidth / 2, DragHeight / 2);
+ XQueryPointer(dpy, Scr->Root, &JunkRoot,
+ &JunkChild, &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
#if 0
- Scr->SizeStringOffset = width +
- MyFont_TextWidth(&Scr->SizeFont, ": ", 2);
- XResizeWindow (dpy, Scr->SizeWindow, Scr->SizeStringOffset +
- Scr->SizeStringWidth, height);
- MyFont_DrawImageString (dpy, Scr->SizeWindow, &Scr->SizeFont, Scr->NormalGC,
- width, SIZE_VINDENT + Scr->SizeFont.ascent,
- ": ", 2);
+ Scr->SizeStringOffset = width + MyFont_TextWidth(&Scr->SizeFont, ": ", 2);
+ XResizeWindow(dpy, Scr->SizeWindow, Scr->SizeStringOffset +
+ Scr->SizeStringWidth, height);
+ MyFont_DrawImageString(dpy, Scr->SizeWindow, &Scr->SizeFont, Scr->NormalGC,
+ width, SIZE_VINDENT + Scr->SizeFont.ascent, ": ", 2);
#endif
- lastx = -10000;
- lasty = -10000;
+ lastx = -10000;
+ lasty = -10000;
#if 0
- MoveOutline(Scr->Root,
- origDragX - JunkBW, origDragY - JunkBW,
- DragWidth * JunkBW, DragHeight * JunkBW,
- tmp_win->frame_bw,
- tmp_win->title_height);
+ MoveOutline(Scr->Root,
+ origDragX - JunkBW, origDragY - JunkBW,
+ DragWidth * JunkBW, DragHeight * JunkBW,
+ tmp_win->frame_bw, tmp_win->title_height);
#endif
- MenuStartResize(tmp_win, origDragX, origDragY, DragWidth, DragHeight);
- while (TRUE)
- {
- XMaskEvent(dpy,
- ButtonPressMask | PointerMotionMask, &event);
-
- if (event.type == MotionNotify) {
- /* discard any extra motion events before a release */
- while(XCheckMaskEvent(dpy,
- ButtonMotionMask | ButtonPressMask, &event))
- if (event.type == ButtonPress)
- break;
- }
-
- if (event.type == ButtonPress)
- {
- MenuEndResize(tmp_win);
- XMoveResizeWindow(dpy, w, AddingX, AddingY, (unsigned)AddingW, (unsigned)AddingH);
- break;
- }
-
-/* if (!DispatchEvent ()) continue; */
-
- if (event.type != MotionNotify) {
- continue;
- }
-
- /*
- * XXX - if we are going to do a loop, we ought to consider
- * using multiple GXxor lines so that we don't need to
- * grab the server.
- */
- XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
- &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
-
- if (lastx != AddingX || lasty != AddingY)
- {
- MenuDoResize(AddingX, AddingY, tmp_win);
-
- lastx = AddingX;
- lasty = AddingY;
- }
+ MenuStartResize(tmp_win, origDragX, origDragY, DragWidth, DragHeight);
+ while (TRUE) {
+ XMaskEvent(dpy, ButtonPressMask | PointerMotionMask, &event);
+
+ if (event.type == MotionNotify) {
+ /* discard any extra motion events before a release */
+ while (XCheckMaskEvent(dpy,
+ ButtonMotionMask | ButtonPressMask, &event))
+ if (event.type == ButtonPress)
+ break;
+ }
+
+ if (event.type == ButtonPress) {
+ MenuEndResize(tmp_win);
+ XMoveResizeWindow(dpy, w, AddingX, AddingY, (unsigned) AddingW,
+ (unsigned) AddingH);
+ break;
+ }
+
+ /* if (!DispatchEvent ()) continue; */
+
+ if (event.type != MotionNotify) {
+ continue;
+ }
+
+ /*
+ * XXX - if we are going to do a loop, we ought to consider
+ * using multiple GXxor lines so that we don't need to
+ * grab the server.
+ */
+ XQueryPointer(dpy, Scr->Root, &JunkRoot, &JunkChild,
+ &JunkX, &JunkY, &AddingX, &AddingY, &JunkMask);
+
+ if (lastx != AddingX || lasty != AddingY) {
+ MenuDoResize(AddingX, AddingY, tmp_win);
+
+ lastx = AddingX;
+ lasty = AddingY;
+ }
}
}
-
-
/** \fn ExecuteFunction
* execute a twm root function.
*
@@ -1279,15 +1209,16 @@ static int
WarpThere(TwmWindow *t)
{
if (Scr->WarpUnmapped || t->mapped) {
- if (!t->mapped) DeIconify (t);
- if (!Scr->NoRaiseWarp) XRaiseWindow (dpy, t->frame);
- WarpToWindow (t);
+ if (!t->mapped)
+ DeIconify(t);
+ if (!Scr->NoRaiseWarp)
+ XRaiseWindow(dpy, t->frame);
+ WarpToWindow(t);
return 1;
}
return 0;
}
-
int
ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
XEvent *eventp, int context, int pulldown)
@@ -1305,10 +1236,9 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
RootFunction = 0;
if (Cancel)
- return TRUE; /* XXX should this be FALSE? */
+ return TRUE; /* XXX should this be FALSE? */
- switch (func)
- {
+ switch (func) {
case F_UPICONMGR:
case F_LEFTICONMGR:
case F_RIGHTICONMGR:
@@ -1328,35 +1258,35 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
case F_WARPNEXT:
case F_WARPPREV:
case F_COLORMAP:
- break;
+ break;
default:
XGrabPointer(dpy, Scr->Root, True,
- ButtonPressMask | ButtonReleaseMask,
- GrabModeAsync, GrabModeAsync,
- Scr->Root, Scr->WaitCursor, CurrentTime);
- break;
+ ButtonPressMask | ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync,
+ Scr->Root, Scr->WaitCursor, CurrentTime);
+ break;
}
- switch (func)
- {
+ switch (func) {
case F_NOP:
case F_TITLE:
- break;
+ break;
case F_DELTASTOP:
- if (WindowMoved) do_next_action = FALSE;
- break;
+ if (WindowMoved)
+ do_next_action = FALSE;
+ break;
case F_RESTART:
{
- XSync (dpy, 0);
- Reborder (eventp->xbutton.time);
- XSync (dpy, 0);
- if (smcConn)
- SmcCloseConnection (smcConn, 0, NULL);
- execvp(*Argv, Argv);
- fprintf (stderr, "%s: unable to restart: %s\n", ProgramName, *Argv);
- break;
+ XSync(dpy, 0);
+ Reborder(eventp->xbutton.time);
+ XSync(dpy, 0);
+ if (smcConn)
+ SmcCloseConnection(smcConn, 0, NULL);
+ execvp(*Argv, Argv);
+ fprintf(stderr, "%s: unable to restart: %s\n", ProgramName, *Argv);
+ break;
}
case F_UPICONMGR:
@@ -1365,146 +1295,149 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
case F_RIGHTICONMGR:
case F_FORWICONMGR:
case F_BACKICONMGR:
- MoveIconManager(func);
+ MoveIconManager(func);
break;
case F_NEXTICONMGR:
case F_PREVICONMGR:
- JumpIconManager(func);
+ JumpIconManager(func);
break;
case F_SHOWLIST:
- if (Scr->NoIconManagers)
- break;
- DeIconify(Scr->iconmgr.twm_win);
- XRaiseWindow(dpy, Scr->iconmgr.twm_win->frame);
- break;
+ if (Scr->NoIconManagers)
+ break;
+ DeIconify(Scr->iconmgr.twm_win);
+ XRaiseWindow(dpy, Scr->iconmgr.twm_win->frame);
+ break;
case F_HIDELIST:
- if (Scr->NoIconManagers)
- break;
- HideIconManager ();
- break;
+ if (Scr->NoIconManagers)
+ break;
+ HideIconManager();
+ break;
case F_SORTICONMGR:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
- {
- int save_sort;
+ {
+ int save_sort;
- save_sort = Scr->SortIconMgr;
- Scr->SortIconMgr = TRUE;
+ save_sort = Scr->SortIconMgr;
+ Scr->SortIconMgr = TRUE;
- if (context == C_ICONMGR)
- SortIconManager((IconMgr *) NULL);
- else if (tmp_win->iconmgr)
- SortIconManager(tmp_win->iconmgrp);
- else
- Bell(XkbBI_Info,0,tmp_win->w);
+ if (context == C_ICONMGR)
+ SortIconManager((IconMgr *) NULL);
+ else if (tmp_win->iconmgr)
+ SortIconManager(tmp_win->iconmgrp);
+ else
+ Bell(XkbBI_Info, 0, tmp_win->w);
- Scr->SortIconMgr = (short)save_sort;
- }
- break;
+ Scr->SortIconMgr = (short) save_sort;
+ }
+ break;
case F_IDENTIFY:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
- Identify(tmp_win);
- break;
+ Identify(tmp_win);
+ break;
case F_VERSION:
- Identify ((TwmWindow *) NULL);
- break;
+ Identify((TwmWindow *) NULL);
+ break;
case F_AUTORAISE:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
-
- tmp_win->auto_raise = !tmp_win->auto_raise;
- if (tmp_win->auto_raise) ++(Scr->NumAutoRaises);
- else --(Scr->NumAutoRaises);
- break;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
+
+ tmp_win->auto_raise = !tmp_win->auto_raise;
+ if (tmp_win->auto_raise)
+ ++(Scr->NumAutoRaises);
+ else
+ --(Scr->NumAutoRaises);
+ break;
case F_BEEP:
- Bell(XkbBI_Info,0,None);
- break;
+ Bell(XkbBI_Info, 0, None);
+ break;
case F_POPUP:
- tmp_win = (TwmWindow *)action;
- if (Scr->WindowFunction.func != 0)
- {
- ExecuteFunction(Scr->WindowFunction.func,
- Scr->WindowFunction.item->action,
- w, tmp_win, eventp, C_FRAME, FALSE);
- }
- else
- {
- DeIconify(tmp_win);
- XRaiseWindow (dpy, tmp_win->frame);
- }
- break;
+ tmp_win = (TwmWindow *) action;
+ if (Scr->WindowFunction.func != 0) {
+ ExecuteFunction(Scr->WindowFunction.func,
+ Scr->WindowFunction.item->action,
+ w, tmp_win, eventp, C_FRAME, FALSE);
+ }
+ else {
+ DeIconify(tmp_win);
+ XRaiseWindow(dpy, tmp_win->frame);
+ }
+ break;
case F_RESIZE:
- EventHandler[EnterNotify] = HandleUnknown;
- EventHandler[LeaveNotify] = HandleUnknown;
- if (DeferExecution(context, func, Scr->MoveCursor))
- return TRUE;
-
- PopDownMenu();
-
- if (pulldown)
- XWarpPointer(dpy, None, Scr->Root,
- 0, 0, 0, 0, eventp->xbutton.x_root, eventp->xbutton.y_root);
-
- if (w != tmp_win->icon_w) { /* can't resize icons */
-
- if ((Context == C_FRAME || Context == C_WINDOW || Context == C_TITLE)
- && fromMenu)
- resizeFromCenter(w, tmp_win);
- else {
- /*
- * see if this is being done from the titlebar
- */
- fromtitlebar =
- belongs_to_twm_window (tmp_win, eventp->xbutton.window);
-
- /* Save pointer position so we can tell if it was moved or
- not during the resize. */
- ResizeOrigX = eventp->xbutton.x_root;
- ResizeOrigY = eventp->xbutton.y_root;
-
- StartResize (eventp, tmp_win, fromtitlebar);
-
- do {
- XMaskEvent(dpy,
- ButtonPressMask | ButtonReleaseMask |
- EnterWindowMask | LeaveWindowMask |
- ButtonMotionMask, &Event);
-
- if (fromtitlebar && Event.type == ButtonPress) {
- fromtitlebar = False;
- continue;
- }
-
- if (Event.type == MotionNotify) {
- /* discard any extra motion events before a release */
- while
- (XCheckMaskEvent
- (dpy, ButtonMotionMask | ButtonReleaseMask, &Event))
- if (Event.type == ButtonRelease)
- break;
- }
-
- if (!DispatchEvent ()) continue;
-
- } while (!(Event.type == ButtonRelease || Cancel));
- return TRUE;
- }
- }
- break;
+ EventHandler[EnterNotify] = HandleUnknown;
+ EventHandler[LeaveNotify] = HandleUnknown;
+ if (DeferExecution(context, func, Scr->MoveCursor))
+ return TRUE;
+
+ PopDownMenu();
+
+ if (pulldown)
+ XWarpPointer(dpy, None, Scr->Root,
+ 0, 0, 0, 0, eventp->xbutton.x_root,
+ eventp->xbutton.y_root);
+
+ if (w != tmp_win->icon_w) { /* can't resize icons */
+
+ if ((Context == C_FRAME || Context == C_WINDOW ||
+ Context == C_TITLE)
+ && fromMenu)
+ resizeFromCenter(w, tmp_win);
+ else {
+ /*
+ * see if this is being done from the titlebar
+ */
+ fromtitlebar =
+ belongs_to_twm_window(tmp_win, eventp->xbutton.window);
+
+ /* Save pointer position so we can tell if it was moved or
+ not during the resize. */
+ ResizeOrigX = eventp->xbutton.x_root;
+ ResizeOrigY = eventp->xbutton.y_root;
+
+ StartResize(eventp, tmp_win, fromtitlebar);
+
+ do {
+ XMaskEvent(dpy,
+ ButtonPressMask | ButtonReleaseMask |
+ EnterWindowMask | LeaveWindowMask |
+ ButtonMotionMask, &Event);
+
+ if (fromtitlebar && Event.type == ButtonPress) {
+ fromtitlebar = False;
+ continue;
+ }
+
+ if (Event.type == MotionNotify) {
+ /* discard any extra motion events before a release */
+ while
+ (XCheckMaskEvent
+ (dpy, ButtonMotionMask | ButtonReleaseMask,
+ &Event))
+ if (Event.type == ButtonRelease)
+ break;
+ }
+ if (!DispatchEvent())
+ continue;
+
+ } while (!(Event.type == ButtonRelease || Cancel));
+ return TRUE;
+ }
+ }
+ break;
case F_ZOOM:
case F_HORIZOOM:
@@ -1513,780 +1446,790 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win,
case F_RIGHTZOOM:
case F_TOPZOOM:
case F_BOTTOMZOOM:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
- fullzoom(tmp_win, func);
- break;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
+ fullzoom(tmp_win, func);
+ break;
case F_MOVE:
case F_FORCEMOVE:
- if (DeferExecution(context, func, Scr->MoveCursor))
- return TRUE;
-
- PopDownMenu();
- rootw = eventp->xbutton.root;
- MoveFunction = func;
-
- if (pulldown)
- XWarpPointer(dpy, None, Scr->Root,
- 0, 0, 0, 0, eventp->xbutton.x_root, eventp->xbutton.y_root);
-
- EventHandler[EnterNotify] = HandleUnknown;
- EventHandler[LeaveNotify] = HandleUnknown;
-
- if (!Scr->NoGrabServer || !Scr->OpaqueMove) {
- XGrabServer(dpy);
- }
- XGrabPointer(dpy, eventp->xbutton.root, True,
- ButtonPressMask | ButtonReleaseMask |
- ButtonMotionMask | PointerMotionMask, /* PointerMotionHintMask */
- GrabModeAsync, GrabModeAsync,
- Scr->Root, Scr->MoveCursor, CurrentTime);
-
- if (context == C_ICON && tmp_win->icon_w)
- {
- w = tmp_win->icon_w;
- DragX = eventp->xbutton.x;
- DragY = eventp->xbutton.y;
- moving_icon = TRUE;
- }
-
- else if (w != tmp_win->icon_w)
- {
- XTranslateCoordinates(dpy, w, tmp_win->frame,
- eventp->xbutton.x,
- eventp->xbutton.y,
- &DragX, &DragY, &JunkChild);
-
- w = tmp_win->frame;
- }
-
- DragWindow = None;
-
- XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY,
- (unsigned int *)&DragWidth, (unsigned int *)&DragHeight, &JunkBW,
- &JunkDepth);
-
- origX = eventp->xbutton.x_root;
- origY = eventp->xbutton.y_root;
- CurrentDragX = origDragX;
- CurrentDragY = origDragY;
-
- /*
- * only do the constrained move if timer is set; need to check it
- * in case of stupid or wicked fast servers
- */
- if (ConstrainedMoveTime &&
- (eventp->xbutton.time - last_time) < (Time)ConstrainedMoveTime)
- {
- int width, height;
-
- ConstMove = TRUE;
- ConstMoveDir = MOVE_NONE;
- ConstMoveX = (int)((unsigned)eventp->xbutton.x_root - (unsigned)DragX - JunkBW);
- ConstMoveY = (int)((unsigned)eventp->xbutton.y_root - (unsigned)DragY - JunkBW);
- width = (int)((unsigned)DragWidth + 2 * JunkBW);
- height = (int)((unsigned)DragHeight + 2 * JunkBW);
- ConstMoveXL = ConstMoveX + width/3;
- ConstMoveXR = ConstMoveX + 2*(width/3);
- ConstMoveYT = ConstMoveY + height/3;
- ConstMoveYB = ConstMoveY + 2*(height/3);
-
- XWarpPointer(dpy, None, w,
- 0, 0, 0, 0, DragWidth/2, DragHeight/2);
-
- XQueryPointer(dpy, w, &JunkRoot, &JunkChild,
- &JunkX, &JunkY, &DragX, &DragY, &JunkMask);
- }
- last_time = eventp->xbutton.time;
-
- if (!Scr->OpaqueMove)
- {
- InstallRootColormap();
- if (!Scr->MoveDelta)
- {
- /*
- * Draw initial outline. This was previously done the
- * first time though the outer loop by dropping out of
- * the XCheckMaskEvent inner loop down to one of the
- * MoveOutline's below.
- */
- MoveOutline(rootw,
- (int)((unsigned)origDragX - JunkBW),
- (int)((unsigned)origDragY - JunkBW),
- (int)((unsigned)DragWidth + 2 * JunkBW),
- (int)((unsigned)DragHeight + 2 * JunkBW),
- tmp_win->frame_bw,
- moving_icon ? 0 : tmp_win->title_height);
- /*
- * This next line causes HandleReleaseNotify to call
- * XRaiseWindow(). This is solely to preserve the
- * previous behaviour that raises a window being moved
- * on button release even if you never actually moved
- * any distance (unless you move less than MoveDelta or
- * NoRaiseMove is set or OpaqueMove is set).
- */
- DragWindow = w;
- }
- }
-
- /*
- * see if this is being done from the titlebar
- */
- fromtitlebar = belongs_to_twm_window (tmp_win, eventp->xbutton.window);
-
- if (menuFromFrameOrWindowOrTitlebar) {
- /* warp the pointer to the middle of the window */
- XWarpPointer(dpy, None, Scr->Root, 0, 0, 0, 0,
- origDragX + DragWidth / 2,
- origDragY + DragHeight / 2);
- XFlush(dpy);
- }
-
- while (TRUE)
- {
- long releaseEvent = menuFromFrameOrWindowOrTitlebar ?
- ButtonPress : ButtonRelease;
- long movementMask = menuFromFrameOrWindowOrTitlebar ?
- PointerMotionMask : ButtonMotionMask;
-
- /* block until there is an interesting event */
- XMaskEvent(dpy, ButtonPressMask | ButtonReleaseMask |
- EnterWindowMask | LeaveWindowMask |
- ExposureMask | movementMask |
- VisibilityChangeMask, &Event);
-
- /* throw away enter and leave events until release */
- if (Event.xany.type == EnterNotify ||
- Event.xany.type == LeaveNotify) continue;
-
- if (Event.type == MotionNotify) {
- /* discard any extra motion events before a logical release */
- while(XCheckMaskEvent(dpy,
- movementMask | releaseEvent, &Event))
- if (Event.type == releaseEvent)
- break;
- }
-
- /* test to see if we have a second button press to abort move */
- if (!menuFromFrameOrWindowOrTitlebar && !MovedFromKeyPress) {
- if (Event.type == ButtonPress && DragWindow != None) {
- if (Scr->OpaqueMove)
- XMoveWindow (dpy, DragWindow, origDragX, origDragY);
- else
- MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
- DragWindow = None;
+ if (DeferExecution(context, func, Scr->MoveCursor))
+ return TRUE;
+
+ PopDownMenu();
+ rootw = eventp->xbutton.root;
+ MoveFunction = func;
+
+ if (pulldown)
+ XWarpPointer(dpy, None, Scr->Root,
+ 0, 0, 0, 0, eventp->xbutton.x_root,
+ eventp->xbutton.y_root);
+
+ EventHandler[EnterNotify] = HandleUnknown;
+ EventHandler[LeaveNotify] = HandleUnknown;
+
+ if (!Scr->NoGrabServer || !Scr->OpaqueMove) {
+ XGrabServer(dpy);
+ }
+ XGrabPointer(dpy, eventp->xbutton.root, True, ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PointerMotionMask, /* PointerMotionHintMask */
+ GrabModeAsync, GrabModeAsync,
+ Scr->Root, Scr->MoveCursor, CurrentTime);
+
+ if (context == C_ICON && tmp_win->icon_w) {
+ w = tmp_win->icon_w;
+ DragX = eventp->xbutton.x;
+ DragY = eventp->xbutton.y;
+ moving_icon = TRUE;
+ }
+
+ else if (w != tmp_win->icon_w) {
+ XTranslateCoordinates(dpy, w, tmp_win->frame,
+ eventp->xbutton.x,
+ eventp->xbutton.y,
+ &DragX, &DragY, &JunkChild);
+
+ w = tmp_win->frame;
+ }
+
+ DragWindow = None;
+
+ XGetGeometry(dpy, w, &JunkRoot, &origDragX, &origDragY,
+ (unsigned int *) &DragWidth, (unsigned int *) &DragHeight,
+ &JunkBW, &JunkDepth);
+
+ origX = eventp->xbutton.x_root;
+ origY = eventp->xbutton.y_root;
+ CurrentDragX = origDragX;
+ CurrentDragY = origDragY;
+
+ /*
+ * only do the constrained move if timer is set; need to check it
+ * in case of stupid or wicked fast servers
+ */
+ if (ConstrainedMoveTime &&
+ (eventp->xbutton.time - last_time) < (Time) ConstrainedMoveTime) {
+ int width, height;
+
+ ConstMove = TRUE;
+ ConstMoveDir = MOVE_NONE;
+ ConstMoveX =
+ (int) ((unsigned) eventp->xbutton.x_root - (unsigned) DragX -
+ JunkBW);
+ ConstMoveY =
+ (int) ((unsigned) eventp->xbutton.y_root - (unsigned) DragY -
+ JunkBW);
+ width = (int) ((unsigned) DragWidth + 2 * JunkBW);
+ height = (int) ((unsigned) DragHeight + 2 * JunkBW);
+ ConstMoveXL = ConstMoveX + width / 3;
+ ConstMoveXR = ConstMoveX + 2 * (width / 3);
+ ConstMoveYT = ConstMoveY + height / 3;
+ ConstMoveYB = ConstMoveY + 2 * (height / 3);
+
+ XWarpPointer(dpy, None, w,
+ 0, 0, 0, 0, DragWidth / 2, DragHeight / 2);
+
+ XQueryPointer(dpy, w, &JunkRoot, &JunkChild,
+ &JunkX, &JunkY, &DragX, &DragY, &JunkMask);
+ }
+ last_time = eventp->xbutton.time;
+
+ if (!Scr->OpaqueMove) {
+ InstallRootColormap();
+ if (!Scr->MoveDelta) {
+ /*
+ * Draw initial outline. This was previously done the
+ * first time though the outer loop by dropping out of
+ * the XCheckMaskEvent inner loop down to one of the
+ * MoveOutline's below.
+ */
+ MoveOutline(rootw,
+ (int) ((unsigned) origDragX - JunkBW),
+ (int) ((unsigned) origDragY - JunkBW),
+ (int) ((unsigned) DragWidth + 2 * JunkBW),
+ (int) ((unsigned) DragHeight + 2 * JunkBW),
+ tmp_win->frame_bw,
+ moving_icon ? 0 : tmp_win->title_height);
+ /*
+ * This next line causes HandleReleaseNotify to call
+ * XRaiseWindow(). This is solely to preserve the
+ * previous behaviour that raises a window being moved
+ * on button release even if you never actually moved
+ * any distance (unless you move less than MoveDelta or
+ * NoRaiseMove is set or OpaqueMove is set).
+ */
+ DragWindow = w;
+ }
+ }
+
+ /*
+ * see if this is being done from the titlebar
+ */
+ fromtitlebar = belongs_to_twm_window(tmp_win, eventp->xbutton.window);
+
+ if (menuFromFrameOrWindowOrTitlebar) {
+ /* warp the pointer to the middle of the window */
+ XWarpPointer(dpy, None, Scr->Root, 0, 0, 0, 0,
+ origDragX + DragWidth / 2, origDragY + DragHeight / 2);
+ XFlush(dpy);
+ }
+
+ while (TRUE) {
+ long releaseEvent = menuFromFrameOrWindowOrTitlebar ?
+ ButtonPress : ButtonRelease;
+ long movementMask = menuFromFrameOrWindowOrTitlebar ?
+ PointerMotionMask : ButtonMotionMask;
+
+ /* block until there is an interesting event */
+ XMaskEvent(dpy, ButtonPressMask | ButtonReleaseMask |
+ EnterWindowMask | LeaveWindowMask |
+ ExposureMask | movementMask |
+ VisibilityChangeMask, &Event);
+
+ /* throw away enter and leave events until release */
+ if (Event.xany.type == EnterNotify ||
+ Event.xany.type == LeaveNotify)
+ continue;
+
+ if (Event.type == MotionNotify) {
+ /* discard any extra motion events before a logical release */
+ while (XCheckMaskEvent(dpy,
+ movementMask | releaseEvent, &Event))
+ if (Event.type == releaseEvent)
+ break;
+ }
+
+ /* test to see if we have a second button press to abort move */
+ if (!menuFromFrameOrWindowOrTitlebar && !MovedFromKeyPress) {
+ if (Event.type == ButtonPress && DragWindow != None) {
+ if (Scr->OpaqueMove)
+ XMoveWindow(dpy, DragWindow, origDragX, origDragY);
+ else
+ MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
+ DragWindow = None;
+ }
+ }
+ if (fromtitlebar && Event.type == ButtonPress) {
+ fromtitlebar = False;
+ CurrentDragX = origX = Event.xbutton.x_root;
+ CurrentDragY = origY = Event.xbutton.y_root;
+
+ XTranslateCoordinates(dpy, rootw, tmp_win->frame,
+ origX, origY, &DragX, &DragY, &JunkChild);
+ continue;
+ }
+
+ if (!DispatchEvent2())
+ continue;
+
+ if (Cancel) {
+ WindowMoved = FALSE;
+ if (!Scr->OpaqueMove)
+ UninstallRootColormap();
+ return TRUE; /* XXX should this be FALSE? */
+ }
+ if (Event.type == releaseEvent) {
+ MoveOutline(rootw, 0, 0, 0, 0, 0, 0);
+ if (moving_icon &&
+ ((CurrentDragX != origDragX || CurrentDragY != origDragY)))
+ tmp_win->icon_moved = TRUE;
+ if (!Scr->OpaqueMove && menuFromFrameOrWindowOrTitlebar)
+ XMoveWindow(dpy, DragWindow,
+ Event.xbutton.x_root - DragWidth / 2,
+ Event.xbutton.y_root - DragHeight / 2);
+ break;
+ }
+
+ /* something left to do only if the pointer moved */
+ if (Event.type != MotionNotify)
+ continue;
+
+ XQueryPointer(dpy, rootw, &(eventp->xmotion.root), &JunkChild,
+ &(eventp->xmotion.x_root), &(eventp->xmotion.y_root),
+ &JunkX, &JunkY, &JunkMask);
+
+ if (DragWindow == None &&
+ abs(eventp->xmotion.x_root - origX) < Scr->MoveDelta &&
+ abs(eventp->xmotion.y_root - origY) < Scr->MoveDelta)
+ continue;
+
+ WindowMoved = TRUE;
+ DragWindow = w;
+
+ if (!Scr->NoRaiseMove && Scr->OpaqueMove) /* can't restore... */
+ XRaiseWindow(dpy, DragWindow);
+
+ if (ConstMove) {
+ switch (ConstMoveDir) {
+ case MOVE_NONE:
+ if (eventp->xmotion.x_root < ConstMoveXL ||
+ eventp->xmotion.x_root > ConstMoveXR)
+ ConstMoveDir = MOVE_HORIZ;
+
+ if (eventp->xmotion.y_root < ConstMoveYT ||
+ eventp->xmotion.y_root > ConstMoveYB)
+ ConstMoveDir = MOVE_VERT;
+
+ XQueryPointer(dpy, DragWindow, &JunkRoot, &JunkChild,
+ &JunkX, &JunkY, &DragX, &DragY, &JunkMask);
+ break;
+
+ case MOVE_VERT:
+ ConstMoveY =
+ (int) ((unsigned) eventp->xmotion.y_root -
+ (unsigned) DragY - JunkBW);
+ break;
+
+ case MOVE_HORIZ:
+ ConstMoveX =
+ (int) ((unsigned) eventp->xmotion.x_root -
+ (unsigned) DragX - JunkBW);
+ break;
+ }
+
+ if (ConstMoveDir != MOVE_NONE) {
+ int xl, yt, xr, yb, w2, h;
+
+ xl = ConstMoveX;
+ yt = ConstMoveY;
+ w2 = (int) ((unsigned) DragWidth + 2 * JunkBW);
+ h = (int) ((unsigned) DragHeight + 2 * JunkBW);
+
+ if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) {
+ xr = xl + w2;
+ yb = yt + h;
+
+ if (xl < 0)
+ xl = 0;
+ if (xr > Scr->MyDisplayWidth)
+ xl = Scr->MyDisplayWidth - w2;
+
+ if (yt < 0)
+ yt = 0;
+ if (yb > Scr->MyDisplayHeight)
+ yt = Scr->MyDisplayHeight - h;
+ }
+ CurrentDragX = xl;
+ CurrentDragY = yt;
+ if (Scr->OpaqueMove)
+ XMoveWindow(dpy, DragWindow, xl, yt);
+ else
+ MoveOutline(eventp->xmotion.root, xl, yt, w2, h,
+ tmp_win->frame_bw,
+ moving_icon ? 0 : tmp_win->title_height);
+ }
+ }
+ else if (DragWindow != None) {
+ int xl, yt, xr, yb, w2, h;
+
+ if (!menuFromFrameOrWindowOrTitlebar) {
+ xl = (int) ((unsigned) eventp->xmotion.x_root -
+ (unsigned) DragX - JunkBW);
+ yt = (int) ((unsigned) eventp->xmotion.y_root -
+ (unsigned) DragY - JunkBW);
+ }
+ else {
+ xl = (int) (eventp->xmotion.x_root - (DragWidth / 2));
+ yt = (int) (eventp->xmotion.y_root - (DragHeight / 2));
+ }
+ w2 = (int) ((unsigned) DragWidth + 2 * JunkBW);
+ h = (int) ((unsigned) DragHeight + 2 * JunkBW);
+
+ if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) {
+ xr = xl + w2;
+ yb = yt + h;
+
+ if (xl < 0)
+ xl = 0;
+ if (xr > Scr->MyDisplayWidth)
+ xl = Scr->MyDisplayWidth - w2;
+
+ if (yt < 0)
+ yt = 0;
+ if (yb > Scr->MyDisplayHeight)
+ yt = Scr->MyDisplayHeight - h;
}
- }
- if (fromtitlebar && Event.type == ButtonPress) {
- fromtitlebar = False;
- CurrentDragX = origX = Event.xbutton.x_root;
- CurrentDragY = origY = Event.xbutton.y_root;
- XTranslateCoordinates (dpy, rootw, tmp_win->frame,
- origX, origY,
- &DragX, &DragY, &JunkChild);
- continue;
- }
-
- if (!DispatchEvent2 ()) continue;
-
- if (Cancel)
- {
- WindowMoved = FALSE;
- if (!Scr->OpaqueMove)
- UninstallRootColormap();
- return TRUE; /* XXX should this be FALSE? */
- }
- if (Event.type == releaseEvent)
- {
- MoveOutline(rootw, 0, 0, 0, 0, 0, 0);
- if (moving_icon &&
- ((CurrentDragX != origDragX ||
- CurrentDragY != origDragY)))
- tmp_win->icon_moved = TRUE;
- if (!Scr->OpaqueMove && menuFromFrameOrWindowOrTitlebar)
- XMoveWindow(dpy, DragWindow,
- Event.xbutton.x_root - DragWidth / 2,
- Event.xbutton.y_root - DragHeight / 2);
- break;
- }
-
- /* something left to do only if the pointer moved */
- if (Event.type != MotionNotify)
- continue;
-
- XQueryPointer(dpy, rootw, &(eventp->xmotion.root), &JunkChild,
- &(eventp->xmotion.x_root), &(eventp->xmotion.y_root),
- &JunkX, &JunkY, &JunkMask);
-
- if (DragWindow == None &&
- abs(eventp->xmotion.x_root - origX) < Scr->MoveDelta &&
- abs(eventp->xmotion.y_root - origY) < Scr->MoveDelta)
- continue;
-
- WindowMoved = TRUE;
- DragWindow = w;
-
- if (!Scr->NoRaiseMove && Scr->OpaqueMove) /* can't restore... */
- XRaiseWindow(dpy, DragWindow);
-
- if (ConstMove)
- {
- switch (ConstMoveDir)
- {
- case MOVE_NONE:
- if (eventp->xmotion.x_root < ConstMoveXL ||
- eventp->xmotion.x_root > ConstMoveXR)
- ConstMoveDir = MOVE_HORIZ;
-
- if (eventp->xmotion.y_root < ConstMoveYT ||
- eventp->xmotion.y_root > ConstMoveYB)
- ConstMoveDir = MOVE_VERT;
-
- XQueryPointer(dpy, DragWindow, &JunkRoot, &JunkChild,
- &JunkX, &JunkY, &DragX, &DragY, &JunkMask);
- break;
-
- case MOVE_VERT:
- ConstMoveY = (int)((unsigned)eventp->xmotion.y_root - (unsigned)DragY - JunkBW);
- break;
-
- case MOVE_HORIZ:
- ConstMoveX= (int)((unsigned)eventp->xmotion.x_root - (unsigned)DragX - JunkBW);
- break;
- }
-
- if (ConstMoveDir != MOVE_NONE)
- {
- int xl, yt, xr, yb, w2, h;
-
- xl = ConstMoveX;
- yt = ConstMoveY;
- w2 = (int)((unsigned)DragWidth + 2 * JunkBW);
- h = (int)((unsigned)DragHeight + 2 * JunkBW);
-
- if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE)
- {
- xr = xl + w2;
- yb = yt + h;
-
- if (xl < 0)
- xl = 0;
- if (xr > Scr->MyDisplayWidth)
- xl = Scr->MyDisplayWidth - w2;
-
- if (yt < 0)
- yt = 0;
- if (yb > Scr->MyDisplayHeight)
- yt = Scr->MyDisplayHeight - h;
- }
- CurrentDragX = xl;
- CurrentDragY = yt;
- if (Scr->OpaqueMove)
- XMoveWindow(dpy, DragWindow, xl, yt);
- else
- MoveOutline(eventp->xmotion.root, xl, yt, w2, h,
- tmp_win->frame_bw,
- moving_icon ? 0 : tmp_win->title_height);
- }
- }
- else if (DragWindow != None)
- {
- int xl, yt, xr, yb, w2, h;
- if (!menuFromFrameOrWindowOrTitlebar) {
- xl = (int)((unsigned)eventp->xmotion.x_root - (unsigned)DragX - JunkBW);
- yt = (int)((unsigned)eventp->xmotion.y_root - (unsigned)DragY - JunkBW);
- }
- else {
- xl = (int)(eventp->xmotion.x_root - (DragWidth / 2));
- yt = (int)(eventp->xmotion.y_root - (DragHeight / 2));
- }
- w2 = (int)((unsigned)DragWidth + 2 * JunkBW);
- h = (int)((unsigned)DragHeight + 2 * JunkBW);
-
- if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE)
- {
- xr = xl + w2;
- yb = yt + h;
-
- if (xl < 0)
- xl = 0;
- if (xr > Scr->MyDisplayWidth)
- xl = Scr->MyDisplayWidth - w2;
-
- if (yt < 0)
- yt = 0;
- if (yb > Scr->MyDisplayHeight)
- yt = Scr->MyDisplayHeight - h;
- }
-
- CurrentDragX = xl;
- CurrentDragY = yt;
- if (Scr->OpaqueMove)
- XMoveWindow(dpy, DragWindow, xl, yt);
- else
- MoveOutline(eventp->xmotion.root, xl, yt, w2, h,
- tmp_win->frame_bw,
- moving_icon ? 0 : tmp_win->title_height);
- }
-
- }
- MovedFromKeyPress = False;
+ CurrentDragX = xl;
+ CurrentDragY = yt;
+ if (Scr->OpaqueMove)
+ XMoveWindow(dpy, DragWindow, xl, yt);
+ else
+ MoveOutline(eventp->xmotion.root, xl, yt, w2, h,
+ tmp_win->frame_bw,
+ moving_icon ? 0 : tmp_win->title_height);
+ }
- if (!Scr->OpaqueMove && DragWindow == None)
- UninstallRootColormap();
+ }
+ MovedFromKeyPress = False;
+
+ if (!Scr->OpaqueMove && DragWindow == None)
+ UninstallRootColormap();
break;
case F_FUNCTION:
- {
- MenuRoot *mroot;
- MenuItem *mitem;
-
- if ((mroot = FindMenuRoot(action)) == NULL)
- {
- fprintf (stderr, "%s: couldn't find function \"%s\"\n",
- ProgramName, action);
- return TRUE;
- }
-
- if (NeedToDefer(mroot) && DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
- else
- {
- for (mitem = mroot->first; mitem != NULL; mitem = mitem->next)
- {
- if (!ExecuteFunction (mitem->func, mitem->action, w,
- tmp_win, eventp, context, pulldown))
- break;
- }
- }
- }
- break;
+ {
+ MenuRoot *mroot;
+ MenuItem *mitem;
+
+ if ((mroot = FindMenuRoot(action)) == NULL) {
+ fprintf(stderr, "%s: couldn't find function \"%s\"\n",
+ ProgramName, action);
+ return TRUE;
+ }
+
+ if (NeedToDefer(mroot) &&
+ DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
+ else {
+ for (mitem = mroot->first; mitem != NULL; mitem = mitem->next) {
+ if (!ExecuteFunction(mitem->func, mitem->action, w,
+ tmp_win, eventp, context, pulldown))
+ break;
+ }
+ }
+ }
+ break;
case F_DEICONIFY:
case F_ICONIFY:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
-
- if (tmp_win->icon)
- {
- DeIconify(tmp_win);
- }
- else if (func == F_ICONIFY)
- {
- Iconify (tmp_win, eventp->xbutton.x_root - 5,
- eventp->xbutton.y_root - 5);
- }
- break;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
+
+ if (tmp_win->icon) {
+ DeIconify(tmp_win);
+ }
+ else if (func == F_ICONIFY) {
+ Iconify(tmp_win, eventp->xbutton.x_root - 5,
+ eventp->xbutton.y_root - 5);
+ }
+ break;
case F_RAISELOWER:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
- if (!WindowMoved) {
- XWindowChanges xwc;
+ if (!WindowMoved) {
+ XWindowChanges xwc;
- xwc.stack_mode = Opposite;
- if (w != tmp_win->icon_w)
- w = tmp_win->frame;
- XConfigureWindow (dpy, w, CWStackMode, &xwc);
- }
- break;
+ xwc.stack_mode = Opposite;
+ if (w != tmp_win->icon_w)
+ w = tmp_win->frame;
+ XConfigureWindow(dpy, w, CWStackMode, &xwc);
+ }
+ break;
case F_RAISE:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
- /* check to make sure raise is not from the WindowFunction */
- if (w == tmp_win->icon_w && Context != C_ROOT)
- XRaiseWindow(dpy, tmp_win->icon_w);
- else
- XRaiseWindow(dpy, tmp_win->frame);
+ /* check to make sure raise is not from the WindowFunction */
+ if (w == tmp_win->icon_w && Context != C_ROOT)
+ XRaiseWindow(dpy, tmp_win->icon_w);
+ else
+ XRaiseWindow(dpy, tmp_win->frame);
- break;
+ break;
case F_LOWER:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
- if (w == tmp_win->icon_w)
- XLowerWindow(dpy, tmp_win->icon_w);
- else
- XLowerWindow(dpy, tmp_win->frame);
+ if (w == tmp_win->icon_w)
+ XLowerWindow(dpy, tmp_win->icon_w);
+ else
+ XLowerWindow(dpy, tmp_win->frame);
- break;
+ break;
case F_FOCUS:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
-
- if (tmp_win->icon == FALSE)
- {
- if (!Scr->FocusRoot && Scr->Focus == tmp_win)
- {
- FocusOnRoot();
- }
- else
- {
- if (Scr->Focus != NULL) {
- SetBorder (Scr->Focus, False);
- if (Scr->Focus->hilite_w)
- XUnmapWindow (dpy, Scr->Focus->hilite_w);
- }
-
- InstallWindowColormaps (0, tmp_win);
- if (tmp_win->hilite_w) XMapWindow (dpy, tmp_win->hilite_w);
- SetBorder (tmp_win, True);
- if (!tmp_win->wmhints || tmp_win->wmhints->input)
- SetFocus (tmp_win, eventp->xbutton.time);
- Scr->FocusRoot = FALSE;
- Scr->Focus = tmp_win;
- }
- }
- break;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
+
+ if (tmp_win->icon == FALSE) {
+ if (!Scr->FocusRoot && Scr->Focus == tmp_win) {
+ FocusOnRoot();
+ }
+ else {
+ if (Scr->Focus != NULL) {
+ SetBorder(Scr->Focus, False);
+ if (Scr->Focus->hilite_w)
+ XUnmapWindow(dpy, Scr->Focus->hilite_w);
+ }
+
+ InstallWindowColormaps(0, tmp_win);
+ if (tmp_win->hilite_w)
+ XMapWindow(dpy, tmp_win->hilite_w);
+ SetBorder(tmp_win, True);
+ if (!tmp_win->wmhints || tmp_win->wmhints->input)
+ SetFocus(tmp_win, eventp->xbutton.time);
+ Scr->FocusRoot = FALSE;
+ Scr->Focus = tmp_win;
+ }
+ }
+ break;
case F_DESTROY:
- if (DeferExecution(context, func, Scr->DestroyCursor))
- return TRUE;
+ if (DeferExecution(context, func, Scr->DestroyCursor))
+ return TRUE;
- if (tmp_win->iconmgr)
- Bell(XkbBI_MinorError,0,tmp_win->w);
- else
- XKillClient(dpy, tmp_win->w);
- break;
+ if (tmp_win->iconmgr)
+ Bell(XkbBI_MinorError, 0, tmp_win->w);
+ else
+ XKillClient(dpy, tmp_win->w);
+ break;
case F_DELETE:
- if (DeferExecution(context, func, Scr->DestroyCursor))
- return TRUE;
-
- if (tmp_win->iconmgr) /* don't send ourself a message */
- HideIconManager ();
- else if (tmp_win->protocols & DoesWmDeleteWindow)
- SendDeleteWindowMessage (tmp_win, LastTimestamp());
- else
- Bell(XkbBI_MinorError,0,tmp_win->w);
- break;
+ if (DeferExecution(context, func, Scr->DestroyCursor))
+ return TRUE;
+
+ if (tmp_win->iconmgr) /* don't send ourself a message */
+ HideIconManager();
+ else if (tmp_win->protocols & DoesWmDeleteWindow)
+ SendDeleteWindowMessage(tmp_win, LastTimestamp());
+ else
+ Bell(XkbBI_MinorError, 0, tmp_win->w);
+ break;
case F_SAVEYOURSELF:
- if (DeferExecution (context, func, Scr->SelectCursor))
- return TRUE;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
- if (tmp_win->protocols & DoesWmSaveYourself)
- SendSaveYourselfMessage (tmp_win, LastTimestamp());
- else
- Bell(XkbBI_MinorError,0,tmp_win->w);
- break;
+ if (tmp_win->protocols & DoesWmSaveYourself)
+ SendSaveYourselfMessage(tmp_win, LastTimestamp());
+ else
+ Bell(XkbBI_MinorError, 0, tmp_win->w);
+ break;
case F_CIRCLEUP:
- XCirculateSubwindowsUp(dpy, Scr->Root);
- break;
+ XCirculateSubwindowsUp(dpy, Scr->Root);
+ break;
case F_CIRCLEDOWN:
- XCirculateSubwindowsDown(dpy, Scr->Root);
- break;
+ XCirculateSubwindowsDown(dpy, Scr->Root);
+ break;
case F_EXEC:
- PopDownMenu();
- if (!Scr->NoGrabServer) {
- XUngrabServer (dpy);
- XSync (dpy, 0);
- }
- Execute(action);
- break;
+ PopDownMenu();
+ if (!Scr->NoGrabServer) {
+ XUngrabServer(dpy);
+ XSync(dpy, 0);
+ }
+ Execute(action);
+ break;
case F_UNFOCUS:
- FocusOnRoot();
- break;
+ FocusOnRoot();
+ break;
case F_CUT:
- strcpy(tmp, action);
- strcat(tmp, "\n");
- XStoreBytes(dpy, tmp, (int)strlen(tmp));
- break;
+ strcpy(tmp, action);
+ strcat(tmp, "\n");
+ XStoreBytes(dpy, tmp, (int) strlen(tmp));
+ break;
case F_CUTFILE:
- ptr = XFetchBytes(dpy, &count);
- if (ptr) {
- if (sscanf (ptr, "%s", tmp) == 1) {
- XFree (ptr);
- ptr = ExpandFilename(tmp);
- if (ptr) {
- fd = open (ptr, O_RDONLY);
- if (fd >= 0) {
- count = (int)read (fd, buff, MAX_FILE_SIZE - 1);
- if (count > 0) XStoreBytes (dpy, buff, count);
- close(fd);
- } else {
- fprintf (stderr,
- "%s: unable to open cut file \"%s\"\n",
- ProgramName, tmp);
- }
- free (ptr);
- }
- } else {
- XFree(ptr);
- }
- } else {
- fprintf(stderr, "%s: cut buffer is empty\n", ProgramName);
- }
- break;
+ ptr = XFetchBytes(dpy, &count);
+ if (ptr) {
+ if (sscanf(ptr, "%s", tmp) == 1) {
+ XFree(ptr);
+ ptr = ExpandFilename(tmp);
+ if (ptr) {
+ fd = open(ptr, O_RDONLY);
+ if (fd >= 0) {
+ count = (int) read(fd, buff, MAX_FILE_SIZE - 1);
+ if (count > 0)
+ XStoreBytes(dpy, buff, count);
+ close(fd);
+ }
+ else {
+ fprintf(stderr,
+ "%s: unable to open cut file \"%s\"\n",
+ ProgramName, tmp);
+ }
+ free(ptr);
+ }
+ }
+ else {
+ XFree(ptr);
+ }
+ }
+ else {
+ fprintf(stderr, "%s: cut buffer is empty\n", ProgramName);
+ }
+ break;
case F_WARPTOSCREEN:
- {
- if (strcmp (action, WARPSCREEN_NEXT) == 0) {
- WarpToScreen (Scr->screen + 1, 1);
- } else if (strcmp (action, WARPSCREEN_PREV) == 0) {
- WarpToScreen (Scr->screen - 1, -1);
- } else if (strcmp (action, WARPSCREEN_BACK) == 0) {
- WarpToScreen (PreviousScreen, 0);
- } else {
- WarpToScreen (atoi (action), 0);
- }
- }
- break;
+ {
+ if (strcmp(action, WARPSCREEN_NEXT) == 0) {
+ WarpToScreen(Scr->screen + 1, 1);
+ }
+ else if (strcmp(action, WARPSCREEN_PREV) == 0) {
+ WarpToScreen(Scr->screen - 1, -1);
+ }
+ else if (strcmp(action, WARPSCREEN_BACK) == 0) {
+ WarpToScreen(PreviousScreen, 0);
+ }
+ else {
+ WarpToScreen(atoi(action), 0);
+ }
+ }
+ break;
case F_COLORMAP:
- {
- if (strcmp (action, COLORMAP_NEXT) == 0) {
- BumpWindowColormap (tmp_win, 1);
- } else if (strcmp (action, COLORMAP_PREV) == 0) {
- BumpWindowColormap (tmp_win, -1);
- } else {
- BumpWindowColormap (tmp_win, 0);
- }
- }
- break;
+ {
+ if (strcmp(action, COLORMAP_NEXT) == 0) {
+ BumpWindowColormap(tmp_win, 1);
+ }
+ else if (strcmp(action, COLORMAP_PREV) == 0) {
+ BumpWindowColormap(tmp_win, -1);
+ }
+ else {
+ BumpWindowColormap(tmp_win, 0);
+ }
+ }
+ break;
case F_WARPPREV:
case F_WARPNEXT:
- {
- register TwmWindow *t;
- static TwmWindow *savedwarp = NULL;
- TwmWindow *of, *l, *n;
- int c=0;
+ {
+ register TwmWindow *t;
+ static TwmWindow *savedwarp = NULL;
+ TwmWindow *of, *l, *n;
+ int c = 0;
#define wseq(w) (func == F_WARPNEXT ? (w)->next : (w)->prev)
#define nwin(w) ((w) && (n=wseq(w)) != NULL && n != &Scr->TwmRoot ? n : l)
#define bwin(w) (!(w)||(w)->iconmgr||(w)==of||!(Scr->WarpUnmapped||(w)->mapped))
- of=(Scr->Focus ? Scr->Focus : &Scr->TwmRoot);
-
- for(t=Scr->TwmRoot.next; t; t=t->next) if(!bwin(t)) break;
- if(!t) break; /* no windows we can use */
+ of = (Scr->Focus ? Scr->Focus : &Scr->TwmRoot);
+
+ for (t = Scr->TwmRoot.next; t; t = t->next)
+ if (!bwin(t))
+ break;
+ if (!t)
+ break; /* no windows we can use */
+
+ if (func == F_WARPPREV)
+ for (l = of; l->next; l = l->next);
+ else
+ l = Scr->TwmRoot.next;
+
+ for (t = of; bwin(t) && c < 2; t = nwin(t))
+ if (t == of)
+ c++;
+
+ if (bwin(t) || c >= 2)
+ Bell(XkbBI_MinorError, 0, None);
+ else {
+ if (of && of == savedwarp) {
+ Iconify(of, 0, 0);
+ savedwarp = NULL;
+ }
+ if (!t->mapped)
+ savedwarp = t;
+ else
+ savedwarp = NULL;
+ WarpThere(t);
+ }
+ break;
+ }
- if(func == F_WARPPREV) for(l=of; l->next; l=l->next) ;
- else l = Scr->TwmRoot.next;
+ case F_WARPTO:
+ {
+ register TwmWindow *t;
+ int len;
- for(t=of; bwin(t) && c < 2; t=nwin(t)) if(t == of) c++;
+ len = (int) strlen(action);
- if(bwin(t) || c >= 2) Bell(XkbBI_MinorError,0,None);
- else {
- if(of && of == savedwarp) {
- Iconify(of, 0, 0);
- savedwarp = NULL;
- }
- if(!t->mapped) savedwarp = t; else savedwarp = NULL;
- WarpThere(t);
- }
- break;
- }
+ for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
+ if (!strncmp(action, t->name, (size_t) len))
+ if (WarpThere(t))
+ break;
+ }
+ if (!t) {
+ for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
+ if (!strncmp(action, t->class.res_name, (size_t) len))
+ if (WarpThere(t))
+ break;
+ }
+ if (!t) {
+ for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
+ if (!strncmp(action, t->class.res_class, (size_t) len))
+ if (WarpThere(t))
+ break;
+ }
+ }
+ }
- case F_WARPTO:
- {
- register TwmWindow *t;
- int len;
-
- len = (int)strlen(action);
-
- for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
- if (!strncmp(action, t->name, (size_t)len))
- if (WarpThere(t)) break;
- }
- if (!t) {
- for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
- if (!strncmp(action, t->class.res_name, (size_t)len))
- if (WarpThere(t)) break;
- }
- if (!t) {
- for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
- if (!strncmp(action, t->class.res_class, (size_t)len))
- if (WarpThere(t)) break;
- }
- }
- }
-
- if (!t)
- Bell(XkbBI_MinorError,0,None);
- }
- break;
+ if (!t)
+ Bell(XkbBI_MinorError, 0, None);
+ }
+ break;
case F_WARPTOICONMGR:
- {
- TwmWindow *t;
- int len;
- Window raisewin = None, iconwin = None;
-
- len = (int)strlen(action);
- if (len == 0) {
- if (tmp_win && tmp_win->list) {
- raisewin = tmp_win->list->iconmgr->twm_win->frame;
- iconwin = tmp_win->list->icon;
- } else if (Scr->iconmgr.active) {
- raisewin = Scr->iconmgr.twm_win->frame;
- iconwin = Scr->iconmgr.active->w;
- }
- } else {
- for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
- if (strncmp (action, t->icon_name, (size_t)len) == 0) {
- if (t->list && t->list->iconmgr->twm_win->mapped) {
- raisewin = t->list->iconmgr->twm_win->frame;
- iconwin = t->list->icon;
- break;
- }
- }
- }
- }
-
- if (raisewin) {
- XRaiseWindow (dpy, raisewin);
- XWarpPointer (dpy, None, iconwin, 0,0,0,0, 5, 5);
- } else {
- Bell(XkbBI_MinorError,0,None);
- }
- }
- break;
+ {
+ TwmWindow *t;
+ int len;
+ Window raisewin = None, iconwin = None;
+
+ len = (int) strlen(action);
+ if (len == 0) {
+ if (tmp_win && tmp_win->list) {
+ raisewin = tmp_win->list->iconmgr->twm_win->frame;
+ iconwin = tmp_win->list->icon;
+ }
+ else if (Scr->iconmgr.active) {
+ raisewin = Scr->iconmgr.twm_win->frame;
+ iconwin = Scr->iconmgr.active->w;
+ }
+ }
+ else {
+ for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
+ if (strncmp(action, t->icon_name, (size_t) len) == 0) {
+ if (t->list && t->list->iconmgr->twm_win->mapped) {
+ raisewin = t->list->iconmgr->twm_win->frame;
+ iconwin = t->list->icon;
+ break;
+ }
+ }
+ }
+ }
+
+ if (raisewin) {
+ XRaiseWindow(dpy, raisewin);
+ XWarpPointer(dpy, None, iconwin, 0, 0, 0, 0, 5, 5);
+ }
+ else {
+ Bell(XkbBI_MinorError, 0, None);
+ }
+ }
+ break;
case F_WARPRING:
- switch (action[0]) {
- case 'n':
- WarpAlongRing (&eventp->xbutton, True);
- break;
- case 'p':
- WarpAlongRing (&eventp->xbutton, False);
- break;
- default:
- Bell(XkbBI_MinorError,0,None);
- break;
- }
- break;
+ switch (action[0]) {
+ case 'n':
+ WarpAlongRing(&eventp->xbutton, True);
+ break;
+ case 'p':
+ WarpAlongRing(&eventp->xbutton, False);
+ break;
+ default:
+ Bell(XkbBI_MinorError, 0, None);
+ break;
+ }
+ break;
case F_FILE:
- ptr = ExpandFilename(action);
- if (ptr) {
- fd = open(ptr, O_RDONLY);
- if (fd >= 0)
- {
- count = (int)read(fd, buff, MAX_FILE_SIZE - 1);
- if (count > 0)
- XStoreBytes(dpy, buff, count);
-
- close(fd);
- }
- else
- {
- fprintf (stderr, "%s: unable to open file \"%s\"\n",
- ProgramName, ptr);
- }
- free(ptr);
- } else {
- fprintf (stderr, "%s: error expanding filename\n", ProgramName);
- }
- break;
+ ptr = ExpandFilename(action);
+ if (ptr) {
+ fd = open(ptr, O_RDONLY);
+ if (fd >= 0) {
+ count = (int) read(fd, buff, MAX_FILE_SIZE - 1);
+ if (count > 0)
+ XStoreBytes(dpy, buff, count);
+
+ close(fd);
+ }
+ else {
+ fprintf(stderr, "%s: unable to open file \"%s\"\n",
+ ProgramName, ptr);
+ }
+ free(ptr);
+ }
+ else {
+ fprintf(stderr, "%s: error expanding filename\n", ProgramName);
+ }
+ break;
case F_REFRESH:
- {
- XSetWindowAttributes attributes;
- unsigned long valuemask;
-
- valuemask = (CWBackPixel | CWBackingStore | CWSaveUnder);
- attributes.background_pixel = Scr->Black;
- attributes.backing_store = NotUseful;
- attributes.save_under = False;
- w = XCreateWindow (dpy, Scr->Root, 0, 0,
- (unsigned int) Scr->MyDisplayWidth,
- (unsigned int) Scr->MyDisplayHeight,
- (unsigned int) 0,
- CopyFromParent, (unsigned int) CopyFromParent,
- (Visual *) CopyFromParent, valuemask,
- &attributes);
- XMapWindow (dpy, w);
- XDestroyWindow (dpy, w);
- XFlush (dpy);
- }
- break;
+ {
+ XSetWindowAttributes attributes;
+ unsigned long valuemask;
+
+ valuemask = (CWBackPixel | CWBackingStore | CWSaveUnder);
+ attributes.background_pixel = Scr->Black;
+ attributes.backing_store = NotUseful;
+ attributes.save_under = False;
+ w = XCreateWindow(dpy, Scr->Root, 0, 0,
+ (unsigned int) Scr->MyDisplayWidth,
+ (unsigned int) Scr->MyDisplayHeight,
+ (unsigned int) 0,
+ CopyFromParent, (unsigned int) CopyFromParent,
+ (Visual *) CopyFromParent, valuemask, &attributes);
+ XMapWindow(dpy, w);
+ XDestroyWindow(dpy, w);
+ XFlush(dpy);
+ }
+ break;
case F_WINREFRESH:
- if (DeferExecution(context, func, Scr->SelectCursor))
- return TRUE;
-
- if (context == C_ICON && tmp_win->icon_w)
- w = XCreateSimpleWindow(dpy, tmp_win->icon_w,
- 0, 0, 9999, 9999, 0, Scr->Black, Scr->Black);
- else
- w = XCreateSimpleWindow(dpy, tmp_win->frame,
- 0, 0, 9999, 9999, 0, Scr->Black, Scr->Black);
-
- XMapWindow(dpy, w);
- XDestroyWindow(dpy, w);
- XFlush(dpy);
- break;
+ if (DeferExecution(context, func, Scr->SelectCursor))
+ return TRUE;
+
+ if (context == C_ICON && tmp_win->icon_w)
+ w = XCreateSimpleWindow(dpy, tmp_win->icon_w,
+ 0, 0, 9999, 9999, 0, Scr->Black,
+ Scr->Black);
+ else
+ w = XCreateSimpleWindow(dpy, tmp_win->frame,
+ 0, 0, 9999, 9999, 0, Scr->Black,
+ Scr->Black);
+
+ XMapWindow(dpy, w);
+ XDestroyWindow(dpy, w);
+ XFlush(dpy);
+ break;
case F_QUIT:
- Done(NULL, NULL);
- break;
+ Done(NULL, NULL);
+ break;
case F_PRIORITY:
- if (HasSync)
- {
- if (DeferExecution (context, func, Scr->SelectCursor))
- return TRUE;
- (void)XSyncSetPriority(dpy, tmp_win->w, atoi(action));
+ 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;
+ 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);
+ if (ButtonPressed == -1)
+ XUngrabPointer(dpy, CurrentTime);
return do_next_action;
}
-
-
/**
* 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 func the function to defer
* \param cursor cursor the cursor to display while waiting
*/
static int
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);
+ if (context == C_ROOT) {
+ LastCursor = cursor;
+ XGrabPointer(dpy, Scr->Root, True,
+ ButtonPressMask | ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync,
+ Scr->Root, cursor, CurrentTime);
- RootFunction = func;
+ RootFunction = func;
- return (TRUE);
+ return (TRUE);
}
return (FALSE);
}
-
-
/**
*regrab the pointer with the LastCursor;
*/
@@ -2294,13 +2237,11 @@ void
ReGrab(void)
{
XGrabPointer(dpy, Scr->Root, True,
- ButtonPressMask | ButtonReleaseMask,
- GrabModeAsync, GrabModeAsync,
- Scr->Root, LastCursor, CurrentTime);
+ ButtonPressMask | ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync,
+ Scr->Root, LastCursor, CurrentTime);
}
-
-
/**
* checks each function in the list to see if it is one that needs
* to be deferred.
@@ -2312,53 +2253,49 @@ 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:
+ 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;
- }
+ case F_AUTORAISE:
+ return TRUE;
+ }
}
return FALSE;
}
-
-
static void
Execute(const char *s)
{
- /* FIXME: is all this stuff needed? There could be security problems here. */
+ /* FIXME: is all this stuff needed? There could be security problems here. */
static char buf[256];
- char *ds = DisplayString (dpy);
+ char *ds = DisplayString(dpy);
char *colon, *dot1;
char oldDisplay[256];
char *doisplay;
int restorevar = 0;
oldDisplay[0] = '\0';
- doisplay=getenv("DISPLAY");
+ doisplay = getenv("DISPLAY");
if (doisplay)
- strcpy (oldDisplay, doisplay);
+ strcpy(oldDisplay, doisplay);
/*
* Build a display string using the current screen number, so that
@@ -2366,39 +2303,38 @@ Execute(const char *s)
* 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;
+ 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);
+ (void) system(s);
- if (restorevar) { /* why bother? */
- (void) snprintf (buf, sizeof(buf), "DISPLAY=%s", oldDisplay);
- putenv (buf);
+ if (restorevar) { /* why bother? */
+ (void) snprintf(buf, sizeof(buf), "DISPLAY=%s", oldDisplay);
+ putenv(buf);
}
}
-
-
/**
* put input focus on the root window.
*/
void
FocusOnRoot(void)
{
- SetFocus ((TwmWindow *) NULL, LastTimestamp());
- if (Scr->Focus != NULL)
- {
- SetBorder (Scr->Focus, False);
- if (Scr->Focus->hilite_w) XUnmapWindow (dpy, Scr->Focus->hilite_w);
+ 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;
@@ -2411,77 +2347,69 @@ 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;
- }
- }
- }
+ 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;
+ }
+ }
+ }
}
XMapWindow(dpy, tmp_win->w);
tmp_win->mapped = TRUE;
if (Scr->NoRaiseDeicon)
- XMapWindow(dpy, tmp_win->frame);
+ XMapWindow(dpy, tmp_win->frame);
else
- XMapRaised(dpy, tmp_win->frame);
+ XMapRaised(dpy, tmp_win->frame);
SetMapStateProp(tmp_win, NormalState);
if (tmp_win->icon_w) {
- XUnmapWindow(dpy, tmp_win->icon_w);
- IconDown (tmp_win);
+ XUnmapWindow(dpy, tmp_win->icon_w);
+ IconDown(tmp_win);
}
if (tmp_win->list)
- XUnmapWindow(dpy, tmp_win->list->icon);
+ XUnmapWindow(dpy, tmp_win->list->icon);
if ((Scr->WarpCursor ||
- LookInList(Scr->WarpCursorL, tmp_win->full_name, &tmp_win->class)) &&
- tmp_win->icon)
- WarpToWindow (tmp_win);
+ LookInList(Scr->WarpCursorL, tmp_win->full_name, &tmp_win->class)) &&
+ tmp_win->icon)
+ WarpToWindow(tmp_win);
tmp_win->icon = FALSE;
tmp_win->icon_on = FALSE;
-
/* now de-iconify transients */
- for (t = Scr->TwmRoot.next; t != NULL; t = t->next)
- {
- if (t->transient && t->transientfor == tmp_win->w)
- {
- if (t->icon_on)
- Zoom(t->icon_w, t->frame);
- else
- Zoom(tmp_win->icon_w, t->frame);
-
- XMapWindow(dpy, t->w);
- t->mapped = TRUE;
- 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);
-}
+ for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
+ if (t->transient && t->transientfor == tmp_win->w) {
+ if (t->icon_on)
+ Zoom(t->icon_w, t->frame);
+ else
+ Zoom(tmp_win->icon_w, t->frame);
+
+ XMapWindow(dpy, t->w);
+ t->mapped = TRUE;
+ 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(TwmWindow *tmp_win, int def_x, int def_y)
@@ -2492,91 +2420,87 @@ Iconify(TwmWindow *tmp_win, int def_x, int def_y)
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 (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);
+ XMapWindow(dpy, tmp_win->list->icon);
XGetWindowAttributes(dpy, tmp_win->w, &winattrs);
- eventMask = (unsigned long)winattrs.your_event_mask;
+ eventMask = (unsigned long) winattrs.your_event_mask;
/* iconify transients first */
- for (t = Scr->TwmRoot.next; t != NULL; t = t->next)
- {
- if (t->transient && t->transientfor == tmp_win->w)
- {
- if (iconify)
- {
- if (t->icon_on)
- Zoom(t->icon_w, tmp_win->icon_w);
- else
- Zoom(t->frame, tmp_win->icon_w);
- }
-
- /*
- * Prevent the receipt of an UnmapNotify, since that would
- * cause a transition to the Withdrawn state.
- */
- t->mapped = FALSE;
- XSelectInput(dpy, t->w, (long)(eventMask & (unsigned long)(~StructureNotifyMask)));
- XUnmapWindow(dpy, t->w);
- XSelectInput(dpy, t->w, (long)eventMask);
- XUnmapWindow(dpy, t->frame);
- if (t->icon_w)
- XUnmapWindow(dpy, t->icon_w);
- SetMapStateProp(t, IconicState);
- SetBorder (t, False);
- if (t == Scr->Focus)
- {
- SetFocus ((TwmWindow *) NULL, LastTimestamp());
- Scr->Focus = NULL;
- Scr->FocusRoot = TRUE;
- }
- if (t->list) XMapWindow(dpy, t->list->icon);
- t->icon = TRUE;
- t->icon_on = FALSE;
- }
- }
+ for (t = Scr->TwmRoot.next; t != NULL; t = t->next) {
+ if (t->transient && t->transientfor == tmp_win->w) {
+ if (iconify) {
+ if (t->icon_on)
+ Zoom(t->icon_w, tmp_win->icon_w);
+ else
+ Zoom(t->frame, tmp_win->icon_w);
+ }
+
+ /*
+ * Prevent the receipt of an UnmapNotify, since that would
+ * cause a transition to the Withdrawn state.
+ */
+ t->mapped = FALSE;
+ XSelectInput(dpy, t->w,
+ (long) (eventMask &
+ (unsigned long) (~StructureNotifyMask)));
+ XUnmapWindow(dpy, t->w);
+ XSelectInput(dpy, t->w, (long) eventMask);
+ XUnmapWindow(dpy, t->frame);
+ if (t->icon_w)
+ XUnmapWindow(dpy, t->icon_w);
+ SetMapStateProp(t, IconicState);
+ SetBorder(t, False);
+ if (t == Scr->Focus) {
+ SetFocus((TwmWindow *) NULL, LastTimestamp());
+ Scr->Focus = NULL;
+ Scr->FocusRoot = TRUE;
+ }
+ if (t->list)
+ XMapWindow(dpy, t->list->icon);
+ t->icon = TRUE;
+ t->icon_on = FALSE;
+ }
+ }
if (iconify)
- Zoom(tmp_win->frame, tmp_win->icon_w);
+ Zoom(tmp_win->frame, tmp_win->icon_w);
/*
* Prevent the receipt of an UnmapNotify, since that would
* cause a transition to the Withdrawn state.
*/
tmp_win->mapped = FALSE;
- XSelectInput(dpy, tmp_win->w, (long)(eventMask & (unsigned long)(~StructureNotifyMask)));
+ XSelectInput(dpy, tmp_win->w,
+ (long) (eventMask & (unsigned long) (~StructureNotifyMask)));
XUnmapWindow(dpy, tmp_win->w);
- XSelectInput(dpy, tmp_win->w, (long)eventMask);
+ XSelectInput(dpy, tmp_win->w, (long) eventMask);
XUnmapWindow(dpy, tmp_win->frame);
SetMapStateProp(tmp_win, IconicState);
- SetBorder (tmp_win, False);
- if (tmp_win == Scr->Focus)
- {
- SetFocus ((TwmWindow *) NULL, LastTimestamp());
- Scr->Focus = NULL;
- Scr->FocusRoot = TRUE;
+ 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;
+ tmp_win->icon_on = TRUE;
else
- tmp_win->icon_on = FALSE;
- XSync (dpy, 0);
+ tmp_win->icon_on = FALSE;
+ XSync(dpy, 0);
}
-
-
static void
-Identify (TwmWindow *t)
+Identify(TwmWindow *t)
{
int i, n, twidth, width, height;
int x, y;
@@ -2590,81 +2514,81 @@ Identify (TwmWindow *t)
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);
- snprintf(Info[n++], INFO_SIZE,
- "Name = \"%s\"", t->full_name);
- snprintf(Info[n++], INFO_SIZE,
- "Class.res_name = \"%s\"", t->class.res_name);
- snprintf(Info[n++], INFO_SIZE,
- "Class.res_class = \"%s\"", t->class.res_class);
- Info[n++][0] = '\0';
- snprintf(Info[n++], INFO_SIZE,
- "Geometry/root = %dx%d+%d+%d", wwidth, wheight, x, y);
- snprintf(Info[n++], INFO_SIZE, "Border width = %d", bw);
- snprintf(Info[n++], INFO_SIZE, "Depth = %d", depth);
- if (HasSync)
- {
- int priority;
- (void)XSyncGetPriority(dpy, t->w, &priority);
- snprintf(Info[n++], INFO_SIZE, "Priority = %d", priority);
- }
+ XGetGeometry(dpy, t->w, &JunkRoot, &JunkX, &JunkY,
+ &wwidth, &wheight, &bw, &depth);
+ (void) XTranslateCoordinates(dpy, t->w, Scr->Root, 0, 0, &x, &y, &junk);
+ snprintf(Info[n++], INFO_SIZE,
+ "Name = \"%s\"", t->full_name);
+ snprintf(Info[n++], INFO_SIZE,
+ "Class.res_name = \"%s\"", t->class.res_name);
+ snprintf(Info[n++], INFO_SIZE,
+ "Class.res_class = \"%s\"", t->class.res_class);
+ Info[n++][0] = '\0';
+ snprintf(Info[n++], INFO_SIZE,
+ "Geometry/root = %dx%d+%d+%d", wwidth, wheight, x, y);
+ snprintf(Info[n++], INFO_SIZE, "Border width = %d", bw);
+ snprintf(Info[n++], INFO_SIZE, "Depth = %d", depth);
+ if (HasSync) {
+ int priority;
+
+ (void) XSyncGetPriority(dpy, t->w, &priority);
+ snprintf(Info[n++], INFO_SIZE, "Priority = %d", priority);
+ }
}
Info[n++][0] = '\0';
snprintf(Info[n++], INFO_SIZE, "Click to dismiss....");
/* figure out the width and height of the info window */
- height = n * (Scr->DefaultFont.height+2);
+ height = n * (Scr->DefaultFont.height + 2);
width = 1;
- for (i = 0; i < n; i++)
- {
- twidth = MyFont_TextWidth(&Scr->DefaultFont, Info[i],
- (int)strlen(Info[i]));
- if (twidth > width)
- width = twidth;
- }
- if (InfoLines) XUnmapWindow(dpy, Scr->InfoWindow);
-
- width += 10; /* some padding */
- 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, (unsigned)width, (unsigned)height);
+ for (i = 0; i < n; i++) {
+ twidth = MyFont_TextWidth(&Scr->DefaultFont, Info[i],
+ (int) strlen(Info[i]));
+ if (twidth > width)
+ width = twidth;
+ }
+ if (InfoLines)
+ XUnmapWindow(dpy, Scr->InfoWindow);
+
+ width += 10; /* some padding */
+ 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, (unsigned) width,
+ (unsigned) height);
XMapRaised(dpy, Scr->InfoWindow);
InfoLines = n;
}
-
void
SetMapStateProp(TwmWindow *tmp_win, int state)
{
- unsigned long data[2]; /* "suggested" by ICCCM version 1 */
+ 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);
+ tmp_win->icon_w);
- XChangeProperty (dpy, tmp_win->w, _XA_WM_STATE, _XA_WM_STATE, 32,
- PropModeReplace, (unsigned char *) data, 2);
+ XChangeProperty(dpy, tmp_win->w, _XA_WM_STATE, _XA_WM_STATE, 32,
+ PropModeReplace, (unsigned char *) data, 2);
}
-
-
Bool
-GetWMState (Window w, int *statep, Window *iwp)
+GetWMState(Window w, int *statep, Window *iwp)
{
Atom actual_type;
int actual_format;
@@ -2672,25 +2596,25 @@ GetWMState (Window w, int *statep, Window *iwp)
unsigned char *prop_return = NULL;
Bool retval = False;
- if (XGetWindowProperty (dpy, w, _XA_WM_STATE, 0L, 2L, False, _XA_WM_STATE,
- &actual_type, &actual_format, &nitems, &bytesafter,
- &prop_return) != Success || !prop_return)
- return False;
+ if (XGetWindowProperty(dpy, w, _XA_WM_STATE, 0L, 2L, False, _XA_WM_STATE,
+ &actual_type, &actual_format, &nitems, &bytesafter,
+ &prop_return) != Success || !prop_return)
+ return False;
- if (nitems <= 2) { /* "suggested" by ICCCM version 1 */
- unsigned long *datap = (unsigned long *) prop_return;
- *statep = (int) datap[0];
- *iwp = (Window) datap[1];
- retval = True;
+ if (nitems <= 2) { /* "suggested" by ICCCM version 1 */
+ unsigned long *datap = (unsigned long *) prop_return;
+
+ *statep = (int) datap[0];
+ *iwp = (Window) datap[1];
+ retval = True;
}
- XFree (prop_return);
+ XFree(prop_return);
return retval;
}
-
void
-WarpToScreen (int n, int inc)
+WarpToScreen(int n, int inc)
{
Window dumwin;
int x, y, dumint;
@@ -2698,221 +2622,219 @@ WarpToScreen (int n, int inc)
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 */
+ /* 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);
+ XQueryPointer(dpy, Scr->Root, &dumwin, &dumwin, &x, &y,
+ &dumint, &dumint, &dummask);
- XWarpPointer (dpy, None, newscr->Root, 0, 0, 0, 0, x, y);
+ XWarpPointer(dpy, None, newscr->Root, 0, 0, 0, 0, x, y);
return;
}
-
-
-
/**
* rotate our internal copy of WM_COLORMAP_WINDOWS
*/
static void
-BumpWindowColormap (TwmWindow *tmp, int inc)
+BumpWindowColormap(TwmWindow *tmp, int inc)
{
int i, j, previously_installed;
ColormapWindow **cwins;
- if (!tmp) return;
+ if (!tmp)
+ return;
if (inc && tmp->cmaps.number_cwins > 0) {
- cwins = malloc(sizeof(ColormapWindow *) * (size_t)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)
- j -= tmp->cmaps.number_cwins;
- else if (j < 0)
- j += tmp->cmaps.number_cwins;
- cwins[j] = tmp->cmaps.cwins[i];
- }
-
- free(tmp->cmaps.cwins);
-
- tmp->cmaps.cwins = cwins;
-
- if (tmp->cmaps.number_cwins > 1)
- bzero (tmp->cmaps.scoreboard,
- ColormapsScoreboardLength(&tmp->cmaps));
-
- if (previously_installed)
- InstallWindowColormaps(PropertyNotify, (TwmWindow *) NULL);
- }
- } else
- FetchWmColormapWindows (tmp);
+ cwins =
+ malloc(sizeof(ColormapWindow *) * (size_t) tmp->cmaps.number_cwins);
+ if (cwins) {
+ /* SUPPRESS 560 */
+ if ((previously_installed = (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)
+ j -= tmp->cmaps.number_cwins;
+ else if (j < 0)
+ j += tmp->cmaps.number_cwins;
+ cwins[j] = tmp->cmaps.cwins[i];
+ }
+
+ free(tmp->cmaps.cwins);
+
+ tmp->cmaps.cwins = cwins;
+
+ if (tmp->cmaps.number_cwins > 1)
+ bzero(tmp->cmaps.scoreboard,
+ ColormapsScoreboardLength(&tmp->cmaps));
+
+ if (previously_installed)
+ InstallWindowColormaps(PropertyNotify, (TwmWindow *) NULL);
+ }
+ }
+ else
+ FetchWmColormapWindows(tmp);
}
-
static void
-HideIconManager (void)
+HideIconManager(void)
{
- SetMapStateProp (Scr->iconmgr.twm_win, WithdrawnState);
+ 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);
+ XUnmapWindow(dpy, Scr->iconmgr.twm_win->icon_w);
Scr->iconmgr.twm_win->mapped = FALSE;
Scr->iconmgr.twm_win->icon = TRUE;
}
-
-
void
-SetBorder (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);
- }
+ 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);
+ }
}
}
-
static void
-DestroyMenu (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);
+ 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 (tmp);
+ for (item = menu->first; item;) {
+ MenuItem *tmp = item;
+
+ item = item->next;
+ free(tmp);
}
}
-
-
/*
* warping routines
*/
static void
-WarpAlongRing (XButtonEvent *ev, Bool forward)
+WarpAlongRing(XButtonEvent *ev, Bool forward)
{
TwmWindow *r, *head;
if (Scr->RingLeader)
- head = Scr->RingLeader;
+ head = Scr->RingLeader;
else if (!(head = Scr->Ring))
- return;
+ 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;
- }
+ 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;
- XPointer context_data;
-
- Scr->RingLeader = r;
- WarpToWindow (r);
-
- if (XFindContext (dpy, ev->window, TwmContext, &context_data) == 0)
- t = (TwmWindow *) context_data;
- else
- t = NULL;
-
- if (p && p->mapped && 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;
- }
- }
+ TwmWindow *p = Scr->RingLeader, *t;
+ XPointer context_data;
+
+ Scr->RingLeader = r;
+ WarpToWindow(r);
+
+ if (XFindContext(dpy, ev->window, TwmContext, &context_data) == 0)
+ t = (TwmWindow *) context_data;
+ else
+ t = NULL;
+
+ if (p && p->mapped && 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;
+ }
+ }
}
}
-
-
static void
-WarpToWindow (TwmWindow *t)
+WarpToWindow(TwmWindow *t)
{
int x, y;
- if (t->auto_raise || !Scr->NoRaiseWarp) AutoRaiseWindow (t);
+ 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;
+ x = t->ring.curs_x;
+ y = t->ring.curs_y;
}
- XWarpPointer (dpy, None, t->frame, 0, 0, 0, 0, x, 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
+ * 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 (Window w, Atom a, Time timestamp)
+send_clientmessage(Window w, Atom a, Time timestamp)
{
XClientMessageEvent ev;
@@ -2920,25 +2842,25 @@ send_clientmessage (Window w, Atom a, Time timestamp)
ev.window = w;
ev.message_type = _XA_WM_PROTOCOLS;
ev.format = 32;
- ev.data.l[0] = (long)a;
- ev.data.l[1] = (long)timestamp;
- XSendEvent (dpy, w, False, 0L, (XEvent *) &ev);
+ ev.data.l[0] = (long) a;
+ ev.data.l[1] = (long) timestamp;
+ XSendEvent(dpy, w, False, 0L, (XEvent *) &ev);
}
void
-SendDeleteWindowMessage (TwmWindow *tmp, Time timestamp)
+SendDeleteWindowMessage(TwmWindow *tmp, Time timestamp)
{
- send_clientmessage (tmp->w, _XA_WM_DELETE_WINDOW, timestamp);
+ send_clientmessage(tmp->w, _XA_WM_DELETE_WINDOW, timestamp);
}
void
-SendSaveYourselfMessage (TwmWindow *tmp, Time timestamp)
+SendSaveYourselfMessage(TwmWindow *tmp, Time timestamp)
{
- send_clientmessage (tmp->w, _XA_WM_SAVE_YOURSELF, timestamp);
+ send_clientmessage(tmp->w, _XA_WM_SAVE_YOURSELF, timestamp);
}
void
-SendTakeFocusMessage (TwmWindow *tmp, Time timestamp)
+SendTakeFocusMessage(TwmWindow *tmp, Time timestamp)
{
- send_clientmessage (tmp->w, _XA_WM_TAKE_FOCUS, timestamp);
+ send_clientmessage(tmp->w, _XA_WM_TAKE_FOCUS, timestamp);
}
diff --git a/src/menus.h b/src/menus.h
index cadffaf..de0629c 100644
--- a/src/menus.h
+++ b/src/menus.h
@@ -49,87 +49,81 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* twm menus include file
*
- * 17-Nov-87 Thomas E. LaStrange File created
+ * 17-Nov-87 Thomas E. LaStrange File created
*
***********************************************************************/
#ifndef _MENUS_
#define _MENUS_
-#define TWM_ROOT "bLoB_GoOp" /* my private root menu */
-#define TWM_WINDOWS "TwmWindows" /* for f.menu "TwmWindows" */
-
-#define MAX_FILE_SIZE 4096 /* max chars to read from file for cut */
-
-typedef struct MenuItem
-{
- struct MenuItem *next; /* next menu item */
- struct MenuItem *prev; /* prev menu item */
- struct MenuRoot *sub; /* MenuRoot of a pull right menu */
- struct MenuRoot *root; /* back pointer to my MenuRoot */
- const char *item; /* the character string displayed */
- const char *action; /* action to be performed */
- Pixel fore; /* foreground color */
- Pixel back; /* background color */
- Pixel hi_fore; /* highlight foreground */
- Pixel hi_back; /* highlight background */
- short item_num; /* item number of this menu */
- short x; /* x coordinate for text */
- short func; /* twm built in function */
- short state; /* video state, 0 = normal, 1 = reversed */
- short strlen; /* strlen(item) */
- short user_colors; /* colors were specified */
+#define TWM_ROOT "bLoB_GoOp" /* my private root menu */
+#define TWM_WINDOWS "TwmWindows" /* for f.menu "TwmWindows" */
+
+#define MAX_FILE_SIZE 4096 /* max chars to read from file for cut */
+
+typedef struct MenuItem {
+ struct MenuItem *next; /* next menu item */
+ struct MenuItem *prev; /* prev menu item */
+ struct MenuRoot *sub; /* MenuRoot of a pull right menu */
+ struct MenuRoot *root; /* back pointer to my MenuRoot */
+ const char *item; /* the character string displayed */
+ const char *action; /* action to be performed */
+ Pixel fore; /* foreground color */
+ Pixel back; /* background color */
+ Pixel hi_fore; /* highlight foreground */
+ Pixel hi_back; /* highlight background */
+ short item_num; /* item number of this menu */
+ short x; /* x coordinate for text */
+ short func; /* twm built in function */
+ short state; /* video state, 0 = normal, 1 = reversed */
+ short strlen; /* strlen(item) */
+ short user_colors; /* colors were specified */
} MenuItem;
-typedef struct MenuRoot
-{
- struct MenuItem *first; /* first item in menu */
- struct MenuItem *last; /* last item in menu */
- struct MenuRoot *prev; /* previous root menu if pull right */
- struct MenuRoot *next; /* next in list of root menus */
- const char *name; /* name of root */
- Window w; /* the window of the menu */
- Window shadow; /* the shadow window */
- Pixel hi_fore; /* highlight foreground */
- Pixel hi_back; /* highlight background */
- short mapped; /* NEVER_MAPPED, UNMAPPED, or MAPPED */
- short height; /* height of the menu */
- short width; /* width of the menu */
- short items; /* number of items in the menu */
- short pull; /* is there a pull right entry ? */
- short entered; /* EnterNotify following pop up */
- short real_menu; /* this is a real menu */
+typedef struct MenuRoot {
+ struct MenuItem *first; /* first item in menu */
+ struct MenuItem *last; /* last item in menu */
+ struct MenuRoot *prev; /* previous root menu if pull right */
+ struct MenuRoot *next; /* next in list of root menus */
+ const char *name; /* name of root */
+ Window w; /* the window of the menu */
+ Window shadow; /* the shadow window */
+ Pixel hi_fore; /* highlight foreground */
+ Pixel hi_back; /* highlight background */
+ short mapped; /* NEVER_MAPPED, UNMAPPED, or MAPPED */
+ short height; /* height of the menu */
+ short width; /* width of the menu */
+ short items; /* number of items in the menu */
+ short pull; /* is there a pull right entry ? */
+ short entered; /* EnterNotify following pop up */
+ short real_menu; /* this is a real menu */
} MenuRoot;
-#define NEVER_MAPPED 0 /* constants for mapped field of MenuRoot */
-#define UNMAPPED 1
-#define MAPPED 2
-
+#define NEVER_MAPPED 0 /* constants for mapped field of MenuRoot */
+#define UNMAPPED 1
+#define MAPPED 2
-typedef struct MouseButton
-{
- int func; /* the function number */
- int mask; /* modifier mask */
- MenuRoot *menu; /* menu if func is F_MENU */
- MenuItem *item; /* action to perform if func != F_MENU */
+typedef struct MouseButton {
+ int func; /* the function number */
+ int mask; /* modifier mask */
+ MenuRoot *menu; /* menu if func is F_MENU */
+ MenuItem *item; /* action to perform if func != F_MENU */
} MouseButton;
-typedef struct FuncKey
-{
- struct FuncKey *next; /* next in the list of function keys */
- char *name; /* key name */
- KeySym keysym; /* X keysym */
- KeyCode keycode; /* X keycode */
- int cont; /* context */
- int mods; /* modifiers */
- int func; /* function to perform */
- char *win_name; /* window name (if any) */
- char *action; /* action string (if any) */
+typedef struct FuncKey {
+ struct FuncKey *next; /* next in the list of function keys */
+ char *name; /* key name */
+ KeySym keysym; /* X keysym */
+ KeyCode keycode; /* X keycode */
+ int cont; /* context */
+ int mods; /* modifiers */
+ int func; /* function to perform */
+ char *win_name; /* window name (if any) */
+ char *action; /* action string (if any) */
} FuncKey;
extern int RootFunction;
@@ -149,12 +143,12 @@ extern int menuFromFrameOrWindowOrTitlebar;
extern int ResizeOrigX;
extern int ResizeOrigY;
-#define MAXMENUDEPTH 10 /* max number of nested menus */
+#define MAXMENUDEPTH 10 /* max number of nested menus */
extern int MenuDepth;
-#define MOVE_NONE 0 /* modes of constrained move */
-#define MOVE_VERT 1
-#define MOVE_HORIZ 2
+#define MOVE_NONE 0 /* modes of constrained move */
+#define MOVE_VERT 1
+#define MOVE_HORIZ 2
#define WARPSCREEN_NEXT "next"
#define WARPSCREEN_PREV "prev"
@@ -164,29 +158,35 @@ extern int MenuDepth;
#define COLORMAP_PREV "prev"
#define COLORMAP_DEFAULT "default"
-extern void InitMenus ( void );
-extern Bool AddFuncKey ( char *name, int cont, int mods, int func, char *win_name, char *action );
-extern int CreateTitleButton ( const char *name, int func, const char *action, MenuRoot *menuroot, Bool rightside, Bool append );
-extern void InitTitlebarButtons ( void );
-extern void PaintEntry ( MenuRoot *mr, MenuItem *mi, int exposure );
-extern void PaintMenu ( MenuRoot *mr, XEvent *e );
-extern void UpdateMenu ( void );
-extern MenuRoot * NewMenuRoot ( const char *name );
-extern MenuItem * AddToMenu ( MenuRoot *menu, const char *item, const char *action, MenuRoot *sub, int func, const char *fore, const char *back );
-extern void MakeMenus ( void );
-extern Bool PopUpMenu ( MenuRoot *menu, int x, int y, Bool center );
-extern void PopDownMenu ( void );
-extern MenuRoot * FindMenuRoot ( const char *name );
-extern int ExecuteFunction ( int func, const char *action, Window w, TwmWindow *tmp_win, XEvent *eventp, int context, int pulldown );
-extern void ReGrab ( void );
-extern void FocusOnRoot ( void );
-extern void DeIconify ( TwmWindow *tmp_win );
-extern void Iconify ( TwmWindow *tmp_win, int def_x, int def_y );
-extern void SetMapStateProp ( TwmWindow *tmp_win, int state );
-extern void WarpToScreen ( int n, int inc );
-extern void SetBorder ( TwmWindow *tmp, Bool onoroff );
-extern void SendDeleteWindowMessage ( TwmWindow *tmp, Time timestamp );
-extern void SendSaveYourselfMessage ( TwmWindow *tmp, Time timestamp );
-extern void SendTakeFocusMessage ( TwmWindow *tmp, Time timestamp );
-
-#endif /* _MENUS_ */
+extern void InitMenus(void);
+extern Bool AddFuncKey(char *name, int cont, int mods, int func, char *win_name,
+ char *action);
+extern int CreateTitleButton(const char *name, int func, const char *action,
+ MenuRoot *menuroot, Bool rightside, Bool append);
+extern void InitTitlebarButtons(void);
+extern void PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure);
+extern void PaintMenu(MenuRoot *mr, XEvent *e);
+extern void UpdateMenu(void);
+extern MenuRoot *NewMenuRoot(const char *name);
+extern MenuItem *AddToMenu(MenuRoot *menu, const char *item, const char *action,
+ MenuRoot *sub, int func, const char *fore,
+ const char *back);
+extern void MakeMenus(void);
+extern Bool PopUpMenu(MenuRoot *menu, int x, int y, Bool center);
+extern void PopDownMenu(void);
+extern MenuRoot *FindMenuRoot(const char *name);
+extern int ExecuteFunction(int func, const char *action, Window w,
+ TwmWindow *tmp_win, XEvent *eventp, int context,
+ int pulldown);
+extern void ReGrab(void);
+extern void FocusOnRoot(void);
+extern void DeIconify(TwmWindow *tmp_win);
+extern void Iconify(TwmWindow *tmp_win, int def_x, int def_y);
+extern void SetMapStateProp(TwmWindow *tmp_win, int state);
+extern void WarpToScreen(int n, int inc);
+extern void SetBorder(TwmWindow *tmp, Bool onoroff);
+extern void SendDeleteWindowMessage(TwmWindow *tmp, Time timestamp);
+extern void SendSaveYourselfMessage(TwmWindow *tmp, Time timestamp);
+extern void SendTakeFocusMessage(TwmWindow *tmp, Time timestamp);
+
+#endif /* _MENUS_ */
diff --git a/src/parse.c b/src/parse.c
index 044e02c..d81c2f3 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* parse the .twmrc file
@@ -78,30 +77,30 @@ in this Software without prior written authorization from The Open Group.
static FILE *twmrc;
static int ptr = 0;
static int len = 0;
-static unsigned char buff[BUF_LEN+1];
-static unsigned char overflowbuff[20]; /* really only need one */
+static unsigned char buff[BUF_LEN + 1];
+static unsigned char overflowbuff[20]; /* really only need one */
static int overflowlen;
static unsigned char **stringListSource, *currentString;
-static int doparse ( int (*ifunc)(void), const char *srctypename, const char *srcname );
-static int twmFileInput ( void );
-static int twmStringListInput ( void );
-static int ParseUsePPosition ( char *s );
-static int ParseStringList ( unsigned char **sl );
+static int doparse(int (*ifunc) (void), const char *srctypename,
+ const char *srcname);
+static int twmFileInput(void);
+static int twmStringListInput(void);
+static int ParseUsePPosition(char *s);
+static int ParseStringList(unsigned char **sl);
extern int yylineno;
-int ConstrainedMoveTime = 400; /* milliseconds, event times */
-
-int (*twmInputFunc)(void);
+int ConstrainedMoveTime = 400; /* milliseconds, event times */
+int (*twmInputFunc) (void);
/**
* parse the .twmrc file
* \param filename the filename to parse. NULL indicates $HOME/.twmrc
*/
-static int doparse (int (*ifunc)(void),
- const char *srctypename, const char *srcname)
+static int
+doparse(int (*ifunc) (void), const char *srctypename, const char *srcname)
{
mods = 0;
ptr = 0;
@@ -114,50 +113,50 @@ static int doparse (int (*ifunc)(void),
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);
- XRecolorCursor(dpy, MiddleButt,
- &Scr->PointerForeground, &Scr->PointerBackground);
- XRecolorCursor(dpy, Scr->FrameCursor,
- &Scr->PointerForeground, &Scr->PointerBackground);
- XRecolorCursor(dpy, Scr->TitleCursor,
- &Scr->PointerForeground, &Scr->PointerBackground);
- XRecolorCursor(dpy, Scr->IconCursor,
- &Scr->PointerForeground, &Scr->PointerBackground);
- XRecolorCursor(dpy, Scr->IconMgrCursor,
- &Scr->PointerForeground, &Scr->PointerBackground);
- XRecolorCursor(dpy, Scr->MoveCursor,
- &Scr->PointerForeground, &Scr->PointerBackground);
- XRecolorCursor(dpy, Scr->ResizeCursor,
- &Scr->PointerForeground, &Scr->PointerBackground);
- XRecolorCursor(dpy, Scr->MenuCursor,
- &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);
+ 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);
+ XRecolorCursor(dpy, MiddleButt,
+ &Scr->PointerForeground, &Scr->PointerBackground);
+ XRecolorCursor(dpy, Scr->FrameCursor,
+ &Scr->PointerForeground, &Scr->PointerBackground);
+ XRecolorCursor(dpy, Scr->TitleCursor,
+ &Scr->PointerForeground, &Scr->PointerBackground);
+ XRecolorCursor(dpy, Scr->IconCursor,
+ &Scr->PointerForeground, &Scr->PointerBackground);
+ XRecolorCursor(dpy, Scr->IconMgrCursor,
+ &Scr->PointerForeground, &Scr->PointerBackground);
+ XRecolorCursor(dpy, Scr->MoveCursor,
+ &Scr->PointerForeground, &Scr->PointerBackground);
+ XRecolorCursor(dpy, Scr->ResizeCursor,
+ &Scr->PointerForeground, &Scr->PointerBackground);
+ XRecolorCursor(dpy, Scr->MenuCursor,
+ &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");
+ 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 (char *filename)
+int
+ParseTwmrc(char *filename)
{
int i;
char *home = NULL;
@@ -170,122 +169,127 @@ int ParseTwmrc (char *filename)
* 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");
- if (home) {
- homelen = (int)strlen (home);
- cp = tmpfilename;
- (void) snprintf (tmpfilename, sizeof(tmpfilename),
- "%s/.twmrc.%d", home, Scr->screen);
- break;
- }
- }
- continue;
-
- case 2: /* ~/.twmrc */
- if (home) {
- tmpfilename[homelen + 7] = '\0';
- }
- break;
-
- case 3: /* system.twmrc */
- cp = SYSTEM_INIT_FILE;
- break;
- }
-
- if (cp) twmrc = fopen (cp, "r");
+ switch (i) {
+ case 0: /* -f filename */
+ cp = filename;
+ break;
+
+ case 1: /* ~/.twmrc.screennum */
+ if (!filename) {
+ home = getenv("HOME");
+ if (home) {
+ homelen = (int) strlen(home);
+ cp = tmpfilename;
+ (void) snprintf(tmpfilename, sizeof(tmpfilename),
+ "%s/.twmrc.%d", home, Scr->screen);
+ break;
+ }
+ }
+ continue;
+
+ case 2: /* ~/.twmrc */
+ if (home) {
+ tmpfilename[homelen + 7] = '\0';
+ }
+ break;
+
+ case 3: /* system.twmrc */
+ cp = SYSTEM_INIT_FILE;
+ break;
+ }
+
+ if (cp)
+ twmrc = fopen(cp, "r");
}
if (twmrc) {
- 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 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);
}
}
-static int ParseStringList (unsigned char **sl)
+static int
+ParseStringList(unsigned char **sl)
{
stringListSource = sl;
currentString = *sl;
- return doparse (twmStringListInput, "string list", (char *)NULL);
+ return doparse(twmStringListInput, "string list", (char *) NULL);
}
-
/**
* redefinition of the lex input routine for file input
*
* \return the next input character
*/
-static int twmFileInput(void)
+static int
+twmFileInput(void)
{
- if (overflowlen) return (int) overflowbuff[--overflowlen];
+ if (overflowlen)
+ return (int) overflowbuff[--overflowlen];
- while (ptr == len)
- {
- if (fgets((char *) buff, BUF_LEN, twmrc) == NULL)
- return 0;
+ while (ptr == len) {
+ if (fgets((char *) buff, BUF_LEN, twmrc) == NULL)
+ return 0;
- ptr = 0;
- len = (int)strlen((char *) buff);
+ ptr = 0;
+ len = (int) strlen((char *) buff);
}
- return ((int)buff[ptr++]);
+ return ((int) buff[ptr++]);
}
-static int twmStringListInput(void)
+static int
+twmStringListInput(void)
{
- if (overflowlen) return (int) overflowbuff[--overflowlen];
+ if (overflowlen)
+ return (int) overflowbuff[--overflowlen];
/*
* return the character currently pointed to
*/
if (currentString) {
- unsigned int c = (unsigned int) *currentString++;
+ unsigned int c = (unsigned int) *currentString++;
- if (c) return (int)c; /* if non-nul char */
- currentString = *++stringListSource; /* advance to next bol */
- return '\n'; /* but say that we hit last eol */
+ if (c)
+ return (int) c; /* if non-nul char */
+ currentString = *++stringListSource; /* advance to next bol */
+ return '\n'; /* but say that we hit last eol */
}
- return 0; /* eof */
+ return 0; /* eof */
}
-
/*
* redefinition of the lex unput routine
*
* \param c the character to push back onto the input stream
*/
-void twmUnput (int c)
+void
+twmUnput(int c)
{
- if ((size_t)overflowlen < sizeof overflowbuff) {
- overflowbuff[overflowlen++] = (unsigned char) c;
- } else {
- twmrc_error_prefix ();
- fprintf (stderr, "unable to unput character (%d)\n",
- c);
+ if ((size_t) 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
*
@@ -298,7 +302,6 @@ TwmOutput(int c)
putchar(c);
}
-
/**********************************************************************
* Parsing table and routines
***********************************************************************/
@@ -309,633 +312,666 @@ typedef struct _TwmKeyword {
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
-#define kw0_NoRaiseOnDeiconify 13
-#define kw0_DontMoveOff 14
-#define kw0_NoBackingStore 15
-#define kw0_NoSaveUnders 16
-#define kw0_RestartPreviousState 17
-#define kw0_ClientBorderWidth 18
-#define kw0_NoTitleFocus 19
-#define kw0_RandomPlacement 20
-#define kw0_DecorateTransients 21
-#define kw0_ShowIconManager 22
-#define kw0_NoCaseSensitive 23
-#define kw0_NoRaiseOnWarp 24
-#define kw0_WarpUnmapped 25
-
-#define kws_UsePPosition 1
-#define kws_IconFont 2
-#define kws_ResizeFont 3
-#define kws_MenuFont 4
-#define kws_TitleFont 5
-#define kws_IconManagerFont 6
-#define kws_UnknownIcon 7
-#define kws_IconDirectory 8
-#define kws_MaxWindowSize 9
-
-#define kwn_ConstrainedMoveTime 1
-#define kwn_MoveDelta 2
-#define kwn_XorValue 3
-#define kwn_FramePadding 4
-#define kwn_TitlePadding 5
-#define kwn_ButtonIndent 6
-#define kwn_BorderWidth 7
-#define kwn_IconBorderWidth 8
-#define kwn_TitleButtonBorderWidth 9
-#define kwn_Priority 10
-#define kwn_MenuBorderWidth 11
-
-#define kwcl_BorderColor 1
-#define kwcl_IconManagerHighlight 2
-#define kwcl_BorderTileForeground 3
-#define kwcl_BorderTileBackground 4
-#define kwcl_TitleForeground 5
-#define kwcl_TitleBackground 6
-#define kwcl_IconForeground 7
-#define kwcl_IconBackground 8
-#define kwcl_IconBorderColor 9
-#define kwcl_IconManagerForeground 10
-#define kwcl_IconManagerBackground 11
-
-#define kwc_DefaultForeground 1
-#define kwc_DefaultBackground 2
-#define kwc_MenuForeground 3
-#define kwc_MenuBackground 4
-#define kwc_MenuTitleForeground 5
-#define kwc_MenuTitleBackground 6
-#define kwc_MenuShadowColor 7
-#define kwc_PointerForeground 8
-#define kwc_PointerBackground 9
-#define kwc_MenuBorderColor 10
-
+#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
+#define kw0_NoRaiseOnDeiconify 13
+#define kw0_DontMoveOff 14
+#define kw0_NoBackingStore 15
+#define kw0_NoSaveUnders 16
+#define kw0_RestartPreviousState 17
+#define kw0_ClientBorderWidth 18
+#define kw0_NoTitleFocus 19
+#define kw0_RandomPlacement 20
+#define kw0_DecorateTransients 21
+#define kw0_ShowIconManager 22
+#define kw0_NoCaseSensitive 23
+#define kw0_NoRaiseOnWarp 24
+#define kw0_WarpUnmapped 25
+
+#define kws_UsePPosition 1
+#define kws_IconFont 2
+#define kws_ResizeFont 3
+#define kws_MenuFont 4
+#define kws_TitleFont 5
+#define kws_IconManagerFont 6
+#define kws_UnknownIcon 7
+#define kws_IconDirectory 8
+#define kws_MaxWindowSize 9
+
+#define kwn_ConstrainedMoveTime 1
+#define kwn_MoveDelta 2
+#define kwn_XorValue 3
+#define kwn_FramePadding 4
+#define kwn_TitlePadding 5
+#define kwn_ButtonIndent 6
+#define kwn_BorderWidth 7
+#define kwn_IconBorderWidth 8
+#define kwn_TitleButtonBorderWidth 9
+#define kwn_Priority 10
+#define kwn_MenuBorderWidth 11
+
+#define kwcl_BorderColor 1
+#define kwcl_IconManagerHighlight 2
+#define kwcl_BorderTileForeground 3
+#define kwcl_BorderTileBackground 4
+#define kwcl_TitleForeground 5
+#define kwcl_TitleBackground 6
+#define kwcl_IconForeground 7
+#define kwcl_IconBackground 8
+#define kwcl_IconBorderColor 9
+#define kwcl_IconManagerForeground 10
+#define kwcl_IconManagerBackground 11
+
+#define kwc_DefaultForeground 1
+#define kwc_DefaultBackground 2
+#define kwc_MenuForeground 3
+#define kwc_MenuBackground 4
+#define kwc_MenuTitleForeground 5
+#define kwc_MenuTitleBackground 6
+#define kwc_MenuShadowColor 7
+#define kwc_PointerForeground 8
+#define kwc_PointerBackground 9
+#define kwc_MenuBorderColor 10
/*
* The following is sorted alphabetically according to name (which must be
* in lowercase and only contain the letters a-z). It is fed to a binary
* search to parse keywords.
*/
+/* *INDENT-OFF* */
static TwmKeyword keytable[] = {
- { "all", ALL, 0 },
- { "autoraise", AUTO_RAISE, 0 },
- { "autorelativeresize", KEYWORD, kw0_AutoRelativeResize },
- { "bordercolor", CLKEYWORD, kwcl_BorderColor },
- { "bordertilebackground", CLKEYWORD, kwcl_BorderTileBackground },
- { "bordertileforeground", CLKEYWORD, kwcl_BorderTileForeground },
- { "borderwidth", NKEYWORD, kwn_BorderWidth },
- { "button", BUTTON, 0 },
- { "buttonindent", NKEYWORD, kwn_ButtonIndent },
- { "c", CONTROL, 0 },
- { "center", JKEYWORD, J_CENTER },
- { "clientborderwidth", KEYWORD, kw0_ClientBorderWidth },
- { "color", COLOR, 0 },
- { "constrainedmovetime", NKEYWORD, kwn_ConstrainedMoveTime },
- { "control", CONTROL, 0 },
- { "cursors", CURSORS, 0 },
- { "decoratetransients", KEYWORD, kw0_DecorateTransients },
- { "defaultbackground", CKEYWORD, kwc_DefaultBackground },
- { "defaultforeground", CKEYWORD, kwc_DefaultForeground },
- { "defaultfunction", DEFAULT_FUNCTION, 0 },
- { "destroy", KILL, 0 },
- { "donticonifybyunmapping", DONT_ICONIFY_BY_UNMAPPING, 0 },
- { "dontmoveoff", KEYWORD, kw0_DontMoveOff },
- { "dontsqueezetitle", DONT_SQUEEZE_TITLE, 0 },
- { "east", DKEYWORD, D_EAST },
- { "f", FRAME, 0 },
- { "f.autoraise", FKEYWORD, F_AUTORAISE },
- { "f.backiconmgr", FKEYWORD, F_BACKICONMGR },
- { "f.beep", FKEYWORD, F_BEEP },
- { "f.bottomzoom", FKEYWORD, F_BOTTOMZOOM },
- { "f.circledown", FKEYWORD, F_CIRCLEDOWN },
- { "f.circleup", FKEYWORD, F_CIRCLEUP },
- { "f.colormap", FSKEYWORD, F_COLORMAP },
- { "f.cut", FSKEYWORD, F_CUT },
- { "f.cutfile", FKEYWORD, F_CUTFILE },
- { "f.deiconify", FKEYWORD, F_DEICONIFY },
- { "f.delete", FKEYWORD, F_DELETE },
- { "f.deltastop", FKEYWORD, F_DELTASTOP },
- { "f.destroy", FKEYWORD, F_DESTROY },
- { "f.downiconmgr", FKEYWORD, F_DOWNICONMGR },
- { "f.exec", FSKEYWORD, F_EXEC },
- { "f.file", FSKEYWORD, F_FILE },
- { "f.focus", FKEYWORD, F_FOCUS },
- { "f.forcemove", FKEYWORD, F_FORCEMOVE },
- { "f.forwiconmgr", FKEYWORD, F_FORWICONMGR },
- { "f.fullzoom", FKEYWORD, F_FULLZOOM },
- { "f.function", FSKEYWORD, F_FUNCTION },
- { "f.hbzoom", FKEYWORD, F_BOTTOMZOOM },
- { "f.hideiconmgr", FKEYWORD, F_HIDELIST },
- { "f.horizoom", FKEYWORD, F_HORIZOOM },
- { "f.htzoom", FKEYWORD, F_TOPZOOM },
- { "f.hzoom", FKEYWORD, F_HORIZOOM },
- { "f.iconify", FKEYWORD, F_ICONIFY },
- { "f.identify", FKEYWORD, F_IDENTIFY },
- { "f.lefticonmgr", FKEYWORD, F_LEFTICONMGR },
- { "f.leftzoom", FKEYWORD, F_LEFTZOOM },
- { "f.lower", FKEYWORD, F_LOWER },
- { "f.menu", FSKEYWORD, F_MENU },
- { "f.move", FKEYWORD, F_MOVE },
- { "f.nexticonmgr", FKEYWORD, F_NEXTICONMGR },
- { "f.nop", FKEYWORD, F_NOP },
- { "f.previconmgr", FKEYWORD, F_PREVICONMGR },
- { "f.priority", FSKEYWORD, F_PRIORITY },
- { "f.quit", FKEYWORD, F_QUIT },
- { "f.raise", FKEYWORD, F_RAISE },
- { "f.raiselower", FKEYWORD, F_RAISELOWER },
- { "f.refresh", FKEYWORD, F_REFRESH },
- { "f.resize", FKEYWORD, F_RESIZE },
- { "f.restart", FKEYWORD, F_RESTART },
- { "f.righticonmgr", FKEYWORD, F_RIGHTICONMGR },
- { "f.rightzoom", FKEYWORD, F_RIGHTZOOM },
- { "f.saveyourself", FKEYWORD, F_SAVEYOURSELF },
- { "f.showiconmgr", FKEYWORD, F_SHOWLIST },
- { "f.sorticonmgr", FKEYWORD, F_SORTICONMGR },
- { "f.source", FSKEYWORD, F_BEEP }, /* XXX - don't work */
- { "f.startwm", FSKEYWORD, F_STARTWM },
- { "f.title", FKEYWORD, F_TITLE },
- { "f.topzoom", FKEYWORD, F_TOPZOOM },
- { "f.twmrc", FKEYWORD, F_RESTART },
- { "f.unfocus", FKEYWORD, F_UNFOCUS },
- { "f.upiconmgr", FKEYWORD, F_UPICONMGR },
- { "f.version", FKEYWORD, F_VERSION },
- { "f.vlzoom", FKEYWORD, F_LEFTZOOM },
- { "f.vrzoom", FKEYWORD, F_RIGHTZOOM },
- { "f.warpnext", FKEYWORD, F_WARPNEXT },
- { "f.warpprev", FKEYWORD, F_WARPPREV },
- { "f.warpring", FSKEYWORD, F_WARPRING },
- { "f.warpto", FSKEYWORD, F_WARPTO },
- { "f.warptoiconmgr", FSKEYWORD, F_WARPTOICONMGR },
- { "f.warptoscreen", FSKEYWORD, F_WARPTOSCREEN },
- { "f.winrefresh", FKEYWORD, F_WINREFRESH },
- { "f.zoom", FKEYWORD, F_ZOOM },
- { "forceicons", KEYWORD, kw0_ForceIcons },
- { "frame", FRAME, 0 },
- { "framepadding", NKEYWORD, kwn_FramePadding },
- { "function", FUNCTION, 0 },
- { "grayscale", GRAYSCALE, 0 },
- { "greyscale", GRAYSCALE, 0 },
- { "i", ICON, 0 },
- { "icon", ICON, 0 },
- { "iconbackground", CLKEYWORD, kwcl_IconBackground },
- { "iconbordercolor", CLKEYWORD, kwcl_IconBorderColor },
- { "iconborderwidth", NKEYWORD, kwn_IconBorderWidth },
- { "icondirectory", SKEYWORD, kws_IconDirectory },
- { "iconfont", SKEYWORD, kws_IconFont },
- { "iconforeground", CLKEYWORD, kwcl_IconForeground },
- { "iconifybyunmapping", ICONIFY_BY_UNMAPPING, 0 },
- { "iconmanagerbackground", CLKEYWORD, kwcl_IconManagerBackground },
- { "iconmanagerdontshow", ICONMGR_NOSHOW, 0 },
- { "iconmanagerfont", SKEYWORD, kws_IconManagerFont },
- { "iconmanagerforeground", CLKEYWORD, kwcl_IconManagerForeground },
- { "iconmanagergeometry", ICONMGR_GEOMETRY, 0 },
- { "iconmanagerhighlight", CLKEYWORD, kwcl_IconManagerHighlight },
- { "iconmanagers", ICONMGRS, 0 },
- { "iconmanagershow", ICONMGR_SHOW, 0 },
- { "iconmgr", ICONMGR, 0 },
- { "iconregion", ICON_REGION, 0 },
- { "icons", ICONS, 0 },
- { "interpolatemenucolors", KEYWORD, kw0_InterpolateMenuColors },
- { "l", LOCK, 0 },
- { "left", JKEYWORD, J_LEFT },
- { "lefttitlebutton", LEFT_TITLEBUTTON, 0 },
- { "lock", LOCK, 0 },
- { "m", META, 0 },
- { "maketitle", MAKE_TITLE, 0 },
- { "maxwindowsize", SKEYWORD, kws_MaxWindowSize },
- { "menu", MENU, 0 },
- { "menubackground", CKEYWORD, kwc_MenuBackground },
- { "menubordercolor", CKEYWORD, kwc_MenuBorderColor },
- { "menuborderwidth", NKEYWORD, kwn_MenuBorderWidth },
- { "menufont", SKEYWORD, kws_MenuFont },
- { "menuforeground", CKEYWORD, kwc_MenuForeground },
- { "menushadowcolor", CKEYWORD, kwc_MenuShadowColor },
- { "menutitlebackground", CKEYWORD, kwc_MenuTitleBackground },
- { "menutitleforeground", CKEYWORD, kwc_MenuTitleForeground },
- { "meta", META, 0 },
- { "mod", META, 0 }, /* fake it */
- { "monochrome", MONOCHROME, 0 },
- { "move", MOVE, 0 },
- { "movedelta", NKEYWORD, kwn_MoveDelta },
- { "nobackingstore", KEYWORD, kw0_NoBackingStore },
- { "nocasesensitive", KEYWORD, kw0_NoCaseSensitive },
- { "nodefaults", KEYWORD, kw0_NoDefaults },
- { "nograbserver", KEYWORD, kw0_NoGrabServer },
- { "nohighlight", NO_HILITE, 0 },
- { "noiconmanagers", KEYWORD, kw0_NoIconManagers },
- { "nomenushadows", KEYWORD, kw0_NoMenuShadows },
- { "noraiseondeiconify", KEYWORD, kw0_NoRaiseOnDeiconify },
- { "noraiseonmove", KEYWORD, kw0_NoRaiseOnMove },
- { "noraiseonresize", KEYWORD, kw0_NoRaiseOnResize },
- { "noraiseonwarp", KEYWORD, kw0_NoRaiseOnWarp },
- { "north", DKEYWORD, D_NORTH },
- { "nosaveunders", KEYWORD, kw0_NoSaveUnders },
- { "nostackmode", NO_STACKMODE, 0 },
- { "notitle", NO_TITLE, 0 },
- { "notitlefocus", KEYWORD, kw0_NoTitleFocus },
- { "notitlehighlight", NO_TITLE_HILITE, 0 },
- { "noversion", KEYWORD, kw0_NoVersion },
- { "opaquemove", KEYWORD, kw0_OpaqueMove },
- { "pixmaps", PIXMAPS, 0 },
- { "pointerbackground", CKEYWORD, kwc_PointerBackground },
- { "pointerforeground", CKEYWORD, kwc_PointerForeground },
- { "priority", NKEYWORD, kwn_Priority },
- { "r", ROOT, 0 },
- { "randomplacement", KEYWORD, kw0_RandomPlacement },
- { "resize", RESIZE, 0 },
- { "resizefont", SKEYWORD, kws_ResizeFont },
- { "restartpreviousstate", KEYWORD, kw0_RestartPreviousState },
- { "right", JKEYWORD, J_RIGHT },
- { "righttitlebutton", RIGHT_TITLEBUTTON, 0 },
- { "root", ROOT, 0 },
- { "s", SHIFT, 0 },
+ { "all", ALL, 0 },
+ { "autoraise", AUTO_RAISE, 0 },
+ { "autorelativeresize", KEYWORD, kw0_AutoRelativeResize },
+ { "bordercolor", CLKEYWORD, kwcl_BorderColor },
+ { "bordertilebackground", CLKEYWORD, kwcl_BorderTileBackground },
+ { "bordertileforeground", CLKEYWORD, kwcl_BorderTileForeground },
+ { "borderwidth", NKEYWORD, kwn_BorderWidth },
+ { "button", BUTTON, 0 },
+ { "buttonindent", NKEYWORD, kwn_ButtonIndent },
+ { "c", CONTROL, 0 },
+ { "center", JKEYWORD, J_CENTER },
+ { "clientborderwidth", KEYWORD, kw0_ClientBorderWidth },
+ { "color", COLOR, 0 },
+ { "constrainedmovetime", NKEYWORD, kwn_ConstrainedMoveTime },
+ { "control", CONTROL, 0 },
+ { "cursors", CURSORS, 0 },
+ { "decoratetransients", KEYWORD, kw0_DecorateTransients },
+ { "defaultbackground", CKEYWORD, kwc_DefaultBackground },
+ { "defaultforeground", CKEYWORD, kwc_DefaultForeground },
+ { "defaultfunction", DEFAULT_FUNCTION, 0 },
+ { "destroy", KILL, 0 },
+ { "donticonifybyunmapping", DONT_ICONIFY_BY_UNMAPPING, 0 },
+ { "dontmoveoff", KEYWORD, kw0_DontMoveOff },
+ { "dontsqueezetitle", DONT_SQUEEZE_TITLE, 0 },
+ { "east", DKEYWORD, D_EAST },
+ { "f", FRAME, 0 },
+ { "f.autoraise", FKEYWORD, F_AUTORAISE },
+ { "f.backiconmgr", FKEYWORD, F_BACKICONMGR },
+ { "f.beep", FKEYWORD, F_BEEP },
+ { "f.bottomzoom", FKEYWORD, F_BOTTOMZOOM },
+ { "f.circledown", FKEYWORD, F_CIRCLEDOWN },
+ { "f.circleup", FKEYWORD, F_CIRCLEUP },
+ { "f.colormap", FSKEYWORD, F_COLORMAP },
+ { "f.cut", FSKEYWORD, F_CUT },
+ { "f.cutfile", FKEYWORD, F_CUTFILE },
+ { "f.deiconify", FKEYWORD, F_DEICONIFY },
+ { "f.delete", FKEYWORD, F_DELETE },
+ { "f.deltastop", FKEYWORD, F_DELTASTOP },
+ { "f.destroy", FKEYWORD, F_DESTROY },
+ { "f.downiconmgr", FKEYWORD, F_DOWNICONMGR },
+ { "f.exec", FSKEYWORD, F_EXEC },
+ { "f.file", FSKEYWORD, F_FILE },
+ { "f.focus", FKEYWORD, F_FOCUS },
+ { "f.forcemove", FKEYWORD, F_FORCEMOVE },
+ { "f.forwiconmgr", FKEYWORD, F_FORWICONMGR },
+ { "f.fullzoom", FKEYWORD, F_FULLZOOM },
+ { "f.function", FSKEYWORD, F_FUNCTION },
+ { "f.hbzoom", FKEYWORD, F_BOTTOMZOOM },
+ { "f.hideiconmgr", FKEYWORD, F_HIDELIST },
+ { "f.horizoom", FKEYWORD, F_HORIZOOM },
+ { "f.htzoom", FKEYWORD, F_TOPZOOM },
+ { "f.hzoom", FKEYWORD, F_HORIZOOM },
+ { "f.iconify", FKEYWORD, F_ICONIFY },
+ { "f.identify", FKEYWORD, F_IDENTIFY },
+ { "f.lefticonmgr", FKEYWORD, F_LEFTICONMGR },
+ { "f.leftzoom", FKEYWORD, F_LEFTZOOM },
+ { "f.lower", FKEYWORD, F_LOWER },
+ { "f.menu", FSKEYWORD, F_MENU },
+ { "f.move", FKEYWORD, F_MOVE },
+ { "f.nexticonmgr", FKEYWORD, F_NEXTICONMGR },
+ { "f.nop", FKEYWORD, F_NOP },
+ { "f.previconmgr", FKEYWORD, F_PREVICONMGR },
+ { "f.priority", FSKEYWORD, F_PRIORITY },
+ { "f.quit", FKEYWORD, F_QUIT },
+ { "f.raise", FKEYWORD, F_RAISE },
+ { "f.raiselower", FKEYWORD, F_RAISELOWER },
+ { "f.refresh", FKEYWORD, F_REFRESH },
+ { "f.resize", FKEYWORD, F_RESIZE },
+ { "f.restart", FKEYWORD, F_RESTART },
+ { "f.righticonmgr", FKEYWORD, F_RIGHTICONMGR },
+ { "f.rightzoom", FKEYWORD, F_RIGHTZOOM },
+ { "f.saveyourself", FKEYWORD, F_SAVEYOURSELF },
+ { "f.showiconmgr", FKEYWORD, F_SHOWLIST },
+ { "f.sorticonmgr", FKEYWORD, F_SORTICONMGR },
+ { "f.source", FSKEYWORD, F_BEEP }, /* XXX - don't work */
+ { "f.startwm", FSKEYWORD, F_STARTWM },
+ { "f.title", FKEYWORD, F_TITLE },
+ { "f.topzoom", FKEYWORD, F_TOPZOOM },
+ { "f.twmrc", FKEYWORD, F_RESTART },
+ { "f.unfocus", FKEYWORD, F_UNFOCUS },
+ { "f.upiconmgr", FKEYWORD, F_UPICONMGR },
+ { "f.version", FKEYWORD, F_VERSION },
+ { "f.vlzoom", FKEYWORD, F_LEFTZOOM },
+ { "f.vrzoom", FKEYWORD, F_RIGHTZOOM },
+ { "f.warpnext", FKEYWORD, F_WARPNEXT },
+ { "f.warpprev", FKEYWORD, F_WARPPREV },
+ { "f.warpring", FSKEYWORD, F_WARPRING },
+ { "f.warpto", FSKEYWORD, F_WARPTO },
+ { "f.warptoiconmgr", FSKEYWORD, F_WARPTOICONMGR },
+ { "f.warptoscreen", FSKEYWORD, F_WARPTOSCREEN },
+ { "f.winrefresh", FKEYWORD, F_WINREFRESH },
+ { "f.zoom", FKEYWORD, F_ZOOM },
+ { "forceicons", KEYWORD, kw0_ForceIcons },
+ { "frame", FRAME, 0 },
+ { "framepadding", NKEYWORD, kwn_FramePadding },
+ { "function", FUNCTION, 0 },
+ { "grayscale", GRAYSCALE, 0 },
+ { "greyscale", GRAYSCALE, 0 },
+ { "i", ICON, 0 },
+ { "icon", ICON, 0 },
+ { "iconbackground", CLKEYWORD, kwcl_IconBackground },
+ { "iconbordercolor", CLKEYWORD, kwcl_IconBorderColor },
+ { "iconborderwidth", NKEYWORD, kwn_IconBorderWidth },
+ { "icondirectory", SKEYWORD, kws_IconDirectory },
+ { "iconfont", SKEYWORD, kws_IconFont },
+ { "iconforeground", CLKEYWORD, kwcl_IconForeground },
+ { "iconifybyunmapping", ICONIFY_BY_UNMAPPING, 0 },
+ { "iconmanagerbackground", CLKEYWORD, kwcl_IconManagerBackground },
+ { "iconmanagerdontshow", ICONMGR_NOSHOW, 0 },
+ { "iconmanagerfont", SKEYWORD, kws_IconManagerFont },
+ { "iconmanagerforeground", CLKEYWORD, kwcl_IconManagerForeground },
+ { "iconmanagergeometry", ICONMGR_GEOMETRY, 0 },
+ { "iconmanagerhighlight", CLKEYWORD, kwcl_IconManagerHighlight },
+ { "iconmanagers", ICONMGRS, 0 },
+ { "iconmanagershow", ICONMGR_SHOW, 0 },
+ { "iconmgr", ICONMGR, 0 },
+ { "iconregion", ICON_REGION, 0 },
+ { "icons", ICONS, 0 },
+ { "interpolatemenucolors", KEYWORD, kw0_InterpolateMenuColors },
+ { "l", LOCK, 0 },
+ { "left", JKEYWORD, J_LEFT },
+ { "lefttitlebutton", LEFT_TITLEBUTTON, 0 },
+ { "lock", LOCK, 0 },
+ { "m", META, 0 },
+ { "maketitle", MAKE_TITLE, 0 },
+ { "maxwindowsize", SKEYWORD, kws_MaxWindowSize },
+ { "menu", MENU, 0 },
+ { "menubackground", CKEYWORD, kwc_MenuBackground },
+ { "menubordercolor", CKEYWORD, kwc_MenuBorderColor },
+ { "menuborderwidth", NKEYWORD, kwn_MenuBorderWidth },
+ { "menufont", SKEYWORD, kws_MenuFont },
+ { "menuforeground", CKEYWORD, kwc_MenuForeground },
+ { "menushadowcolor", CKEYWORD, kwc_MenuShadowColor },
+ { "menutitlebackground", CKEYWORD, kwc_MenuTitleBackground },
+ { "menutitleforeground", CKEYWORD, kwc_MenuTitleForeground },
+ { "meta", META, 0 },
+ { "mod", META, 0 }, /* fake it */
+ { "monochrome", MONOCHROME, 0 },
+ { "move", MOVE, 0 },
+ { "movedelta", NKEYWORD, kwn_MoveDelta },
+ { "nobackingstore", KEYWORD, kw0_NoBackingStore },
+ { "nocasesensitive", KEYWORD, kw0_NoCaseSensitive },
+ { "nodefaults", KEYWORD, kw0_NoDefaults },
+ { "nograbserver", KEYWORD, kw0_NoGrabServer },
+ { "nohighlight", NO_HILITE, 0 },
+ { "noiconmanagers", KEYWORD, kw0_NoIconManagers },
+ { "nomenushadows", KEYWORD, kw0_NoMenuShadows },
+ { "noraiseondeiconify", KEYWORD, kw0_NoRaiseOnDeiconify },
+ { "noraiseonmove", KEYWORD, kw0_NoRaiseOnMove },
+ { "noraiseonresize", KEYWORD, kw0_NoRaiseOnResize },
+ { "noraiseonwarp", KEYWORD, kw0_NoRaiseOnWarp },
+ { "north", DKEYWORD, D_NORTH },
+ { "nosaveunders", KEYWORD, kw0_NoSaveUnders },
+ { "nostackmode", NO_STACKMODE, 0 },
+ { "notitle", NO_TITLE, 0 },
+ { "notitlefocus", KEYWORD, kw0_NoTitleFocus },
+ { "notitlehighlight", NO_TITLE_HILITE, 0 },
+ { "noversion", KEYWORD, kw0_NoVersion },
+ { "opaquemove", KEYWORD, kw0_OpaqueMove },
+ { "pixmaps", PIXMAPS, 0 },
+ { "pointerbackground", CKEYWORD, kwc_PointerBackground },
+ { "pointerforeground", CKEYWORD, kwc_PointerForeground },
+ { "priority", NKEYWORD, kwn_Priority },
+ { "r", ROOT, 0 },
+ { "randomplacement", KEYWORD, kw0_RandomPlacement },
+ { "resize", RESIZE, 0 },
+ { "resizefont", SKEYWORD, kws_ResizeFont },
+ { "restartpreviousstate", KEYWORD, kw0_RestartPreviousState },
+ { "right", JKEYWORD, J_RIGHT },
+ { "righttitlebutton", RIGHT_TITLEBUTTON, 0 },
+ { "root", ROOT, 0 },
+ { "s", SHIFT, 0 },
{ "savecolor", SAVECOLOR, 0},
- { "select", SELECT, 0 },
- { "shift", SHIFT, 0 },
- { "showiconmanager", KEYWORD, kw0_ShowIconManager },
- { "sorticonmanager", KEYWORD, kw0_SortIconManager },
- { "south", DKEYWORD, D_SOUTH },
- { "squeezetitle", SQUEEZE_TITLE, 0 },
- { "starticonified", START_ICONIFIED, 0 },
- { "t", TITLE, 0 },
- { "title", TITLE, 0 },
- { "titlebackground", CLKEYWORD, kwcl_TitleBackground },
- { "titlebuttonborderwidth", NKEYWORD, kwn_TitleButtonBorderWidth },
- { "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 },
+ { "select", SELECT, 0 },
+ { "shift", SHIFT, 0 },
+ { "showiconmanager", KEYWORD, kw0_ShowIconManager },
+ { "sorticonmanager", KEYWORD, kw0_SortIconManager },
+ { "south", DKEYWORD, D_SOUTH },
+ { "squeezetitle", SQUEEZE_TITLE, 0 },
+ { "starticonified", START_ICONIFIED, 0 },
+ { "t", TITLE, 0 },
+ { "title", TITLE, 0 },
+ { "titlebackground", CLKEYWORD, kwcl_TitleBackground },
+ { "titlebuttonborderwidth", NKEYWORD, kwn_TitleButtonBorderWidth },
+ { "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 },
};
+/* *INDENT-ON* */
-static int numkeywords = (sizeof(keytable)/sizeof(keytable[0]));
+static int numkeywords = (sizeof(keytable) / sizeof(keytable[0]));
-int parse_keyword (char *s, int *nump)
+int
+parse_keyword(char *s, int *nump)
{
register int lower = 0, upper = numkeywords - 1;
- XmuCopyISOLatin1Lowered (s, s);
+ XmuCopyISOLatin1Lowered(s, s);
while (lower <= upper) {
int middle = (lower + upper) / 2;
- TwmKeyword *p = &keytable[middle];
- int res = strcmp (p->name, s);
+ TwmKeyword *p = &keytable[middle];
+ int res = strcmp(p->name, s);
if (res < 0) {
lower = middle + 1;
- } else if (res == 0) {
- *nump = p->subnum;
+ }
+ else if (res == 0) {
+ *nump = p->subnum;
return p->value;
- } else {
+ }
+ else {
upper = middle - 1;
}
}
return ERRORTOKEN;
}
-
-
/*
* action routines called by grammar
*/
-int do_single_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;
- return 1;
-
- case kw0_InterpolateMenuColors:
- if (Scr->FirstTime) Scr->InterpolateMenuColors = TRUE;
- return 1;
-
- case kw0_NoVersion:
- /* obsolete */
- return 1;
-
- case kw0_SortIconManager:
- if (Scr->FirstTime) Scr->SortIconMgr = TRUE;
- return 1;
-
- case kw0_NoGrabServer:
- Scr->NoGrabServer = TRUE;
- return 1;
-
- case kw0_NoMenuShadows:
- if (Scr->FirstTime) Scr->Shadow = FALSE;
- return 1;
-
- case kw0_NoRaiseOnMove:
- if (Scr->FirstTime) Scr->NoRaiseMove = TRUE;
- return 1;
-
- case kw0_NoRaiseOnResize:
- if (Scr->FirstTime) Scr->NoRaiseResize = TRUE;
- return 1;
-
- case kw0_NoRaiseOnDeiconify:
- if (Scr->FirstTime) Scr->NoRaiseDeicon = TRUE;
- return 1;
-
- case kw0_DontMoveOff:
- Scr->DontMoveOff = TRUE;
- return 1;
-
- case kw0_NoBackingStore:
- Scr->BackingStore = FALSE;
- return 1;
-
- case kw0_NoSaveUnders:
- Scr->SaveUnder = FALSE;
- return 1;
-
- case kw0_RestartPreviousState:
- RestartPreviousState = True;
- return 1;
-
- case kw0_ClientBorderWidth:
- if (Scr->FirstTime) Scr->ClientBorderWidth = TRUE;
- return 1;
-
- case kw0_NoTitleFocus:
- Scr->TitleFocus = FALSE;
- return 1;
-
- case kw0_RandomPlacement:
- Scr->RandomPlacement = TRUE;
- return 1;
-
- case kw0_DecorateTransients:
- Scr->DecorateTransients = TRUE;
- return 1;
-
- case kw0_ShowIconManager:
- 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;
+ 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;
+ return 1;
+
+ case kw0_InterpolateMenuColors:
+ if (Scr->FirstTime)
+ Scr->InterpolateMenuColors = TRUE;
+ return 1;
+
+ case kw0_NoVersion:
+ /* obsolete */
+ return 1;
+
+ case kw0_SortIconManager:
+ if (Scr->FirstTime)
+ Scr->SortIconMgr = TRUE;
+ return 1;
+
+ case kw0_NoGrabServer:
+ Scr->NoGrabServer = TRUE;
+ return 1;
+
+ case kw0_NoMenuShadows:
+ if (Scr->FirstTime)
+ Scr->Shadow = FALSE;
+ return 1;
+
+ case kw0_NoRaiseOnMove:
+ if (Scr->FirstTime)
+ Scr->NoRaiseMove = TRUE;
+ return 1;
+
+ case kw0_NoRaiseOnResize:
+ if (Scr->FirstTime)
+ Scr->NoRaiseResize = TRUE;
+ return 1;
+
+ case kw0_NoRaiseOnDeiconify:
+ if (Scr->FirstTime)
+ Scr->NoRaiseDeicon = TRUE;
+ return 1;
+
+ case kw0_DontMoveOff:
+ Scr->DontMoveOff = TRUE;
+ return 1;
+
+ case kw0_NoBackingStore:
+ Scr->BackingStore = FALSE;
+ return 1;
+
+ case kw0_NoSaveUnders:
+ Scr->SaveUnder = FALSE;
+ return 1;
+
+ case kw0_RestartPreviousState:
+ RestartPreviousState = True;
+ return 1;
+
+ case kw0_ClientBorderWidth:
+ if (Scr->FirstTime)
+ Scr->ClientBorderWidth = TRUE;
+ return 1;
+
+ case kw0_NoTitleFocus:
+ Scr->TitleFocus = FALSE;
+ return 1;
+
+ case kw0_RandomPlacement:
+ Scr->RandomPlacement = TRUE;
+ return 1;
+
+ case kw0_DecorateTransients:
+ Scr->DecorateTransients = TRUE;
+ return 1;
+
+ case kw0_ShowIconManager:
+ 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 (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 = (short)ppos;
- }
- return 1;
- }
-
- case kws_IconFont:
- if (!Scr->HaveFonts) Scr->IconFont.name = s;
- return 1;
-
- case kws_ResizeFont:
- if (!Scr->HaveFonts) Scr->SizeFont.name = s;
- return 1;
-
- case kws_MenuFont:
- if (!Scr->HaveFonts) Scr->MenuFont.name = s;
- return 1;
-
- case kws_TitleFont:
- if (!Scr->HaveFonts) Scr->TitleBarFont.name = s;
- return 1;
-
- case kws_IconManagerFont:
- if (!Scr->HaveFonts) Scr->IconManagerFont.name = s;
- return 1;
-
- case kws_UnknownIcon:
- if (Scr->FirstTime) GetUnknownIcon (s);
- return 1;
-
- case kws_IconDirectory:
- if (Scr->FirstTime) Scr->IconDirectory = ExpandFilename (s);
- return 1;
-
- case kws_MaxWindowSize:
- JunkMask = (unsigned)XParseGeometry (s, &JunkX, &JunkY, &JunkWidth, &JunkHeight);
- 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 = (int)JunkWidth;
- Scr->MaxWindowHeight = (int)JunkHeight;
- return 1;
+ 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 = (short) ppos;
+ }
+ return 1;
+ }
+
+ case kws_IconFont:
+ if (!Scr->HaveFonts)
+ Scr->IconFont.name = s;
+ return 1;
+
+ case kws_ResizeFont:
+ if (!Scr->HaveFonts)
+ Scr->SizeFont.name = s;
+ return 1;
+
+ case kws_MenuFont:
+ if (!Scr->HaveFonts)
+ Scr->MenuFont.name = s;
+ return 1;
+
+ case kws_TitleFont:
+ if (!Scr->HaveFonts)
+ Scr->TitleBarFont.name = s;
+ return 1;
+
+ case kws_IconManagerFont:
+ if (!Scr->HaveFonts)
+ Scr->IconManagerFont.name = s;
+ return 1;
+
+ case kws_UnknownIcon:
+ if (Scr->FirstTime)
+ GetUnknownIcon(s);
+ return 1;
+
+ case kws_IconDirectory:
+ if (Scr->FirstTime)
+ Scr->IconDirectory = ExpandFilename(s);
+ return 1;
+
+ case kws_MaxWindowSize:
+ JunkMask =
+ (unsigned) XParseGeometry(s, &JunkX, &JunkY, &JunkWidth,
+ &JunkHeight);
+ 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 = (int) JunkWidth;
+ Scr->MaxWindowHeight = (int) JunkHeight;
+ return 1;
}
return 0;
}
-
-int do_number_keyword (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 = (short)num;
- return 1;
-
- case kwn_XorValue:
- if (Scr->FirstTime) Scr->XORvalue = (unsigned long)num;
- return 1;
-
- case kwn_FramePadding:
- if (Scr->FirstTime) Scr->FramePadding = num;
- return 1;
-
- case kwn_TitlePadding:
- if (Scr->FirstTime) Scr->TitlePadding = num;
- return 1;
-
- case kwn_ButtonIndent:
- if (Scr->FirstTime) Scr->ButtonIndent = num;
- return 1;
-
- case kwn_BorderWidth:
- if (Scr->FirstTime) Scr->BorderWidth = num;
- return 1;
-
- 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;
+ case kwn_ConstrainedMoveTime:
+ ConstrainedMoveTime = num;
+ return 1;
+
+ case kwn_MoveDelta:
+ Scr->MoveDelta = (short) num;
+ return 1;
+
+ case kwn_XorValue:
+ if (Scr->FirstTime)
+ Scr->XORvalue = (unsigned long) num;
+ return 1;
+
+ case kwn_FramePadding:
+ if (Scr->FirstTime)
+ Scr->FramePadding = num;
+ return 1;
+
+ case kwn_TitlePadding:
+ if (Scr->FirstTime)
+ Scr->TitlePadding = num;
+ return 1;
+
+ case kwn_ButtonIndent:
+ if (Scr->FirstTime)
+ Scr->ButtonIndent = num;
+ return 1;
+
+ case kwn_BorderWidth:
+ if (Scr->FirstTime)
+ Scr->BorderWidth = num;
+ return 1;
+
+ 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 (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_BorderColor:
+ GetColor(colormode, &Scr->BorderColor, s);
+ return &Scr->BorderColorL;
- case kwcl_IconManagerHighlight:
- GetColor (colormode, &Scr->IconManagerHighlight, s);
- return &Scr->IconManagerHighlightL;
+ 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_BorderTileForeground:
+ GetColor(colormode, &Scr->BorderTileC.fore, s);
+ return &Scr->BorderTileForegroundL;
- case kwcl_BorderTileBackground:
- GetColor (colormode, &Scr->BorderTileC.back, s);
- return &Scr->BorderTileBackgroundL;
+ case kwcl_BorderTileBackground:
+ GetColor(colormode, &Scr->BorderTileC.back, s);
+ return &Scr->BorderTileBackgroundL;
- case kwcl_TitleForeground:
- GetColor (colormode, &Scr->TitleC.fore, s);
- return &Scr->TitleForegroundL;
+ case kwcl_TitleForeground:
+ GetColor(colormode, &Scr->TitleC.fore, s);
+ return &Scr->TitleForegroundL;
- case kwcl_TitleBackground:
- GetColor (colormode, &Scr->TitleC.back, s);
- return &Scr->TitleBackgroundL;
+ case kwcl_TitleBackground:
+ GetColor(colormode, &Scr->TitleC.back, s);
+ return &Scr->TitleBackgroundL;
- case kwcl_IconForeground:
- GetColor (colormode, &Scr->IconC.fore, s);
- return &Scr->IconForegroundL;
+ case kwcl_IconForeground:
+ GetColor(colormode, &Scr->IconC.fore, s);
+ return &Scr->IconForegroundL;
- case kwcl_IconBackground:
- GetColor (colormode, &Scr->IconC.back, s);
- return &Scr->IconBackgroundL;
+ 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_IconBorderColor:
+ GetColor(colormode, &Scr->IconBorderColor, s);
+ return &Scr->IconBorderColorL;
- case kwcl_IconManagerForeground:
- GetColor (colormode, &Scr->IconManagerC.fore, s);
- return &Scr->IconManagerFL;
+ case kwcl_IconManagerForeground:
+ GetColor(colormode, &Scr->IconManagerC.fore, s);
+ return &Scr->IconManagerFL;
- case kwcl_IconManagerBackground:
- GetColor (colormode, &Scr->IconManagerC.back, s);
- return &Scr->IconManagerBL;
+ case kwcl_IconManagerBackground:
+ GetColor(colormode, &Scr->IconManagerC.back, s);
+ return &Scr->IconManagerBL;
}
return NULL;
}
-int do_color_keyword (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_DefaultForeground:
+ GetColor(colormode, &Scr->DefaultC.fore, s);
+ return 1;
- case kwc_DefaultBackground:
- GetColor (colormode, &Scr->DefaultC.back, 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_MenuForeground:
+ GetColor(colormode, &Scr->MenuC.fore, s);
+ return 1;
- case kwc_MenuBackground:
- GetColor (colormode, &Scr->MenuC.back, s);
- return 1;
+ case kwc_MenuBackground:
+ GetColor(colormode, &Scr->MenuC.back, s);
+ return 1;
- case kwc_MenuBorderColor:
- GetColor (colormode, &Scr->MenuBorderColor, s);
- return 1;
+ case kwc_MenuBorderColor:
+ GetColor(colormode, &Scr->MenuBorderColor, s);
+ return 1;
- case kwc_MenuTitleForeground:
- GetColor (colormode, &Scr->MenuTitleC.fore, s);
- return 1;
+ case kwc_MenuTitleForeground:
+ GetColor(colormode, &Scr->MenuTitleC.fore, s);
+ return 1;
- case kwc_MenuTitleBackground:
- GetColor (colormode, &Scr->MenuTitleC.back, s);
- return 1;
+ case kwc_MenuTitleBackground:
+ GetColor(colormode, &Scr->MenuTitleC.back, s);
+ return 1;
- case kwc_MenuShadowColor:
- GetColor (colormode, &Scr->MenuShadowColor, 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_PointerForeground:
+ GetColorValue(colormode, &Scr->PointerForeground, s);
+ return 1;
- case kwc_PointerBackground:
- GetColorValue (colormode, &Scr->PointerBackground, s);
- return 1;
+ case kwc_PointerBackground:
+ GetColorValue(colormode, &Scr->PointerBackground, s);
+ return 1;
}
return 0;
@@ -947,26 +983,27 @@ int do_color_keyword (int keyword, int colormode, char *s)
static void
put_pixel_on_root(Pixel pixel)
{
- int i, addPixel = 1;
- Atom pixelAtom, retAtom;
- int retFormat;
- unsigned long nPixels, retAfter;
- unsigned char*retProp;
- Pixel *pixelProp;
- pixelAtom = XInternAtom(dpy, "_MIT_PRIORITY_COLORS", True);
- if (XGetWindowProperty(dpy, Scr->Root, pixelAtom, 0, 8192,
- False, XA_CARDINAL, &retAtom,
- &retFormat, &nPixels, &retAfter,
- &retProp) == Success) {
- pixelProp = (Pixel *) retProp;
- for (i = 0; (unsigned long)i < nPixels; i++)
- if (pixel == pixelProp[i])
- addPixel = 0;
- }
- if (addPixel)
- XChangeProperty (dpy, Scr->Root, _XA_MIT_PRIORITY_COLORS,
- XA_CARDINAL, 32, PropModeAppend,
- (unsigned char *)&pixel, 1);
+ int i, addPixel = 1;
+ Atom pixelAtom, retAtom;
+ int retFormat;
+ unsigned long nPixels, retAfter;
+ unsigned char *retProp;
+ Pixel *pixelProp;
+
+ pixelAtom = XInternAtom(dpy, "_MIT_PRIORITY_COLORS", True);
+ if (XGetWindowProperty(dpy, Scr->Root, pixelAtom, 0, 8192,
+ False, XA_CARDINAL, &retAtom,
+ &retFormat, &nPixels, &retAfter,
+ &retProp) == Success) {
+ pixelProp = (Pixel *) retProp;
+ for (i = 0; (unsigned long) i < nPixels; i++)
+ if (pixel == pixelProp[i])
+ addPixel = 0;
+ }
+ if (addPixel)
+ XChangeProperty(dpy, Scr->Root, _XA_MIT_PRIORITY_COLORS,
+ XA_CARDINAL, 32, PropModeAppend,
+ (unsigned char *) &pixel, 1);
}
/**
@@ -975,12 +1012,16 @@ put_pixel_on_root(Pixel pixel)
void
do_string_savecolor(int colormode, char *s)
{
- Pixel p;
- GetColor(colormode, &p, s);
- put_pixel_on_root(p);
+ Pixel p;
+
+ GetColor(colormode, &p, s);
+ put_pixel_on_root(p);
}
-typedef struct _cnode {int i; struct _cnode *next;} Cnode, *Cptr;
+typedef struct _cnode {
+ int i;
+ struct _cnode *next;
+} Cnode, *Cptr;
static Cptr chead = NULL;
/**
@@ -989,17 +1030,23 @@ static Cptr chead = NULL;
void
do_var_savecolor(int key)
{
- Cptr cptrav, cpnew;
- if (!chead) {
- chead = malloc(sizeof(Cnode));
- chead->i = key; chead->next = NULL;
- }
- else {
- cptrav = chead;
- while (cptrav->next != NULL) { cptrav = cptrav->next; }
- cpnew = malloc(sizeof(Cnode));
- cpnew->i = key; cpnew->next = NULL; cptrav->next = cpnew;
- }
+ Cptr cptrav, cpnew;
+
+ if (!chead) {
+ chead = malloc(sizeof(Cnode));
+ chead->i = key;
+ chead->next = NULL;
+ }
+ else {
+ cptrav = chead;
+ while (cptrav->next != NULL) {
+ cptrav = cptrav->next;
+ }
+ cpnew = malloc(sizeof(Cnode));
+ cpnew->i = key;
+ cpnew->next = NULL;
+ cptrav->next = cpnew;
+ }
}
/**
@@ -1009,69 +1056,70 @@ do_var_savecolor(int key)
void
assign_var_savecolor(void)
{
- 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;
- case kwcl_TitleForeground:
- put_pixel_on_root(Scr->TitleC.fore);
- break;
- case kwcl_TitleBackground:
- put_pixel_on_root(Scr->TitleC.back);
- break;
- case kwcl_IconForeground:
- put_pixel_on_root(Scr->IconC.fore);
- break;
- case kwcl_IconBackground:
- put_pixel_on_root(Scr->IconC.back);
- 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;
+ 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;
+ case kwcl_TitleForeground:
+ put_pixel_on_root(Scr->TitleC.fore);
+ break;
+ case kwcl_TitleBackground:
+ put_pixel_on_root(Scr->TitleC.back);
+ break;
+ case kwcl_IconForeground:
+ put_pixel_on_root(Scr->IconC.fore);
+ break;
+ case kwcl_IconBackground:
+ put_pixel_on_root(Scr->IconC.back);
+ 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;
}
- cp = cp->next;
- }
- if (chead) {
- free(chead);
- chead = NULL;
- }
}
static int
-ParseUsePPosition (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;
+ 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
@@ -1081,42 +1129,43 @@ ParseUsePPosition (char *s)
* \param denom 0 or indicates fraction denom
*/
void
-do_squeeze_entry (name_list **list, char *name, int justify, int num, int 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;
+ 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;
+ 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;
+ twmrc_error_prefix();
+ fprintf(stderr, "useless SqueezeTitle faction %d/%d, assuming 0/0\n",
+ num, denom);
+ num = 0;
+ denom = 0;
}
if (HasShape) {
- SqueezeInfo *sinfo;
- sinfo = malloc (sizeof(SqueezeInfo));
-
- if (!sinfo) {
- twmrc_error_prefix();
- fprintf (stderr, "unable to allocate %ld bytes for squeeze info\n",
- (unsigned long)sizeof(SqueezeInfo));
- return;
- }
- sinfo->justify = justify;
- sinfo->num = num;
- sinfo->denom = denom;
- AddToList (list, name, (char *) sinfo);
+ SqueezeInfo *sinfo;
+
+ sinfo = malloc(sizeof(SqueezeInfo));
+
+ if (!sinfo) {
+ twmrc_error_prefix();
+ fprintf(stderr, "unable to allocate %ld bytes for squeeze info\n",
+ (unsigned long) sizeof(SqueezeInfo));
+ return;
+ }
+ sinfo->justify = justify;
+ sinfo->num = num;
+ sinfo->denom = denom;
+ AddToList(list, name, (char *) sinfo);
}
}
diff --git a/src/parse.h b/src/parse.h
index e461e19..0d0500c 100644
--- a/src/parse.h
+++ b/src/parse.h
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/**********************************************************************
*
* .twmrc parsing externs
@@ -63,93 +62,91 @@ in this Software without prior written authorization from The Open Group.
#include "list.h"
-extern void assign_var_savecolor ( void );
-extern int do_single_keyword ( int keyword );
-extern int do_string_keyword ( int keyword, char *s );
-extern int do_number_keyword ( int keyword, int num );
-extern name_list **do_colorlist_keyword ( int keyword, int colormode,
- char *s );
-extern int do_color_keyword ( int keyword, int colormode, char *s );
-extern void do_string_savecolor ( int colormode, char *s );
-extern void do_var_savecolor ( int key );
-extern int ParseTwmrc ( char *filename );
-extern int parse_keyword ( char *s, int *nump );
-extern void TwmOutput ( int c );
-extern void twmUnput ( int c );
-extern void do_squeeze_entry ( name_list **list, char *name, int justify,
- int num, int denom );
-
-
-extern int (*twmInputFunc)(void);
+extern void assign_var_savecolor(void);
+extern int do_single_keyword(int keyword);
+extern int do_string_keyword(int keyword, char *s);
+extern int do_number_keyword(int keyword, int num);
+extern name_list **do_colorlist_keyword(int keyword, int colormode, char *s);
+extern int do_color_keyword(int keyword, int colormode, char *s);
+extern void do_string_savecolor(int colormode, char *s);
+extern void do_var_savecolor(int key);
+extern int ParseTwmrc(char *filename);
+extern int parse_keyword(char *s, int *nump);
+extern void TwmOutput(int c);
+extern void twmUnput(int c);
+extern void do_squeeze_entry(name_list ** list, char *name, int justify,
+ int num, int denom);
+
+extern int (*twmInputFunc) (void);
extern int ConstrainedMoveTime;
extern unsigned char *defTwmrc[];
extern int mods;
-#define F_NOP 0
-#define F_BEEP 1
-#define F_RESTART 2
-#define F_QUIT 3
-#define F_FOCUS 4
-#define F_REFRESH 5
-#define F_WINREFRESH 6
-#define F_DELTASTOP 7
-#define F_MOVE 8
-#define F_POPUP 9
-#define F_FORCEMOVE 10
-#define F_AUTORAISE 11
-#define F_IDENTIFY 12
-#define F_ICONIFY 13
-#define F_DEICONIFY 14
-#define F_UNFOCUS 15
-#define F_RESIZE 16
-#define F_ZOOM 17
-#define F_LEFTZOOM 18
-#define F_RIGHTZOOM 19
-#define F_TOPZOOM 20
-#define F_BOTTOMZOOM 21
-#define F_HORIZOOM 22
-#define F_FULLZOOM 23
-#define F_RAISE 24
-#define F_RAISELOWER 25
-#define F_LOWER 26
-#define F_DESTROY 27
-#define F_DELETE 28
-#define F_SAVEYOURSELF 29
-#define F_VERSION 30
-#define F_TITLE 31
-#define F_RIGHTICONMGR 32
-#define F_LEFTICONMGR 33
-#define F_UPICONMGR 34
-#define F_DOWNICONMGR 35
-#define F_FORWICONMGR 36
-#define F_BACKICONMGR 37
-#define F_NEXTICONMGR 38
-#define F_PREVICONMGR 39
-#define F_SORTICONMGR 40
-#define F_CIRCLEUP 41
-#define F_CIRCLEDOWN 42
-#define F_CUTFILE 43
-#define F_SHOWLIST 44
-#define F_HIDELIST 45
-
-#define F_MENU 101 /* string */
-#define F_WARPNEXT 112 /* string */
-#define F_WARPPREV 113 /* string */
-#define F_WARPTO 102 /* string */
-#define F_WARPTOICONMGR 103 /* string */
-#define F_WARPRING 104 /* string */
-#define F_FILE 105 /* string */
-#define F_EXEC 106 /* string */
-#define F_CUT 107 /* string */
-#define F_FUNCTION 108 /* string */
-#define F_WARPTOSCREEN 109 /* string */
-#define F_COLORMAP 110 /* string */
-#define F_PRIORITY 111 /* string */
-#define F_STARTWM 114 /* string */
-
-#define D_NORTH 1
-#define D_SOUTH 2
-#define D_EAST 3
-#define D_WEST 4
-
-#endif /* _PARSE_ */
+#define F_NOP 0
+#define F_BEEP 1
+#define F_RESTART 2
+#define F_QUIT 3
+#define F_FOCUS 4
+#define F_REFRESH 5
+#define F_WINREFRESH 6
+#define F_DELTASTOP 7
+#define F_MOVE 8
+#define F_POPUP 9
+#define F_FORCEMOVE 10
+#define F_AUTORAISE 11
+#define F_IDENTIFY 12
+#define F_ICONIFY 13
+#define F_DEICONIFY 14
+#define F_UNFOCUS 15
+#define F_RESIZE 16
+#define F_ZOOM 17
+#define F_LEFTZOOM 18
+#define F_RIGHTZOOM 19
+#define F_TOPZOOM 20
+#define F_BOTTOMZOOM 21
+#define F_HORIZOOM 22
+#define F_FULLZOOM 23
+#define F_RAISE 24
+#define F_RAISELOWER 25
+#define F_LOWER 26
+#define F_DESTROY 27
+#define F_DELETE 28
+#define F_SAVEYOURSELF 29
+#define F_VERSION 30
+#define F_TITLE 31
+#define F_RIGHTICONMGR 32
+#define F_LEFTICONMGR 33
+#define F_UPICONMGR 34
+#define F_DOWNICONMGR 35
+#define F_FORWICONMGR 36
+#define F_BACKICONMGR 37
+#define F_NEXTICONMGR 38
+#define F_PREVICONMGR 39
+#define F_SORTICONMGR 40
+#define F_CIRCLEUP 41
+#define F_CIRCLEDOWN 42
+#define F_CUTFILE 43
+#define F_SHOWLIST 44
+#define F_HIDELIST 45
+
+#define F_MENU 101 /* string */
+#define F_WARPNEXT 112 /* string */
+#define F_WARPPREV 113 /* string */
+#define F_WARPTO 102 /* string */
+#define F_WARPTOICONMGR 103 /* string */
+#define F_WARPRING 104 /* string */
+#define F_FILE 105 /* string */
+#define F_EXEC 106 /* string */
+#define F_CUT 107 /* string */
+#define F_FUNCTION 108 /* string */
+#define F_WARPTOSCREEN 109 /* string */
+#define F_COLORMAP 110 /* string */
+#define F_PRIORITY 111 /* string */
+#define F_STARTWM 114 /* string */
+
+#define D_NORTH 1
+#define D_SOUTH 2
+#define D_EAST 3
+#define D_WEST 4
+
+#endif /* _PARSE_ */
diff --git a/src/resize.c b/src/resize.c
index 5a93ac5..07a1015 100644
--- a/src/resize.c
+++ b/src/resize.c
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* window resizing borrowed from the "wm" window manager
@@ -68,13 +67,13 @@ in this Software without prior written authorization from The Open Group.
#include "screen.h"
#include "events.h"
-static void DisplaySize ( TwmWindow *tmp_win, int width, int height );
+static void DisplaySize(TwmWindow *tmp_win, int width, int height);
-#define MINHEIGHT 0 /* had been 32 */
-#define MINWIDTH 0 /* had been 60 */
+#define MINHEIGHT 0 /* had been 32 */
+#define MINWIDTH 0 /* had been 60 */
-static int dragx; /* all these variables are used */
-static int dragy; /* in resize operations */
+static int dragx; /* all these variables are used */
+static int dragy; /* in resize operations */
static int dragWidth;
static int dragHeight;
@@ -93,51 +92,51 @@ static int clampDY;
static int last_width;
static int last_height;
-
static void
-do_auto_clamp (TwmWindow *tmp_win, XEvent *evp)
+do_auto_clamp(TwmWindow *tmp_win, XEvent *evp)
{
Window junkRoot;
int x, y, h, v, junkbw;
unsigned int junkMask;
switch (evp->type) {
- case ButtonPress:
- x = evp->xbutton.x_root;
- y = evp->xbutton.y_root;
- break;
- case KeyPress:
- x = evp->xkey.x_root;
- y = evp->xkey.y_root;
- break;
- default:
- if (!XQueryPointer (dpy, Scr->Root, &junkRoot, &junkRoot,
- &x, &y, &junkbw, &junkbw, &junkMask))
- return;
+ case ButtonPress:
+ x = evp->xbutton.x_root;
+ y = evp->xbutton.y_root;
+ break;
+ case KeyPress:
+ x = evp->xkey.x_root;
+ y = evp->xkey.y_root;
+ break;
+ default:
+ if (!XQueryPointer(dpy, Scr->Root, &junkRoot, &junkRoot,
+ &x, &y, &junkbw, &junkbw, &junkMask))
+ return;
}
h = ((x - dragx) / (dragWidth < 3 ? 1 : (dragWidth / 3)));
v = ((y - dragy - tmp_win->title_height) /
- (dragHeight < 3 ? 1 : (dragHeight / 3)));
+ (dragHeight < 3 ? 1 : (dragHeight / 3)));
if (h <= 0) {
- clampLeft = 1;
- clampDX = (x - dragx);
- } else if (h >= 2) {
- clampRight = 1;
- clampDX = (x - dragx - dragWidth);
+ 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);
+ clampTop = 1;
+ clampDY = (y - dragy);
+ }
+ else if (v >= 2) {
+ clampBottom = 1;
+ clampDY = (y - dragy - dragHeight);
}
}
-
/**
* begin a window resize operation
* \param ev the event structure (button press)
@@ -147,20 +146,20 @@ do_auto_clamp (TwmWindow *tmp_win, XEvent *evp)
void
StartResize(XEvent *evp, TwmWindow *tmp_win, Bool fromtitlebar)
{
- Window junkRoot;
+ 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);
+ 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, &dragy, (unsigned int *) &dragWidth,
+ (unsigned int *) &dragHeight, &junkbw, &junkDepth);
dragx += tmp_win->frame_bw;
dragy += tmp_win->frame_bw;
origx = dragx;
@@ -170,53 +169,51 @@ StartResize(XEvent *evp, TwmWindow *tmp_win, Bool fromtitlebar)
clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0;
if (Scr->AutoRelativeResize && !fromtitlebar)
- do_auto_clamp (tmp_win, evp);
+ do_auto_clamp(tmp_win, evp);
Scr->SizeStringOffset = SIZE_HINDENT;
- XResizeWindow (dpy, Scr->SizeWindow,
- (unsigned)(Scr->SizeStringWidth + SIZE_HINDENT * 2),
- (unsigned)(Scr->SizeFont.height + SIZE_VINDENT * 2));
+ XResizeWindow(dpy, Scr->SizeWindow,
+ (unsigned) (Scr->SizeStringWidth + SIZE_HINDENT * 2),
+ (unsigned) (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);
+ 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(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);
+ 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; */
+ 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,
- (unsigned)(Scr->SizeStringWidth + SIZE_HINDENT * 2),
- (unsigned)(Scr->SizeFont.height + SIZE_VINDENT * 2));
+ XResizeWindow(dpy, Scr->SizeWindow,
+ (unsigned) (Scr->SizeStringWidth + SIZE_HINDENT * 2),
+ (unsigned) (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);
+ 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);
}
/**
@@ -228,9 +225,9 @@ 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);
+ ButtonReleaseMask | ButtonMotionMask | PointerMotionHintMask,
+ GrabModeAsync, GrabModeAsync,
+ Scr->Root, Scr->ResizeCursor, CurrentTime);
dragx = x + tmp_win->frame_bw;
dragy = y + tmp_win->frame_bw;
@@ -241,7 +238,7 @@ AddStartResize(TwmWindow *tmp_win, int x, int y, int w, int h)
clampTop = clampBottom = clampLeft = clampRight = clampDX = clampDY = 0;
/*****
if (Scr->AutoRelativeResize) {
- clampRight = clampBottom = 1;
+ clampRight = clampBottom = 1;
}
*****/
last_width = 0;
@@ -249,8 +246,6 @@ AddStartResize(TwmWindow *tmp_win, int x, int y, int w, int h)
DisplaySize(tmp_win, origWidth, origHeight);
}
-
-
void
MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win)
{
@@ -262,7 +257,8 @@ MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win)
y_root -= clampDY;
if (clampTop) {
- int delta = y_root - dragy;
+ int delta = y_root - dragy;
+
if (dragHeight - delta < MINHEIGHT) {
delta = dragHeight - MINHEIGHT;
clampTop = 0;
@@ -271,18 +267,18 @@ MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win)
dragHeight -= delta;
action = 1;
}
- else if (y_root <= dragy/* ||
- y_root == findRootInfo(root)->rooty*/) {
+ else if (y_root <= dragy /* ||
+ y_root == findRootInfo(root)->rooty */ ) {
dragy = y_root;
- dragHeight = origy + origHeight -
- y_root;
+ dragHeight = origy + origHeight - y_root;
clampBottom = 0;
clampTop = 1;
- clampDY = 0;
+ clampDY = 0;
action = 1;
}
if (clampLeft) {
- int delta = x_root - dragx;
+ int delta = x_root - dragx;
+
if (dragWidth - delta < MINWIDTH) {
delta = dragWidth - MINWIDTH;
clampLeft = 0;
@@ -291,18 +287,18 @@ MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win)
dragWidth -= delta;
action = 1;
}
- else if (x_root <= dragx/* ||
- x_root == findRootInfo(root)->rootx*/) {
+ else if (x_root <= dragx /* ||
+ x_root == findRootInfo(root)->rootx */ ) {
dragx = x_root;
- dragWidth = origx + origWidth -
- x_root;
+ dragWidth = origx + origWidth - x_root;
clampRight = 0;
clampLeft = 1;
- clampDX = 0;
+ clampDX = 0;
action = 1;
}
if (clampBottom) {
- int delta = y_root - dragy - dragHeight;
+ int delta = y_root - dragy - dragHeight;
+
if (dragHeight + delta < MINHEIGHT) {
delta = MINHEIGHT - dragHeight;
clampBottom = 0;
@@ -315,11 +311,12 @@ MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win)
dragHeight = 1 + y_root - dragy;
clampTop = 0;
clampBottom = 1;
- clampDY = 0;
+ clampDY = 0;
action = 1;
}
if (clampRight) {
- int delta = x_root - dragx - dragWidth;
+ int delta = x_root - dragx - dragWidth;
+
if (dragWidth + delta < MINWIDTH) {
delta = MINWIDTH - dragWidth;
clampRight = 0;
@@ -332,28 +329,27 @@ MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win)
dragWidth = 1 + x_root - origx;
clampLeft = 0;
clampRight = 1;
- clampDX = 0;
+ clampDX = 0;
action = 1;
}
if (action) {
- ConstrainSize (tmp_win, &dragWidth, &dragHeight);
+ 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);
+ 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);
}
-
/**
* move the rubberband around. This is called for each motion event when
* we are resizing
@@ -373,7 +369,8 @@ DoResize(int x_root, int y_root, TwmWindow *tmp_win)
y_root -= clampDY;
if (clampTop) {
- int delta = y_root - dragy;
+ int delta = y_root - dragy;
+
if (dragHeight - delta < MINHEIGHT) {
delta = dragHeight - MINHEIGHT;
clampTop = 0;
@@ -382,18 +379,18 @@ DoResize(int x_root, int y_root, TwmWindow *tmp_win)
dragHeight -= delta;
action = 1;
}
- else if (y_root <= dragy/* ||
- y_root == findRootInfo(root)->rooty*/) {
+ else if (y_root <= dragy /* ||
+ y_root == findRootInfo(root)->rooty */ ) {
dragy = y_root;
- dragHeight = origy + origHeight -
- y_root;
+ dragHeight = origy + origHeight - y_root;
clampBottom = 0;
clampTop = 1;
- clampDY = 0;
+ clampDY = 0;
action = 1;
}
if (clampLeft) {
- int delta = x_root - dragx;
+ int delta = x_root - dragx;
+
if (dragWidth - delta < MINWIDTH) {
delta = dragWidth - MINWIDTH;
clampLeft = 0;
@@ -402,18 +399,18 @@ DoResize(int x_root, int y_root, TwmWindow *tmp_win)
dragWidth -= delta;
action = 1;
}
- else if (x_root <= dragx/* ||
- x_root == findRootInfo(root)->rootx*/) {
+ else if (x_root <= dragx /* ||
+ x_root == findRootInfo(root)->rootx */ ) {
dragx = x_root;
- dragWidth = origx + origWidth -
- x_root;
+ dragWidth = origx + origWidth - x_root;
clampRight = 0;
clampLeft = 1;
- clampDX = 0;
+ clampDX = 0;
action = 1;
}
if (clampBottom) {
- int delta = y_root - dragy - dragHeight;
+ int delta = y_root - dragy - dragHeight;
+
if (dragHeight + delta < MINHEIGHT) {
delta = MINHEIGHT - dragHeight;
clampBottom = 0;
@@ -421,18 +418,19 @@ DoResize(int x_root, int y_root, TwmWindow *tmp_win)
dragHeight += delta;
action = 1;
}
- else if (y_root >= dragy + dragHeight - 1/* ||
- y_root == findRootInfo(root)->rooty
- + findRootInfo(root)->rootheight - 1*/) {
+ else if (y_root >= dragy + dragHeight - 1 /* ||
+ y_root == findRootInfo(root)->rooty
+ + findRootInfo(root)->rootheight - 1 */ ) {
dragy = origy;
dragHeight = 1 + y_root - dragy;
clampTop = 0;
clampBottom = 1;
- clampDY = 0;
+ clampDY = 0;
action = 1;
}
if (clampRight) {
- int delta = x_root - dragx - dragWidth;
+ int delta = x_root - dragx - dragWidth;
+
if (dragWidth + delta < MINWIDTH) {
delta = MINWIDTH - dragWidth;
clampRight = 0;
@@ -440,29 +438,29 @@ DoResize(int x_root, int y_root, TwmWindow *tmp_win)
dragWidth += delta;
action = 1;
}
- else if (x_root >= dragx + dragWidth - 1/* ||
- x_root == findRootInfo(root)->rootx +
- findRootInfo(root)->rootwidth - 1*/) {
+ else if (x_root >= dragx + dragWidth - 1 /* ||
+ x_root == findRootInfo(root)->rootx +
+ findRootInfo(root)->rootwidth - 1 */ ) {
dragx = origx;
dragWidth = 1 + x_root - origx;
clampLeft = 0;
clampRight = 1;
- clampDX = 0;
+ clampDX = 0;
action = 1;
}
if (action) {
- ConstrainSize (tmp_win, &dragWidth, &dragHeight);
+ 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);
+ 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);
@@ -495,30 +493,29 @@ DisplaySize(TwmWindow *tmp_win, int width, int height)
* 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)
- {
- if (tmp_win->hints.flags & PBaseSize) {
- dwidth -= tmp_win->hints.base_width;
- dheight -= tmp_win->hints.base_height;
- } else {
- dwidth -= tmp_win->hints.min_width;
- dheight -= tmp_win->hints.min_height;
- }
+ if (tmp_win->hints.flags & (PMinSize | PBaseSize) &&
+ tmp_win->hints.flags & PResizeInc) {
+ if (tmp_win->hints.flags & PBaseSize) {
+ dwidth -= tmp_win->hints.base_width;
+ dheight -= tmp_win->hints.base_height;
+ }
+ else {
+ dwidth -= tmp_win->hints.min_width;
+ dheight -= tmp_win->hints.min_height;
+ }
}
- if (tmp_win->hints.flags & PResizeInc)
- {
+ if (tmp_win->hints.flags & PResizeInc) {
dwidth /= tmp_win->hints.width_inc;
dheight /= tmp_win->hints.height_inc;
}
- (void) snprintf (str, sizeof(str), " %4d x %-4d ", dwidth, dheight);
+ (void) snprintf(str, sizeof(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);
+ MyFont_DrawImageString(dpy, Scr->SizeWindow, &Scr->SizeFont,
+ Scr->NormalGC, Scr->SizeStringOffset,
+ Scr->SizeFont.ascent + SIZE_VINDENT, str, 13);
}
/**
@@ -536,25 +533,26 @@ EndResize(void)
MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
XUnmapWindow(dpy, Scr->SizeWindow);
- XFindContext(dpy, ResizeWindow, TwmContext, (XPointer *)&tmp_win);
+ XFindContext(dpy, ResizeWindow, TwmContext, (XPointer *) &tmp_win);
- ConstrainSize (tmp_win, &dragWidth, &dragHeight);
+ ConstrainSize(tmp_win, &dragWidth, &dragHeight);
if (dragWidth != tmp_win->frame_width ||
dragHeight != tmp_win->frame_height)
- tmp_win->zoomed = ZOOM_NONE;
+ tmp_win->zoomed = ZOOM_NONE;
- SetupWindow (tmp_win, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
- dragWidth, dragHeight, -1);
+ SetupWindow(tmp_win, dragx - tmp_win->frame_bw, dragy - tmp_win->frame_bw,
+ dragWidth, dragHeight, -1);
- if (tmp_win->iconmgr)
- {
- int ncols = tmp_win->iconmgrp->cur_columns;
- if (ncols == 0) ncols = 1;
+ 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);
+ tmp_win->iconmgrp->width = (int) ((dragWidth *
+ (long) tmp_win->iconmgrp->columns)
+ / ncols);
PackIconManager(tmp_win->iconmgrp);
}
@@ -571,16 +569,14 @@ MenuEndResize(TwmWindow *tmp_win)
{
MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
XUnmapWindow(dpy, Scr->SizeWindow);
- ConstrainSize (tmp_win, &dragWidth, &dragHeight);
+ 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);
+ AddingW = dragWidth; /* + (2 * tmp_win->frame_bw); */
+ AddingH = dragHeight; /* + (2 * tmp_win->frame_bw); */
+ SetupWindow(tmp_win, AddingX, AddingY, AddingW, AddingH, -1);
}
-
-
/**
* finish the resize operation for AddWindo<w
*/
@@ -592,7 +588,7 @@ AddEndResize(TwmWindow *tmp_win)
fprintf(stderr, "AddEndResize\n");
#endif
- ConstrainSize (tmp_win, &dragWidth, &dragHeight);
+ ConstrainSize(tmp_win, &dragWidth, &dragHeight);
AddingX = dragx - tmp_win->frame_bw;
AddingY = dragy - tmp_win->frame_bw;
AddingW = dragWidth + (2 * tmp_win->frame_bw);
@@ -607,7 +603,7 @@ AddEndResize(TwmWindow *tmp_win)
* borrowed from uwm's CheckConsistency routine.
*/
void
-ConstrainSize (TwmWindow *tmp_win, int *widthp, int *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))
@@ -616,51 +612,58 @@ ConstrainSize (TwmWindow *tmp_win, int *widthp, int *heightp)
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) {
+ }
+ else if (tmp_win->hints.flags & PBaseSize) {
minWidth = tmp_win->hints.base_width;
minHeight = tmp_win->hints.base_height;
- } else
+ }
+ else
minWidth = minHeight = 1;
if (tmp_win->hints.flags & PBaseSize) {
- baseWidth = tmp_win->hints.base_width;
- baseHeight = tmp_win->hints.base_height;
- } else if (tmp_win->hints.flags & PMinSize) {
- baseWidth = tmp_win->hints.min_width;
- baseHeight = tmp_win->hints.min_height;
- } else
- baseWidth = baseHeight = 0;
-
+ baseWidth = tmp_win->hints.base_width;
+ baseHeight = tmp_win->hints.base_height;
+ }
+ else if (tmp_win->hints.flags & PMinSize) {
+ baseWidth = tmp_win->hints.min_width;
+ baseHeight = tmp_win->hints.min_height;
+ }
+ else
+ baseWidth = baseHeight = 0;
if (tmp_win->hints.flags & PMaxSize) {
- maxWidth = _min (Scr->MaxWindowWidth, tmp_win->hints.max_width);
- maxHeight = _min (Scr->MaxWindowHeight, tmp_win->hints.max_height);
- } else {
+ maxWidth = _min(Scr->MaxWindowWidth, tmp_win->hints.max_width);
+ maxHeight = _min(Scr->MaxWindowHeight, tmp_win->hints.max_height);
+ }
+ else {
maxWidth = Scr->MaxWindowWidth;
- maxHeight = Scr->MaxWindowHeight;
+ maxHeight = Scr->MaxWindowHeight;
}
if (tmp_win->hints.flags & PResizeInc) {
xinc = tmp_win->hints.width_inc;
yinc = tmp_win->hints.height_inc;
- } else
+ }
+ else
xinc = yinc = 1;
/*
* First, clamp to min and max values
*/
- if (dwidth < minWidth) dwidth = minWidth;
- if (dheight < minHeight) dheight = minHeight;
-
- if (dwidth > maxWidth) dwidth = maxWidth;
- if (dheight > maxHeight) dheight = maxHeight;
+ if (dwidth < minWidth)
+ dwidth = minWidth;
+ if (dheight < minHeight)
+ dheight = minHeight;
+ if (dwidth > maxWidth)
+ dwidth = maxWidth;
+ if (dheight > maxHeight)
+ dheight = maxHeight;
/*
* Second, fit to base + N * inc
@@ -668,7 +671,6 @@ ConstrainSize (TwmWindow *tmp_win, int *widthp, int *heightp)
dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth;
dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight;
-
/*
* Third, adjust for aspect ratio
*/
@@ -691,36 +693,32 @@ ConstrainSize (TwmWindow *tmp_win, int *widthp, int *heightp)
*
*/
- if (tmp_win->hints.flags & PAspect)
- {
- if (minAspectX * dheight > minAspectY * dwidth)
- {
- delta = makemult(minAspectX * dheight / minAspectY - dwidth,
- xinc);
- if (dwidth + delta <= maxWidth) dwidth += delta;
- else
- {
- delta = makemult(dheight - dwidth*minAspectY/minAspectX,
+ if (tmp_win->hints.flags & PAspect) {
+ if (minAspectX * dheight > minAspectY * dwidth) {
+ delta = makemult(minAspectX * dheight / minAspectY - dwidth, xinc);
+ if (dwidth + delta <= maxWidth)
+ dwidth += delta;
+ else {
+ delta = makemult(dheight - dwidth * minAspectY / minAspectX,
yinc);
- if (dheight - delta >= minHeight) dheight -= delta;
+ if (dheight - delta >= minHeight)
+ dheight -= delta;
}
}
- if (maxAspectX * dheight < maxAspectY * dwidth)
- {
- delta = makemult(dwidth * maxAspectY / maxAspectX - dheight,
- yinc);
- if (dheight + delta <= maxHeight) dheight += delta;
- else
- {
- delta = makemult(dwidth - maxAspectX*dheight/maxAspectY,
+ if (maxAspectX * dheight < maxAspectY * dwidth) {
+ delta = makemult(dwidth * maxAspectY / maxAspectX - dheight, yinc);
+ if (dheight + delta <= maxHeight)
+ dheight += delta;
+ else {
+ delta = makemult(dwidth - maxAspectX * dheight / maxAspectY,
xinc);
- if (dwidth - delta >= minWidth) dwidth -= delta;
+ if (dwidth - delta >= minWidth)
+ dwidth -= delta;
}
}
}
-
/*
* Fourth, account for border width and title height
*/
@@ -728,7 +726,6 @@ ConstrainSize (TwmWindow *tmp_win, int *widthp, int *heightp)
*heightp = dheight + tmp_win->title_height;
}
-
/**
* set window sizes, this was called from either AddWindow, EndResize, or
* HandleConfigureNotify.
@@ -749,15 +746,18 @@ ConstrainSize (TwmWindow *tmp_win, int *widthp, int *heightp)
* \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 (TwmWindow *tmp_win, int x, int y, int w, int h, int 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);
+ SetupFrame(tmp_win, x, y, w, h, bw, False);
}
/**
* \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)
+void
+SetupFrame(TwmWindow *tmp_win, int x, int y, int w, int h, int bw,
+ Bool sendEvent)
{
XEvent client_event;
XWindowChanges frame_wc, xwc;
@@ -766,19 +766,19 @@ void SetupFrame (TwmWindow *tmp_win, int x, int y, int w, int h, int bw, Bool se
int reShape;
#ifdef DEBUG
- fprintf (stderr, "SetupWindow: x=%d, y=%d, w=%d, h=%d, bw=%d\n",
- x, y, w, h, bw);
+ 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 */
+ x = Scr->MyDisplayWidth - 16; /* one "average" cursor width */
if (y >= Scr->MyDisplayHeight)
- y = Scr->MyDisplayHeight - 16; /* one "average" cursor width */
+ y = Scr->MyDisplayHeight - 16; /* one "average" cursor width */
if (bw < 0)
- bw = tmp_win->frame_bw; /* -1 means current frame width */
+ bw = tmp_win->frame_bw; /* -1 means current frame width */
if (tmp_win->iconmgr) {
- tmp_win->iconmgrp->width = w;
+ tmp_win->iconmgrp->width = w;
h = tmp_win->iconmgrp->height + tmp_win->title_height;
}
@@ -788,121 +788,119 @@ void SetupFrame (TwmWindow *tmp_win, int x, int y, int w, int h, int bw, Bool se
* was moved but not resized.
*/
if (((x != tmp_win->frame_x || y != tmp_win->frame_y) &&
- (w == tmp_win->frame_width && h == tmp_win->frame_height)) ||
- (bw != tmp_win->frame_bw))
- sendEvent = TRUE;
+ (w == tmp_win->frame_width && h == tmp_win->frame_height)) ||
+ (bw != tmp_win->frame_bw))
+ sendEvent = TRUE;
xwcm = CWWidth;
title_width = xwc.width = w;
title_height = Scr->TitleHeight + bw;
- ComputeWindowTitleOffsets (tmp_win, xwc.width, True);
+ ComputeWindowTitleOffsets(tmp_win, xwc.width, True);
reShape = (tmp_win->wShaped ? TRUE : FALSE);
- if (tmp_win->squeeze_info) /* check for title shaping */
- {
- title_width = tmp_win->rightx + Scr->TBInfo.rightoff;
- if (title_width < xwc.width)
- {
- xwc.width = title_width;
- if (tmp_win->frame_height != h ||
- tmp_win->frame_width != w ||
- tmp_win->frame_bw != bw ||
- title_width != tmp_win->title_width)
- reShape = TRUE;
- }
- else
- {
- if (!tmp_win->wShaped) reShape = TRUE;
- title_width = xwc.width;
- }
+ if (tmp_win->squeeze_info) { /* check for title shaping */
+ title_width = tmp_win->rightx + Scr->TBInfo.rightoff;
+ if (title_width < xwc.width) {
+ xwc.width = title_width;
+ if (tmp_win->frame_height != h ||
+ tmp_win->frame_width != w ||
+ tmp_win->frame_bw != bw || title_width != tmp_win->title_width)
+ reShape = TRUE;
+ }
+ else {
+ if (!tmp_win->wShaped)
+ reShape = TRUE;
+ title_width = xwc.width;
+ }
}
tmp_win->title_width = title_width;
- if (tmp_win->title_height) tmp_win->title_height = title_height;
+ if (tmp_win->title_height)
+ tmp_win->title_height = title_height;
if (tmp_win->title_w) {
- if (bw != tmp_win->frame_bw) {
- xwc.border_width = bw;
- tmp_win->title_x = xwc.x = -bw;
- tmp_win->title_y = xwc.y = -bw;
- xwcm |= (CWX | CWY | CWBorderWidth);
- }
-
- XConfigureWindow(dpy, tmp_win->title_w, (unsigned)xwcm, &xwc);
+ if (bw != tmp_win->frame_bw) {
+ xwc.border_width = bw;
+ tmp_win->title_x = xwc.x = -bw;
+ tmp_win->title_y = xwc.y = -bw;
+ xwcm |= (CWX | CWY | CWBorderWidth);
+ }
+
+ XConfigureWindow(dpy, tmp_win->title_w, (unsigned) xwcm, &xwc);
}
if (tmp_win->attr.width != w)
- tmp_win->widthEverChangedByUser = True;
+ tmp_win->widthEverChangedByUser = True;
if (tmp_win->attr.height != (h - tmp_win->title_height))
- tmp_win->heightEverChangedByUser = True;
+ tmp_win->heightEverChangedByUser = True;
tmp_win->attr.width = w;
tmp_win->attr.height = h - tmp_win->title_height;
- XMoveResizeWindow (dpy, tmp_win->w, 0, tmp_win->title_height,
- (unsigned)w, (unsigned)(h - tmp_win->title_height));
+ XMoveResizeWindow(dpy, tmp_win->w, 0, tmp_win->title_height,
+ (unsigned) w, (unsigned) (h - tmp_win->title_height));
/*
* fix up frame and assign size/location values in tmp_win
*/
frame_mask = 0;
if (bw != tmp_win->frame_bw) {
- frame_wc.border_width = tmp_win->frame_bw = bw;
- frame_mask |= CWBorderWidth;
+ frame_wc.border_width = tmp_win->frame_bw = bw;
+ frame_mask |= CWBorderWidth;
}
frame_wc.x = tmp_win->frame_x = x;
frame_wc.y = tmp_win->frame_y = y;
frame_wc.width = tmp_win->frame_width = w;
frame_wc.height = tmp_win->frame_height = h;
frame_mask |= (CWX | CWY | CWWidth | CWHeight);
- XConfigureWindow (dpy, tmp_win->frame, (unsigned)frame_mask, &frame_wc);
+ XConfigureWindow(dpy, tmp_win->frame, (unsigned) frame_mask, &frame_wc);
/*
* fix up highlight window
*/
- if (tmp_win->title_height && tmp_win->hilite_w)
- {
- xwc.width = (tmp_win->rightx - tmp_win->highlightx);
- if (Scr->TBInfo.nright > 0) xwc.width -= Scr->TitlePadding;
+ if (tmp_win->title_height && tmp_win->hilite_w) {
+ xwc.width = (tmp_win->rightx - tmp_win->highlightx);
+ if (Scr->TBInfo.nright > 0)
+ xwc.width -= Scr->TitlePadding;
if (xwc.width <= 0) {
- xwc.x = Scr->MyDisplayWidth; /* move offscreen */
+ xwc.x = Scr->MyDisplayWidth; /* move offscreen */
xwc.width = 1;
- } else {
+ }
+ else {
xwc.x = tmp_win->highlightx;
}
xwcm = CWX | CWWidth;
- XConfigureWindow(dpy, tmp_win->hilite_w, (unsigned)xwcm, &xwc);
+ XConfigureWindow(dpy, tmp_win->hilite_w, (unsigned) xwcm, &xwc);
}
if (HasShape && reShape) {
- SetFrameShape (tmp_win);
+ SetFrameShape(tmp_win);
}
- if (sendEvent)
- {
+ if (sendEvent) {
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);
+ 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;
+ 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 ????? */
+ /* 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);
}
}
-
/**
* 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
@@ -913,49 +911,44 @@ void SetupFrame (TwmWindow *tmp_win, int x, int y, int w, int h, int bw, Bool se
void
fullzoom(TwmWindow *tmp_win, int flag)
{
- Window junkRoot;
+ 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;
+ 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;
+ }
+ else {
+ if (tmp_win->zoomed == ZOOM_NONE) {
+ tmp_win->save_frame_x = dragx;
+ tmp_win->save_frame_y = dragy;
+ tmp_win->save_frame_width = dragWidth;
+ tmp_win->save_frame_height = dragHeight;
+ tmp_win->zoomed = (short) flag;
}
else
- {
- if (tmp_win->zoomed == ZOOM_NONE)
- {
- tmp_win->save_frame_x = dragx;
- tmp_win->save_frame_y = dragy;
- tmp_win->save_frame_width = dragWidth;
- tmp_win->save_frame_height = dragHeight;
- tmp_win->zoomed = (short)flag;
- }
- else
- tmp_win->zoomed = (short)flag;
-
-
- frame_bw_times_2 = 2*tmp_win->frame_bw;
-
- switch (flag)
- {
+ tmp_win->zoomed = (short) flag;
+
+ frame_bw_times_2 = 2 * tmp_win->frame_bw;
+
+ switch (flag) {
case ZOOM_NONE:
break;
case F_ZOOM:
dragHeight = Scr->MyDisplayHeight - frame_bw_times_2;
- dragy=basey;
+ dragy = basey;
break;
case F_HORIZOOM:
dragx = basex;
@@ -971,50 +964,51 @@ fullzoom(TwmWindow *tmp_win, int flag)
dragx = basex;
dragy = basey;
dragHeight = Scr->MyDisplayHeight - frame_bw_times_2;
- dragWidth = Scr->MyDisplayWidth/2 - frame_bw_times_2;
+ dragWidth = Scr->MyDisplayWidth / 2 - frame_bw_times_2;
break;
case F_RIGHTZOOM:
- dragx = basex + Scr->MyDisplayWidth/2;
+ dragx = basex + Scr->MyDisplayWidth / 2;
dragy = basey;
dragHeight = Scr->MyDisplayHeight - frame_bw_times_2;
- dragWidth = Scr->MyDisplayWidth/2 - frame_bw_times_2;
+ dragWidth = Scr->MyDisplayWidth / 2 - frame_bw_times_2;
break;
case F_TOPZOOM:
dragx = basex;
dragy = basey;
- dragHeight = Scr->MyDisplayHeight/2 - frame_bw_times_2;
+ dragHeight = Scr->MyDisplayHeight / 2 - frame_bw_times_2;
dragWidth = Scr->MyDisplayWidth - frame_bw_times_2;
break;
case F_BOTTOMZOOM:
dragx = basex;
- dragy = basey + Scr->MyDisplayHeight/2;
- dragHeight = Scr->MyDisplayHeight/2 - frame_bw_times_2;
+ 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);
+ SetupWindow(tmp_win, dragx, dragy, dragWidth, dragHeight, -1);
+ XUngrabPointer(dpy, CurrentTime);
+ XUngrabServer(dpy);
}
void
-SetFrameShape (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);
+ 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);
}
/*
@@ -1023,63 +1017,64 @@ SetFrameShape (TwmWindow *tmp)
* rectangular).
*/
if (tmp->wShaped) {
- /*
- * need to do general case
- */
- XShapeCombineShape (dpy, tmp->frame, ShapeBounding,
- 0, tmp->title_height, tmp->w,
- ShapeBounding, ShapeSet);
- if (tmp->title_w) {
- XShapeCombineShape (dpy, tmp->frame, ShapeBounding,
- tmp->title_x + tmp->frame_bw,
- tmp->title_y + tmp->frame_bw,
- tmp->title_w, ShapeBounding,
- ShapeUnion);
- }
- } else {
- /*
- * can optimize rectangular contents window
- */
- if (tmp->squeeze_info) {
- XRectangle newBounding[2];
- XRectangle newClip[2];
- int fbw2 = 2 * tmp->frame_bw;
-
- /*
- * Build the border clipping rectangles; one around title, one
- * around window. The title_[xy] field already have had frame_bw
- * subtracted off them so that they line up properly in the frame.
- *
- * The frame_width and frame_height do *not* include borders.
- */
- /* border */
- newBounding[0].x = (short)tmp->title_x;
- newBounding[0].y = (short)tmp->title_y;
- newBounding[0].width = (unsigned short)(tmp->title_width + fbw2);
- newBounding[0].height = (unsigned short)tmp->title_height;
- newBounding[1].x = (short)-tmp->frame_bw;
- newBounding[1].y = (short)Scr->TitleHeight;
- newBounding[1].width = (unsigned short)(tmp->attr.width + fbw2);
- newBounding[1].height = (unsigned short)(tmp->attr.height + fbw2);
- XShapeCombineRectangles (dpy, tmp->frame, ShapeBounding, 0, 0,
- newBounding, 2, ShapeSet, YXBanded);
- /* insides */
- newClip[0].x = (short)(tmp->title_x + tmp->frame_bw);
- newClip[0].y = 0;
- newClip[0].width = (unsigned short)tmp->title_width;
- newClip[0].height = (unsigned short)Scr->TitleHeight;
- newClip[1].x = 0;
- newClip[1].y = (short)tmp->title_height;
- newClip[1].width = (unsigned short)tmp->attr.width;
- newClip[1].height = (unsigned short)tmp->attr.height;
- XShapeCombineRectangles (dpy, tmp->frame, ShapeClip, 0, 0,
- newClip, 2, ShapeSet, YXBanded);
- } else {
- (void) XShapeCombineMask (dpy, tmp->frame, ShapeBounding, 0, 0,
- None, ShapeSet);
- (void) XShapeCombineMask (dpy, tmp->frame, ShapeClip, 0, 0,
- None, ShapeSet);
- }
+ /*
+ * need to do general case
+ */
+ XShapeCombineShape(dpy, tmp->frame, ShapeBounding,
+ 0, tmp->title_height, tmp->w,
+ ShapeBounding, ShapeSet);
+ if (tmp->title_w) {
+ XShapeCombineShape(dpy, tmp->frame, ShapeBounding,
+ tmp->title_x + tmp->frame_bw,
+ tmp->title_y + tmp->frame_bw,
+ tmp->title_w, ShapeBounding, ShapeUnion);
+ }
+ }
+ else {
+ /*
+ * can optimize rectangular contents window
+ */
+ if (tmp->squeeze_info) {
+ XRectangle newBounding[2];
+ XRectangle newClip[2];
+ int fbw2 = 2 * tmp->frame_bw;
+
+ /*
+ * Build the border clipping rectangles; one around title, one
+ * around window. The title_[xy] field already have had frame_bw
+ * subtracted off them so that they line up properly in the frame.
+ *
+ * The frame_width and frame_height do *not* include borders.
+ */
+ /* border */
+ newBounding[0].x = (short) tmp->title_x;
+ newBounding[0].y = (short) tmp->title_y;
+ newBounding[0].width = (unsigned short) (tmp->title_width + fbw2);
+ newBounding[0].height = (unsigned short) tmp->title_height;
+ newBounding[1].x = (short) -tmp->frame_bw;
+ newBounding[1].y = (short) Scr->TitleHeight;
+ newBounding[1].width = (unsigned short) (tmp->attr.width + fbw2);
+ newBounding[1].height = (unsigned short) (tmp->attr.height + fbw2);
+ XShapeCombineRectangles(dpy, tmp->frame, ShapeBounding, 0, 0,
+ newBounding, 2, ShapeSet, YXBanded);
+ /* insides */
+ newClip[0].x = (short) (tmp->title_x + tmp->frame_bw);
+ newClip[0].y = 0;
+ newClip[0].width = (unsigned short) tmp->title_width;
+ newClip[0].height = (unsigned short) Scr->TitleHeight;
+ newClip[1].x = 0;
+ newClip[1].y = (short) tmp->title_height;
+ newClip[1].width = (unsigned short) tmp->attr.width;
+ newClip[1].height = (unsigned short) tmp->attr.height;
+ XShapeCombineRectangles(dpy, tmp->frame, ShapeClip, 0, 0,
+ newClip, 2, ShapeSet, YXBanded);
+ }
+ else {
+ (void) XShapeCombineMask(dpy, tmp->frame, ShapeBounding, 0, 0,
+ None, ShapeSet);
+ (void) XShapeCombineMask(dpy, tmp->frame, ShapeClip, 0, 0,
+ None, ShapeSet);
+ }
}
}
diff --git a/src/resize.h b/src/resize.h
index e227ed6..5eb729e 100644
--- a/src/resize.h
+++ b/src/resize.h
@@ -49,7 +49,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/**********************************************************************
*
* resize function externs
@@ -61,18 +60,19 @@ in this Software without prior written authorization from The Open Group.
#ifndef _RESIZE_
#define _RESIZE_
-extern void AddEndResize ( TwmWindow *tmp_win );
-extern void AddStartResize ( TwmWindow *tmp_win, int x, int y, int w, int h );
-extern void ConstrainSize ( TwmWindow *tmp_win, int *widthp, int *heightp );
-extern void DoResize ( int x_root, int y_root, TwmWindow *tmp_win );
-extern void EndResize ( void );
-extern void fullzoom ( TwmWindow *tmp_win, int flag );
-extern void MenuDoResize ( int x_root, int y_root, TwmWindow *tmp_win );
-extern void MenuEndResize ( TwmWindow *tmp_win );
-extern void MenuStartResize ( TwmWindow *tmp_win, int x, int y, int w, int h );
-extern void SetFrameShape ( TwmWindow *tmp );
-extern void SetupFrame ( TwmWindow *tmp_win, int x, int y, int w, int h, int bw, Bool sendEvent );
-extern void SetupWindow ( TwmWindow *tmp_win, int x, int y, int w, int h, int bw );
-extern void StartResize ( XEvent *evp, TwmWindow *tmp_win, Bool fromtitlebar );
+extern void AddEndResize(TwmWindow *tmp_win);
+extern void AddStartResize(TwmWindow *tmp_win, int x, int y, int w, int h);
+extern void ConstrainSize(TwmWindow *tmp_win, int *widthp, int *heightp);
+extern void DoResize(int x_root, int y_root, TwmWindow *tmp_win);
+extern void EndResize(void);
+extern void fullzoom(TwmWindow *tmp_win, int flag);
+extern void MenuDoResize(int x_root, int y_root, TwmWindow *tmp_win);
+extern void MenuEndResize(TwmWindow *tmp_win);
+extern void MenuStartResize(TwmWindow *tmp_win, int x, int y, int w, int h);
+extern void SetFrameShape(TwmWindow *tmp);
+extern void SetupFrame(TwmWindow *tmp_win, int x, int y, int w, int h, int bw,
+ Bool sendEvent);
+extern void SetupWindow(TwmWindow *tmp_win, int x, int y, int w, int h, int bw);
+extern void StartResize(XEvent *evp, TwmWindow *tmp_win, Bool fromtitlebar);
-#endif /* _RESIZE_ */
+#endif /* _RESIZE_ */
diff --git a/src/screen.h b/src/screen.h
index 2798137..583597a 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -27,7 +27,7 @@ in this Software without prior written authorization from The Open Group.
*
* twm per-screen data include file
*
- * 11-3-88 Dave Payne, Apple Computer File created
+ * 11-3-88 Dave Payne, Apple Computer File created
*
***********************************************************************/
@@ -42,10 +42,10 @@ in this Software without prior written authorization from The Open Group.
#include "iconmgr.h"
typedef struct _StdCmap {
- struct _StdCmap *next; /* next link in chain */
- Atom atom; /* property from which this came */
- int nmaps; /* number of maps below */
- XStandardColormap *maps; /* the actual maps */
+ struct _StdCmap *next; /* next link in chain */
+ Atom atom; /* property from which this came */
+ int nmaps; /* number of maps below */
+ XStandardColormap *maps; /* the actual maps */
} StdCmap;
#define SIZE_HINDENT 10
@@ -59,96 +59,95 @@ typedef struct _TitlebarPixmaps {
Pixmap delete;
} TitlebarPixmaps;
-typedef struct ScreenInfo
-{
- int screen; /* the default screen */
- int d_depth; /* copy of DefaultDepth(dpy, screen) */
- Visual *d_visual; /* copy of DefaultVisual(dpy, screen) */
- int Monochrome; /* is the display monochrome ? */
- int MyDisplayWidth; /* my copy of DisplayWidth(dpy, screen) */
- int MyDisplayHeight; /* my copy of DisplayHeight(dpy, screen) */
- int MaxWindowWidth; /* largest window to allow */
- int MaxWindowHeight; /* ditto */
+typedef struct ScreenInfo {
+ int screen; /* the default screen */
+ int d_depth; /* copy of DefaultDepth(dpy, screen) */
+ Visual *d_visual; /* copy of DefaultVisual(dpy, screen) */
+ int Monochrome; /* is the display monochrome ? */
+ int MyDisplayWidth; /* my copy of DisplayWidth(dpy, screen) */
+ int MyDisplayHeight; /* my copy of DisplayHeight(dpy, screen) */
+ int MaxWindowWidth; /* largest window to allow */
+ int MaxWindowHeight; /* ditto */
- TwmWindow TwmRoot; /* the head of the twm window list */
+ TwmWindow TwmRoot; /* the head of the twm window list */
- Window Root; /* the root window */
- Window SizeWindow; /* the resize dimensions window */
- Window InfoWindow; /* the information window */
+ Window Root; /* the root window */
+ Window SizeWindow; /* the resize dimensions window */
+ Window InfoWindow; /* the information window */
- name_list *Icons; /* list of icon pixmaps */
- TitlebarPixmaps tbpm; /* titlebar pixmaps */
- Pixmap UnknownPm; /* the unknown icon pixmap */
- Pixmap siconifyPm; /* the icon manager iconify pixmap */
- Pixmap pullPm; /* pull right menu icon */
- unsigned int pullW, pullH; /* size of pull right menu icon */
- Pixmap hilitePm; /* focus highlight window background */
- int hilite_pm_width, hilite_pm_height; /* cache the size */
+ name_list *Icons; /* list of icon pixmaps */
+ TitlebarPixmaps tbpm; /* titlebar pixmaps */
+ Pixmap UnknownPm; /* the unknown icon pixmap */
+ Pixmap siconifyPm; /* the icon manager iconify pixmap */
+ Pixmap pullPm; /* pull right menu icon */
+ unsigned int pullW, pullH; /* size of pull right menu icon */
+ Pixmap hilitePm; /* focus highlight window background */
+ int hilite_pm_width, hilite_pm_height; /* cache the size */
- MenuRoot *MenuList; /* head of the menu list */
- MenuRoot *LastMenu; /* the last menu (mostly unused?) */
- MenuRoot *Windows; /* the TwmWindows menu */
+ MenuRoot *MenuList; /* head of the menu list */
+ MenuRoot *LastMenu; /* the last menu (mostly unused?) */
+ MenuRoot *Windows; /* the TwmWindows menu */
- TwmWindow *Ring; /* one of the windows in window ring */
- TwmWindow *RingLeader; /* current winodw in ring */
+ TwmWindow *Ring; /* one of the windows in window ring */
+ TwmWindow *RingLeader; /* current winodw in ring */
- MouseButton Mouse[MAX_BUTTONS+1][NUM_CONTEXTS][MOD_SIZE];
+ MouseButton Mouse[MAX_BUTTONS + 1][NUM_CONTEXTS][MOD_SIZE];
MouseButton DefaultFunction;
MouseButton WindowFunction;
struct {
- Colormaps *cmaps; /* current list of colormap windows */
- int maxCmaps; /* maximum number of installed colormaps */
- unsigned long first_req; /* seq # for first XInstallColormap() req in
- pass thru loading a colortable list */
- int root_pushes; /* current push level to install root
- colormap windows */
- TwmWindow *pushed_window; /* saved window to install when pushes drops
- to zero */
+ Colormaps *cmaps; /* current list of colormap windows */
+ int maxCmaps; /* maximum number of installed colormaps */
+ unsigned long first_req; /* seq # for first XInstallColormap() req in
+ pass thru loading a colortable list */
+ int root_pushes; /* current push level to install root
+ colormap windows */
+ TwmWindow *pushed_window; /* saved window to install when pushes drops
+ to zero */
} cmapInfo;
struct {
- StdCmap *head, *tail; /* list of maps */
- StdCmap *mru; /* most recently used in list */
- int mruindex; /* index of mru in entry */
+ StdCmap *head, *tail; /* list of maps */
+ StdCmap *mru; /* most recently used in list */
+ int mruindex; /* index of mru in entry */
} StdCmapInfo;
struct {
- int nleft, nright; /* numbers of buttons in list */
- TitleButton *head; /* start of list */
- int border; /* button border */
- int pad; /* button-padding */
- int width; /* width of single button & border */
- int leftx; /* start of left buttons */
- int titlex; /* start of title string */
- int rightoff; /* offset back from right edge */
+ int nleft, nright; /* numbers of buttons in list */
+ TitleButton *head; /* start of list */
+ int border; /* button border */
+ int pad; /* button-padding */
+ int width; /* width of single button & border */
+ int leftx; /* start of left buttons */
+ int titlex; /* start of title string */
+ int rightoff; /* offset back from right edge */
} TBInfo;
- ColorPair BorderTileC; /* border tile colors */
- ColorPair TitleC; /* titlebar colors */
- ColorPair MenuC; /* menu colors */
- ColorPair MenuTitleC; /* menu title colors */
- ColorPair IconC; /* icon colors */
- ColorPair IconManagerC; /* icon manager colors */
- XColor PointerForeground; /* pointer foreground color */
- XColor PointerBackground; /* pointer background color */
- ColorPair DefaultC; /* default colors */
- Pixel BorderColor; /* color of window borders */
- Pixel MenuShadowColor; /* menu shadow color */
- Pixel MenuBorderColor; /* menu border color */
- Pixel IconBorderColor; /* icon border color */
- Pixel IconManagerHighlight; /* icon manager highlight */
+ ColorPair BorderTileC; /* border tile colors */
+ ColorPair TitleC; /* titlebar colors */
+ ColorPair MenuC; /* menu colors */
+ ColorPair MenuTitleC; /* menu title colors */
+ ColorPair IconC; /* icon colors */
+ ColorPair IconManagerC; /* icon manager colors */
+ XColor PointerForeground; /* pointer foreground color */
+ XColor PointerBackground; /* pointer background color */
+ ColorPair DefaultC; /* default colors */
+ Pixel BorderColor; /* color of window borders */
+ Pixel MenuShadowColor; /* menu shadow color */
+ Pixel MenuBorderColor; /* menu border color */
+ Pixel IconBorderColor; /* icon border color */
+ Pixel IconManagerHighlight; /* icon manager highlight */
- Cursor TitleCursor; /* title bar cursor */
- Cursor FrameCursor; /* frame cursor */
- Cursor IconCursor; /* icon cursor */
- Cursor IconMgrCursor; /* icon manager cursor */
- Cursor ButtonCursor; /* title bar button cursor */
- Cursor MoveCursor; /* move cursor */
- Cursor ResizeCursor; /* resize cursor */
- Cursor WaitCursor; /* wait a while cursor */
- Cursor MenuCursor; /* menu cursor */
- Cursor SelectCursor; /* dot cursor for f.move, etc. from menus */
- Cursor DestroyCursor; /* skull and cross bones, f.destroy */
+ Cursor TitleCursor; /* title bar cursor */
+ Cursor FrameCursor; /* frame cursor */
+ Cursor IconCursor; /* icon cursor */
+ Cursor IconMgrCursor; /* icon manager cursor */
+ Cursor ButtonCursor; /* title bar button cursor */
+ Cursor MoveCursor; /* move cursor */
+ Cursor ResizeCursor; /* resize cursor */
+ Cursor WaitCursor; /* wait a while cursor */
+ Cursor MenuCursor; /* menu cursor */
+ Cursor SelectCursor; /* dot cursor for f.move, etc. from menus */
+ Cursor DestroyCursor; /* skull and cross bones, f.destroy */
name_list *BorderColorL;
name_list *IconBorderColorL;
@@ -161,93 +160,93 @@ typedef struct ScreenInfo
name_list *IconManagerFL;
name_list *IconManagerBL;
name_list *IconMgrs;
- name_list *NoTitle; /* list of window names with no title bar */
- name_list *MakeTitle; /* list of window names with title bar */
- name_list *AutoRaise; /* list of window names to auto-raise */
- name_list *IconNames; /* list of window names and icon names */
- name_list *NoHighlight; /* list of windows to not highlight */
- name_list *NoStackModeL; /* windows to ignore stack mode requests */
- name_list *NoTitleHighlight;/* list of windows to not highlight the TB*/
- name_list *DontIconify; /* don't iconify by unmapping */
- name_list *IconMgrNoShow; /* don't show in the icon manager */
- name_list *IconMgrShow; /* show in the icon manager */
- name_list *IconifyByUn; /* windows to iconify by unmapping */
- name_list *StartIconified; /* windows to start iconic */
- name_list *IconManagerHighlightL; /* icon manager highlight colors */
- name_list *SqueezeTitleL; /* windows of which to squeeze title */
- name_list *DontSqueezeTitleL; /* windows of which not to squeeze */
- name_list *WindowRingL; /* windows in ring */
- name_list *WarpCursorL; /* windows to warp cursor to on deiconify */
+ name_list *NoTitle; /* list of window names with no title bar */
+ name_list *MakeTitle; /* list of window names with title bar */
+ name_list *AutoRaise; /* list of window names to auto-raise */
+ name_list *IconNames; /* list of window names and icon names */
+ name_list *NoHighlight; /* list of windows to not highlight */
+ name_list *NoStackModeL; /* windows to ignore stack mode requests */
+ name_list *NoTitleHighlight; /* list of windows to not highlight the TB */
+ name_list *DontIconify; /* don't iconify by unmapping */
+ name_list *IconMgrNoShow; /* don't show in the icon manager */
+ name_list *IconMgrShow; /* show in the icon manager */
+ name_list *IconifyByUn; /* windows to iconify by unmapping */
+ name_list *StartIconified; /* windows to start iconic */
+ name_list *IconManagerHighlightL; /* icon manager highlight colors */
+ name_list *SqueezeTitleL; /* windows of which to squeeze title */
+ name_list *DontSqueezeTitleL; /* windows of which not to squeeze */
+ name_list *WindowRingL; /* windows in ring */
+ name_list *WarpCursorL; /* windows to warp cursor to on deiconify */
- GC NormalGC; /* normal GC for everything */
- GC MenuGC; /* gc for menus */
- GC DrawGC; /* GC to draw lines for move and resize */
+ GC NormalGC; /* normal GC for everything */
+ GC MenuGC; /* gc for menus */
+ GC DrawGC; /* GC to draw lines for move and resize */
unsigned long Black;
unsigned long White;
- unsigned long XORvalue; /* number to use when drawing xor'ed */
- MyFont TitleBarFont; /* title bar font structure */
- MyFont MenuFont; /* menu font structure */
- MyFont IconFont; /* icon font structure */
- MyFont SizeFont; /* resize font structure */
- MyFont IconManagerFont; /* window list font structure */
+ unsigned long XORvalue; /* number to use when drawing xor'ed */
+ MyFont TitleBarFont; /* title bar font structure */
+ MyFont MenuFont; /* menu font structure */
+ MyFont IconFont; /* icon font structure */
+ MyFont SizeFont; /* resize font structure */
+ MyFont IconManagerFont; /* window list font structure */
MyFont DefaultFont;
- IconMgr iconmgr; /* default icon manager */
- struct IconRegion *FirstRegion; /* pointer to icon regions */
- struct IconRegion *LastRegion; /* pointer to the last icon region */
- char *IconDirectory; /* icon directory to search */
- int SizeStringOffset; /* x offset in size window for drawing */
- int SizeStringWidth; /* minimum width of size window */
- int BorderWidth; /* border width of twm windows */
- int IconBorderWidth; /* border width of icon windows */
- int MenuBorderWidth; /* border width of twm menus */
- int UnknownWidth; /* width of the unknown icon */
- int UnknownHeight; /* height of the unknown icon */
- int TitleHeight; /* height of the title bar window */
- TwmWindow *Focus; /* the twm window that has focus */
- int EntryHeight; /* menu entry height */
- int FramePadding; /* distance between decorations and border */
- int TitlePadding; /* distance between items in titlebar */
- int ButtonIndent; /* amount to shrink buttons on each side */
- int NumAutoRaises; /* number of autoraise windows on screen */
- short NoDefaults; /* do not add in default UI stuff */
- short UsePPosition; /* what do with PPosition, see values below */
- short AutoRelativeResize; /* start resize relative to position in quad */
- short FocusRoot; /* is the input focus on the root ? */
- short WarpCursor; /* warp cursor on de-iconify ? */
- short ForceIcon; /* force the icon to the user specified */
- short NoGrabServer; /* don't do server grabs */
- short NoRaiseMove; /* don't raise window following move */
- short NoRaiseResize; /* don't raise window following resize */
- short NoRaiseDeicon; /* don't raise window on deiconify */
- short NoRaiseWarp; /* don't raise window on warp */
- short DontMoveOff; /* don't allow windows to be moved off */
- short DoZoom; /* zoom in and out of icons */
- short TitleFocus; /* focus on window in title bar ? */
- short NoTitlebar; /* put title bars on windows */
- short DecorateTransients; /* put title bars on transients */
- short IconifyByUnmapping; /* simply unmap windows when iconifying */
- short ShowIconManager; /* display the window list */
- short IconManagerDontShow; /* show nothing in the icon manager */
- short BackingStore; /* use backing store for menus */
- short SaveUnder; /* use save under's for menus */
- short RandomPlacement; /* randomly place windows that no give hints */
- short OpaqueMove; /* move the window rather than outline */
- short Highlight; /* should we highlight the window borders */
- short StackMode; /* should we honor stack mode requests */
- short TitleHighlight; /* should we highlight the titlebar */
- short MoveDelta; /* number of pixels before f.move starts */
- short ZoomCount; /* zoom outline count */
- short SortIconMgr; /* sort entries in the icon manager */
- short Shadow; /* show the menu shadow */
- short InterpolateMenuColors;/* make pretty menus */
- short NoIconManagers; /* Don't create any icon managers */
- short ClientBorderWidth; /* respect client window border width */
- short SqueezeTitle; /* make title as small as possible */
- short HaveFonts; /* set if fonts have been loaded */
- short FirstTime; /* first time we've read .twmrc */
- short CaseSensitive; /* be case-sensitive when sorting names */
- short WarpUnmapped; /* allow warping to unmapped windows */
+ IconMgr iconmgr; /* default icon manager */
+ struct IconRegion *FirstRegion; /* pointer to icon regions */
+ struct IconRegion *LastRegion; /* pointer to the last icon region */
+ char *IconDirectory; /* icon directory to search */
+ int SizeStringOffset; /* x offset in size window for drawing */
+ int SizeStringWidth; /* minimum width of size window */
+ int BorderWidth; /* border width of twm windows */
+ int IconBorderWidth; /* border width of icon windows */
+ int MenuBorderWidth; /* border width of twm menus */
+ int UnknownWidth; /* width of the unknown icon */
+ int UnknownHeight; /* height of the unknown icon */
+ int TitleHeight; /* height of the title bar window */
+ TwmWindow *Focus; /* the twm window that has focus */
+ int EntryHeight; /* menu entry height */
+ int FramePadding; /* distance between decorations and border */
+ int TitlePadding; /* distance between items in titlebar */
+ int ButtonIndent; /* amount to shrink buttons on each side */
+ int NumAutoRaises; /* number of autoraise windows on screen */
+ short NoDefaults; /* do not add in default UI stuff */
+ short UsePPosition; /* what do with PPosition, see values below */
+ short AutoRelativeResize; /* start resize relative to position in quad */
+ short FocusRoot; /* is the input focus on the root ? */
+ short WarpCursor; /* warp cursor on de-iconify ? */
+ short ForceIcon; /* force the icon to the user specified */
+ short NoGrabServer; /* don't do server grabs */
+ short NoRaiseMove; /* don't raise window following move */
+ short NoRaiseResize; /* don't raise window following resize */
+ short NoRaiseDeicon; /* don't raise window on deiconify */
+ short NoRaiseWarp; /* don't raise window on warp */
+ short DontMoveOff; /* don't allow windows to be moved off */
+ short DoZoom; /* zoom in and out of icons */
+ short TitleFocus; /* focus on window in title bar ? */
+ short NoTitlebar; /* put title bars on windows */
+ short DecorateTransients; /* put title bars on transients */
+ short IconifyByUnmapping; /* simply unmap windows when iconifying */
+ short ShowIconManager; /* display the window list */
+ short IconManagerDontShow; /* show nothing in the icon manager */
+ short BackingStore; /* use backing store for menus */
+ short SaveUnder; /* use save under's for menus */
+ short RandomPlacement; /* randomly place windows that no give hints */
+ short OpaqueMove; /* move the window rather than outline */
+ short Highlight; /* should we highlight the window borders */
+ short StackMode; /* should we honor stack mode requests */
+ short TitleHighlight; /* should we highlight the titlebar */
+ short MoveDelta; /* number of pixels before f.move starts */
+ short ZoomCount; /* zoom outline count */
+ short SortIconMgr; /* sort entries in the icon manager */
+ short Shadow; /* show the menu shadow */
+ short InterpolateMenuColors; /* make pretty menus */
+ short NoIconManagers; /* Don't create any icon managers */
+ short ClientBorderWidth; /* respect client window border width */
+ short SqueezeTitle; /* make title as small as possible */
+ short HaveFonts; /* set if fonts have been loaded */
+ short FirstTime; /* first time we've read .twmrc */
+ short CaseSensitive; /* be case-sensitive when sorting names */
+ short WarpUnmapped; /* allow warping to unmapped windows */
FuncKey FuncKeyRoot;
} ScreenInfo;
@@ -264,4 +263,4 @@ extern int FirstScreen;
/* may eventually want an option for having the PPosition be the initial
location for the drag lines */
-#endif /* _SCREEN_ */
+#endif /* _SCREEN_ */
diff --git a/src/session.c b/src/session.c
index a908efc..ed8bb33 100644
--- a/src/session.c
+++ b/src/session.c
@@ -26,7 +26,7 @@ Author: Ralph Mor, X Consortium
******************************************************************************/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <X11/Xos.h>
@@ -39,7 +39,7 @@ Author: Ralph Mor, X Consortium
#include <limits.h>
#undef _POSIX_SOURCE
#endif
-#endif /* X_NOT_POSIX */
+#endif /* X_NOT_POSIX */
#ifndef PATH_MAX
#include <sys/param.h>
#ifndef PATH_MAX
@@ -49,7 +49,7 @@ Author: Ralph Mor, X Consortium
#define PATH_MAX 1024
#endif
#endif
-#endif /* PATH_MAX */
+#endif /* PATH_MAX */
#ifdef HAVE_MKSTEMP
#include <unistd.h>
#endif
@@ -71,14 +71,13 @@ static Bool sent_save_done = 0;
#define SAVEFILE_VERSION 2
#ifndef HAVE_MKSTEMP
-static char *unique_filename ( const char *path, const char *prefix );
+static char *unique_filename(const char *path, const char *prefix);
#else
-static char *unique_filename ( const char *path, const char *prefix, int *pFd );
+static char *unique_filename(const char *path, const char *prefix, int *pFd);
#endif
-
static char *
-GetClientID (Window window)
+GetClientID(Window window)
{
char *client_id = NULL;
Window client_leader;
@@ -89,310 +88,285 @@ GetClientID (Window window)
unsigned long bytes_after;
unsigned char *prop = NULL;
- if (XGetWindowProperty (dpy, window, _XA_WM_CLIENT_LEADER,
- 0L, 1L, False, AnyPropertyType, &actual_type, &actual_format,
- &nitems, &bytes_after, &prop) == Success)
- {
- if (actual_type == XA_WINDOW && actual_format == 32 &&
- nitems == 1 && bytes_after == 0)
- {
- client_leader = *((Window *) prop);
-
- if (XGetTextProperty (dpy, client_leader, &tp, _XA_SM_CLIENT_ID))
- {
- if (tp.encoding == XA_STRING &&
- tp.format == 8 && tp.nitems != 0)
- client_id = (char *) tp.value;
- }
- }
-
- if (prop)
- XFree (prop);
+ if (XGetWindowProperty(dpy, window, _XA_WM_CLIENT_LEADER,
+ 0L, 1L, False, AnyPropertyType, &actual_type,
+ &actual_format, &nitems, &bytes_after,
+ &prop) == Success) {
+ if (actual_type == XA_WINDOW && actual_format == 32 && nitems == 1 &&
+ bytes_after == 0) {
+ client_leader = *((Window *) prop);
+
+ if (XGetTextProperty(dpy, client_leader, &tp, _XA_SM_CLIENT_ID)) {
+ if (tp.encoding == XA_STRING &&
+ tp.format == 8 && tp.nitems != 0)
+ client_id = (char *) tp.value;
+ }
+ }
+
+ if (prop)
+ XFree(prop);
}
return client_id;
}
-
-
static char *
-GetWindowRole (Window window)
+GetWindowRole(Window window)
{
XTextProperty tp;
- if (XGetTextProperty (dpy, window, &tp, _XA_WM_WINDOW_ROLE))
- {
- if (tp.encoding == XA_STRING && tp.format == 8 && tp.nitems != 0)
- return ((char *) tp.value);
+ if (XGetTextProperty(dpy, window, &tp, _XA_WM_WINDOW_ROLE)) {
+ if (tp.encoding == XA_STRING && tp.format == 8 && tp.nitems != 0)
+ return ((char *) tp.value);
}
return NULL;
}
-
-
static int
-write_byte (FILE *file, unsigned char b)
+write_byte(FILE *file, unsigned char b)
{
- if (fwrite ((char *) &b, 1, 1, file) != 1)
- return 0;
+ if (fwrite((char *) &b, 1, 1, file) != 1)
+ return 0;
return 1;
}
-
static int
-write_ushort (FILE *file, unsigned short s)
+write_ushort(FILE *file, unsigned short s)
{
- unsigned char file_short[2];
+ unsigned char file_short[2];
- file_short[0] = (unsigned char)((s & (unsigned)0xff00) >> 8);
- file_short[1] = (unsigned char)(s & 0xff);
- if (fwrite ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
- return 0;
+ file_short[0] = (unsigned char) ((s & (unsigned) 0xff00) >> 8);
+ file_short[1] = (unsigned char) (s & 0xff);
+ if (fwrite((char *) file_short, (int) sizeof(file_short), 1, file) != 1)
+ return 0;
return 1;
}
-
static int
-write_short (FILE *file, short s)
+write_short(FILE *file, short s)
{
- unsigned char file_short[2];
+ unsigned char file_short[2];
- file_short[0] = (unsigned char)(((unsigned)s & (unsigned)0xff00) >> 8);
- file_short[1] = (unsigned char)(s & 0xff);
- if (fwrite ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
- return 0;
+ file_short[0] = (unsigned char) (((unsigned) s & (unsigned) 0xff00) >> 8);
+ file_short[1] = (unsigned char) (s & 0xff);
+ if (fwrite((char *) file_short, (int) sizeof(file_short), 1, file) != 1)
+ return 0;
return 1;
}
-
static int
-write_counted_string (FILE *file, char *string)
+write_counted_string(FILE *file, char *string)
{
- if (string)
- {
- unsigned char count = (unsigned char)strlen (string);
-
- if (write_byte (file, count) == 0)
- return 0;
- if (fwrite (string, (int) sizeof (char), (int) count, file) != count)
- return 0;
+ if (string) {
+ unsigned char count = (unsigned char) strlen(string);
+
+ if (write_byte(file, count) == 0)
+ return 0;
+ if (fwrite(string, (int) sizeof(char), (int) count, file) != count)
+ return 0;
}
- else
- {
- if (write_byte (file, 0) == 0)
- return 0;
+ else {
+ if (write_byte(file, 0) == 0)
+ return 0;
}
return 1;
}
-
-
static int
-read_byte (FILE *file, unsigned char *bp)
+read_byte(FILE *file, unsigned char *bp)
{
- if (fread ((char *) bp, 1, 1, file) != 1)
- return 0;
+ if (fread((char *) bp, 1, 1, file) != 1)
+ return 0;
return 1;
}
-
static int
-read_ushort (FILE *file, unsigned short *shortp)
+read_ushort(FILE *file, unsigned short *shortp)
{
- unsigned char file_short[2];
+ unsigned char file_short[2];
- if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
- return 0;
- *shortp = (unsigned short)(file_short[0] * 256 + file_short[1]);
+ if (fread((char *) file_short, (int) sizeof(file_short), 1, file) != 1)
+ return 0;
+ *shortp = (unsigned short) (file_short[0] * 256 + file_short[1]);
return 1;
}
-
static int
-read_short (FILE *file, short *shortp)
+read_short(FILE *file, short *shortp)
{
- unsigned char file_short[2];
+ unsigned char file_short[2];
- if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1)
- return 0;
- *shortp = (short)(file_short[0] * 256 + file_short[1]);
+ if (fread((char *) file_short, (int) sizeof(file_short), 1, file) != 1)
+ return 0;
+ *shortp = (short) (file_short[0] * 256 + file_short[1]);
return 1;
}
-
static int
-read_counted_string (FILE *file, char **stringp)
+read_counted_string(FILE *file, char **stringp)
{
- unsigned char len;
- char *data;
+ unsigned char len;
+ char *data;
- if (read_byte (file, &len) == 0)
- return 0;
+ if (read_byte(file, &len) == 0)
+ return 0;
if (len == 0) {
- data = 0;
- } else {
- data = malloc ((unsigned) len + 1);
- if (!data)
- return 0;
- if (fread (data, (int) sizeof (char), (int) len, file) != len) {
- free (data);
- return 0;
- }
- data[len] = '\0';
+ data = 0;
+ }
+ else {
+ data = malloc((unsigned) len + 1);
+ if (!data)
+ return 0;
+ if (fread(data, (int) sizeof(char), (int) len, file) != len) {
+ free(data);
+ return 0;
+ }
+ data[len] = '\0';
}
*stringp = data;
return 1;
}
-
-
/*
* An entry in the saved window config file looks like this:
*
- * FIELD BYTES
+ * FIELD BYTES
* ----- ----
- * SM_CLIENT_ID ID len 1 (may be 0)
- * SM_CLIENT_ID LIST of bytes (may be NULL)
+ * SM_CLIENT_ID ID len 1 (may be 0)
+ * SM_CLIENT_ID LIST of bytes (may be NULL)
*
- * WM_WINDOW_ROLE length 1 (may be 0)
- * WM_WINDOW_ROLE LIST of bytes (may be NULL)
+ * WM_WINDOW_ROLE length 1 (may be 0)
+ * WM_WINDOW_ROLE LIST of bytes (may be NULL)
*
* if no WM_WINDOW_ROLE (length = 0)
*
- * WM_CLASS "res name" length 1
- * WM_CLASS "res name" LIST of bytes
+ * WM_CLASS "res name" length 1
+ * WM_CLASS "res name" LIST of bytes
* WM_CLASS "res class" length 1
* WM_CLASS "res class" LIST of bytes
- * WM_NAME length 1 (0 if name changed)
- * WM_NAME LIST of bytes
- * WM_COMMAND arg count 1 (0 if no SM_CLIENT_ID)
+ * WM_NAME length 1 (0 if name changed)
+ * WM_NAME LIST of bytes
+ * WM_COMMAND arg count 1 (0 if no SM_CLIENT_ID)
* For each arg in WM_COMMAND
- * arg length 1
- * arg LIST of bytes
+ * arg length 1
+ * arg LIST of bytes
*
- * Iconified bool 1
- * Icon info present bool 1
+ * Iconified bool 1
+ * Icon info present bool 1
*
* if icon info present
- * icon x 2
- * icon y 2
+ * icon x 2
+ * icon y 2
*
- * Geom x 2
- * Geom y 2
- * Geom width 2
- * Geom height 2
+ * Geom x 2
+ * Geom y 2
+ * Geom width 2
+ * Geom height 2
*
- * Width ever changed by user 1
- * Height ever changed by user 1
+ * Width ever changed by user 1
+ * Height ever changed by user 1
*/
static int
-WriteWinConfigEntry (FILE *configFile, TwmWindow *theWindow,
- char *clientId, char *windowRole)
+WriteWinConfigEntry(FILE *configFile, TwmWindow *theWindow,
+ char *clientId, char *windowRole)
{
char **wm_command;
int wm_command_count, i;
- if (!write_counted_string (configFile, clientId))
- return 0;
-
- if (!write_counted_string (configFile, windowRole))
- return 0;
-
- if (!windowRole)
- {
- if (!write_counted_string (configFile, theWindow->class.res_name))
- return 0;
- if (!write_counted_string (configFile, theWindow->class.res_class))
- return 0;
- if (theWindow->nameChanged)
- {
- /*
- * If WM_NAME changed on this window, we can't use it as
- * a criteria for looking up window configurations. See the
- * longer explanation in the GetWindowConfig() function below.
- */
-
- if (!write_counted_string (configFile, NULL))
- return 0;
- }
- else
- {
- if (!write_counted_string (configFile, theWindow->name))
- return 0;
- }
-
- wm_command = NULL;
- wm_command_count = 0;
- XGetCommand (dpy, theWindow->w, &wm_command, &wm_command_count);
-
- if (clientId || !wm_command || wm_command_count == 0)
- {
- if (!write_byte (configFile, 0))
- return 0;
- }
- else
- {
- if (!write_byte (configFile, (unsigned char) wm_command_count))
- return 0;
- for (i = 0; i < wm_command_count; i++)
- if (!write_counted_string (configFile, wm_command[i]))
- return 0;
- XFreeStringList (wm_command);
- }
+ if (!write_counted_string(configFile, clientId))
+ return 0;
+
+ if (!write_counted_string(configFile, windowRole))
+ return 0;
+
+ if (!windowRole) {
+ if (!write_counted_string(configFile, theWindow->class.res_name))
+ return 0;
+ if (!write_counted_string(configFile, theWindow->class.res_class))
+ return 0;
+ if (theWindow->nameChanged) {
+ /*
+ * If WM_NAME changed on this window, we can't use it as
+ * a criteria for looking up window configurations. See the
+ * longer explanation in the GetWindowConfig() function below.
+ */
+
+ if (!write_counted_string(configFile, NULL))
+ return 0;
+ }
+ else {
+ if (!write_counted_string(configFile, theWindow->name))
+ return 0;
+ }
+
+ wm_command = NULL;
+ wm_command_count = 0;
+ XGetCommand(dpy, theWindow->w, &wm_command, &wm_command_count);
+
+ if (clientId || !wm_command || wm_command_count == 0) {
+ if (!write_byte(configFile, 0))
+ return 0;
+ }
+ else {
+ if (!write_byte(configFile, (unsigned char) wm_command_count))
+ return 0;
+ for (i = 0; i < wm_command_count; i++)
+ if (!write_counted_string(configFile, wm_command[i]))
+ return 0;
+ XFreeStringList(wm_command);
+ }
}
- if (!write_byte (configFile, theWindow->icon ? 1 : 0)) /* iconified */
- return 0;
+ if (!write_byte(configFile, theWindow->icon ? 1 : 0)) /* iconified */
+ return 0;
- if (!write_byte (configFile, theWindow->icon_w ? 1 : 0)) /* icon exists */
- return 0;
+ if (!write_byte(configFile, theWindow->icon_w ? 1 : 0)) /* icon exists */
+ return 0;
- if (theWindow->icon_w)
- {
- int icon_x, icon_y;
+ if (theWindow->icon_w) {
+ int icon_x, icon_y;
- XGetGeometry (dpy, theWindow->icon_w, &JunkRoot, &icon_x,
- &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth);
+ XGetGeometry(dpy, theWindow->icon_w, &JunkRoot, &icon_x,
+ &icon_y, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth);
- if (!write_short (configFile, (short) icon_x))
- return 0;
- if (!write_short (configFile, (short) icon_y))
- return 0;
+ if (!write_short(configFile, (short) icon_x))
+ return 0;
+ if (!write_short(configFile, (short) icon_y))
+ return 0;
}
- if (!write_short (configFile, (short) theWindow->frame_x))
- return 0;
- if (!write_short (configFile, (short) theWindow->frame_y))
- return 0;
- if (!write_ushort (configFile, (unsigned short) theWindow->attr.width))
- return 0;
- if (!write_ushort (configFile, (unsigned short) theWindow->attr.height))
- return 0;
+ if (!write_short(configFile, (short) theWindow->frame_x))
+ return 0;
+ if (!write_short(configFile, (short) theWindow->frame_y))
+ return 0;
+ if (!write_ushort(configFile, (unsigned short) theWindow->attr.width))
+ return 0;
+ if (!write_ushort(configFile, (unsigned short) theWindow->attr.height))
+ return 0;
- if (!write_byte (configFile, theWindow->widthEverChangedByUser ? 1 : 0))
- return 0;
+ if (!write_byte(configFile, theWindow->widthEverChangedByUser ? 1 : 0))
+ return 0;
- if (!write_byte (configFile, theWindow->heightEverChangedByUser ? 1 : 0))
- return 0;
+ if (!write_byte(configFile, theWindow->heightEverChangedByUser ? 1 : 0))
+ return 0;
return 1;
}
-
static int
-ReadWinConfigEntry (FILE *configFile, unsigned short version,
- TWMWinConfigEntry **pentry)
+ReadWinConfigEntry(FILE *configFile, unsigned short version,
+ TWMWinConfigEntry **pentry)
{
TWMWinConfigEntry *entry;
unsigned char byte;
int i;
- *pentry = entry = malloc (sizeof (TWMWinConfigEntry));
+ *pentry = entry = malloc(sizeof(TWMWinConfigEntry));
if (!*pentry)
- return 0;
+ return 0;
entry->tag = 0;
entry->client_id = NULL;
@@ -403,156 +377,142 @@ ReadWinConfigEntry (FILE *configFile, unsigned short version,
entry->wm_command = NULL;
entry->wm_command_count = 0;
- if (!read_counted_string (configFile, &entry->client_id))
- goto give_up;
-
- if (!read_counted_string (configFile, &entry->window_role))
- goto give_up;
-
- if (!entry->window_role)
- {
- if (!read_counted_string (configFile, &entry->class.res_name))
- goto give_up;
- if (!read_counted_string (configFile, &entry->class.res_class))
- goto give_up;
- if (!read_counted_string (configFile, &entry->wm_name))
- goto give_up;
-
- if (!read_byte (configFile, &byte))
- goto give_up;
- entry->wm_command_count = byte;
-
- if (entry->wm_command_count == 0)
- entry->wm_command = NULL;
- else
- {
- entry->wm_command = malloc ((size_t)entry->wm_command_count *
- sizeof (char *));
-
- if (!entry->wm_command)
- goto give_up;
-
- for (i = 0; i < entry->wm_command_count; i++)
- if (!read_counted_string (configFile, &entry->wm_command[i]))
- goto give_up;
- }
+ if (!read_counted_string(configFile, &entry->client_id))
+ goto give_up;
+
+ if (!read_counted_string(configFile, &entry->window_role))
+ goto give_up;
+
+ if (!entry->window_role) {
+ if (!read_counted_string(configFile, &entry->class.res_name))
+ goto give_up;
+ if (!read_counted_string(configFile, &entry->class.res_class))
+ goto give_up;
+ if (!read_counted_string(configFile, &entry->wm_name))
+ goto give_up;
+
+ if (!read_byte(configFile, &byte))
+ goto give_up;
+ entry->wm_command_count = byte;
+
+ if (entry->wm_command_count == 0)
+ entry->wm_command = NULL;
+ else {
+ entry->wm_command = malloc((size_t) entry->wm_command_count *
+ sizeof(char *));
+
+ if (!entry->wm_command)
+ goto give_up;
+
+ for (i = 0; i < entry->wm_command_count; i++)
+ if (!read_counted_string(configFile, &entry->wm_command[i]))
+ goto give_up;
+ }
}
- if (!read_byte (configFile, &byte))
- goto give_up;
+ if (!read_byte(configFile, &byte))
+ goto give_up;
entry->iconified = byte;
- if (!read_byte (configFile, &byte))
- goto give_up;
+ if (!read_byte(configFile, &byte))
+ goto give_up;
entry->icon_info_present = byte;
- if (entry->icon_info_present)
- {
- if (!read_short (configFile, (short *) &entry->icon_x))
- goto give_up;
- if (!read_short (configFile, (short *) &entry->icon_y))
- goto give_up;
+ if (entry->icon_info_present) {
+ if (!read_short(configFile, (short *) &entry->icon_x))
+ goto give_up;
+ if (!read_short(configFile, (short *) &entry->icon_y))
+ goto give_up;
}
- if (!read_short (configFile, (short *) &entry->x))
- goto give_up;
- if (!read_short (configFile, (short *) &entry->y))
- goto give_up;
- if (!read_ushort (configFile, &entry->width))
- goto give_up;
- if (!read_ushort (configFile, &entry->height))
- goto give_up;
-
- if (version > 1)
- {
- if (!read_byte (configFile, &byte))
- goto give_up;
- entry->width_ever_changed_by_user = byte;
-
- if (!read_byte (configFile, &byte))
- goto give_up;
- entry->height_ever_changed_by_user = byte;
+ if (!read_short(configFile, (short *) &entry->x))
+ goto give_up;
+ if (!read_short(configFile, (short *) &entry->y))
+ goto give_up;
+ if (!read_ushort(configFile, &entry->width))
+ goto give_up;
+ if (!read_ushort(configFile, &entry->height))
+ goto give_up;
+
+ if (version > 1) {
+ if (!read_byte(configFile, &byte))
+ goto give_up;
+ entry->width_ever_changed_by_user = byte;
+
+ if (!read_byte(configFile, &byte))
+ goto give_up;
+ entry->height_ever_changed_by_user = byte;
}
- else
- {
- entry->width_ever_changed_by_user = False;
- entry->height_ever_changed_by_user = False;
+ else {
+ entry->width_ever_changed_by_user = False;
+ entry->height_ever_changed_by_user = False;
}
return 1;
-give_up:
+ give_up:
if (entry->client_id)
- free (entry->client_id);
+ free(entry->client_id);
if (entry->window_role)
- free (entry->window_role);
+ free(entry->window_role);
if (entry->class.res_name)
- free (entry->class.res_name);
+ free(entry->class.res_name);
if (entry->class.res_class)
- free (entry->class.res_class);
+ free(entry->class.res_class);
if (entry->wm_name)
- free (entry->wm_name);
- if (entry->wm_command_count && entry->wm_command)
- {
- for (i = 0; i < entry->wm_command_count; i++)
- if (entry->wm_command[i])
- free (entry->wm_command[i]);
+ free(entry->wm_name);
+ if (entry->wm_command_count && entry->wm_command) {
+ for (i = 0; i < entry->wm_command_count; i++)
+ if (entry->wm_command[i])
+ free(entry->wm_command[i]);
}
if (entry->wm_command)
- free (entry->wm_command);
+ free(entry->wm_command);
- free (entry);
+ free(entry);
*pentry = NULL;
return 0;
}
-
void
-ReadWinConfigFile (char *filename)
+ReadWinConfigFile(char *filename)
{
FILE *configFile;
TWMWinConfigEntry *entry;
int done = 0;
unsigned short version = 0;
- configFile = fopen (filename, "rb");
+ configFile = fopen(filename, "rb");
if (!configFile)
- return;
+ return;
- if (!read_ushort (configFile, &version) ||
- version > SAVEFILE_VERSION)
- {
- done = 1;
+ if (!read_ushort(configFile, &version) || version > SAVEFILE_VERSION) {
+ done = 1;
}
- while (!done)
- {
- if (ReadWinConfigEntry (configFile, version, &entry))
- {
- entry->next = winConfigHead;
- winConfigHead = entry;
- }
- else
- done = 1;
+ while (!done) {
+ if (ReadWinConfigEntry(configFile, version, &entry)) {
+ entry->next = winConfigHead;
+ winConfigHead = entry;
+ }
+ else
+ done = 1;
}
- fclose (configFile);
+ fclose(configFile);
}
-
-
int
-GetWindowConfig (
- TwmWindow *theWindow,
- short *x, short *y,
- unsigned short *width, unsigned short *height,
- Bool *iconified,
- Bool *icon_info_present,
- short *icon_x, short *icon_y,
- Bool *width_ever_changed_by_user,
- Bool *height_ever_changed_by_user)
+GetWindowConfig(TwmWindow *theWindow,
+ short *x, short *y,
+ unsigned short *width, unsigned short *height,
+ Bool *iconified,
+ Bool *icon_info_present,
+ short *icon_x, short *icon_y,
+ Bool *width_ever_changed_by_user,
+ Bool *height_ever_changed_by_user)
{
char *clientId, *windowRole;
TWMWinConfigEntry *ptr;
@@ -561,166 +521,146 @@ GetWindowConfig (
ptr = winConfigHead;
if (!ptr)
- return 0;
-
- clientId = GetClientID (theWindow->w);
- windowRole = GetWindowRole (theWindow->w);
-
- while (ptr && !found)
- {
- int client_id_match = (!clientId && !ptr->client_id) ||
- (clientId && ptr->client_id &&
- strcmp (clientId, ptr->client_id) == 0);
-
- if (!ptr->tag && client_id_match)
- {
- if (windowRole || ptr->window_role)
- {
- found = (windowRole && ptr->window_role &&
- strcmp (windowRole, ptr->window_role) == 0);
- }
- else
- {
- /*
- * Compare WM_CLASS + only compare WM_NAME if the
- * WM_NAME in the saved file is non-NULL. If the
- * WM_NAME in the saved file is NULL, this means that
- * the client changed the value of WM_NAME during the
- * session, and we can not use it as a criteria for
- * our search. For example, with xmh, at save time
- * the window name might be "xmh: folderY". However,
- * if xmh does not properly restore state when it is
- * restarted, the initial window name might be
- * "xmh: folderX". This would cause the window manager
- * to fail in finding the saved window configuration.
- * The best we can do is ignore WM_NAME if its value
- * changed in the previous session.
- */
-
- if (strcmp (theWindow->class.res_name,
- ptr->class.res_name) == 0 &&
- strcmp (theWindow->class.res_class,
- ptr->class.res_class) == 0 &&
- (ptr->wm_name == NULL ||
- strcmp (theWindow->name, ptr->wm_name) == 0))
- {
- if (clientId)
- {
- /*
- * If a client ID was present, we should not check
- * WM_COMMAND because Xt will put a -xtsessionID arg
- * on the command line.
- */
-
- found = 1;
- }
- else
- {
- /*
- * For non-XSMP clients, also check WM_COMMAND.
- */
-
- char **wm_command = NULL;
- int wm_command_count = 0, i;
-
- XGetCommand (dpy, theWindow->w,
- &wm_command, &wm_command_count);
-
- if (wm_command_count == ptr->wm_command_count)
- {
- for (i = 0; i < wm_command_count; i++)
- if (strcmp (wm_command[i],
- ptr->wm_command[i]) != 0)
- break;
-
- if (i == wm_command_count)
- found = 1;
- }
- }
- }
- }
- }
-
- if (!found)
- ptr = ptr->next;
+ return 0;
+
+ clientId = GetClientID(theWindow->w);
+ windowRole = GetWindowRole(theWindow->w);
+
+ while (ptr && !found) {
+ int client_id_match = (!clientId && !ptr->client_id) ||
+ (clientId && ptr->client_id &&
+ strcmp(clientId, ptr->client_id) == 0);
+
+ if (!ptr->tag && client_id_match) {
+ if (windowRole || ptr->window_role) {
+ found = (windowRole && ptr->window_role &&
+ strcmp(windowRole, ptr->window_role) == 0);
+ }
+ else {
+ /*
+ * Compare WM_CLASS + only compare WM_NAME if the
+ * WM_NAME in the saved file is non-NULL. If the
+ * WM_NAME in the saved file is NULL, this means that
+ * the client changed the value of WM_NAME during the
+ * session, and we can not use it as a criteria for
+ * our search. For example, with xmh, at save time
+ * the window name might be "xmh: folderY". However,
+ * if xmh does not properly restore state when it is
+ * restarted, the initial window name might be
+ * "xmh: folderX". This would cause the window manager
+ * to fail in finding the saved window configuration.
+ * The best we can do is ignore WM_NAME if its value
+ * changed in the previous session.
+ */
+
+ if (strcmp(theWindow->class.res_name,
+ ptr->class.res_name) == 0 &&
+ strcmp(theWindow->class.res_class,
+ ptr->class.res_class) == 0 &&
+ (ptr->wm_name == NULL ||
+ strcmp(theWindow->name, ptr->wm_name) == 0)) {
+ if (clientId) {
+ /*
+ * If a client ID was present, we should not check
+ * WM_COMMAND because Xt will put a -xtsessionID arg
+ * on the command line.
+ */
+
+ found = 1;
+ }
+ else {
+ /*
+ * For non-XSMP clients, also check WM_COMMAND.
+ */
+
+ char **wm_command = NULL;
+ int wm_command_count = 0, i;
+
+ XGetCommand(dpy, theWindow->w,
+ &wm_command, &wm_command_count);
+
+ if (wm_command_count == ptr->wm_command_count) {
+ for (i = 0; i < wm_command_count; i++)
+ if (strcmp(wm_command[i],
+ ptr->wm_command[i]) != 0)
+ break;
+
+ if (i == wm_command_count)
+ found = 1;
+ }
+ }
+ }
+ }
+ }
+
+ if (!found)
+ ptr = ptr->next;
}
- if (found)
- {
- *x = ptr->x;
- *y = ptr->y;
- *width = ptr->width;
- *height = ptr->height;
- *iconified = ptr->iconified;
- *icon_info_present = ptr->icon_info_present;
- *width_ever_changed_by_user = ptr->width_ever_changed_by_user;
- *height_ever_changed_by_user = ptr->height_ever_changed_by_user;
-
- if (*icon_info_present)
- {
- *icon_x = ptr->icon_x;
- *icon_y = ptr->icon_y;
- }
- ptr->tag = 1;
+ if (found) {
+ *x = ptr->x;
+ *y = ptr->y;
+ *width = ptr->width;
+ *height = ptr->height;
+ *iconified = ptr->iconified;
+ *icon_info_present = ptr->icon_info_present;
+ *width_ever_changed_by_user = ptr->width_ever_changed_by_user;
+ *height_ever_changed_by_user = ptr->height_ever_changed_by_user;
+
+ if (*icon_info_present) {
+ *icon_x = ptr->icon_x;
+ *icon_y = ptr->icon_y;
+ }
+ ptr->tag = 1;
}
else
- *iconified = 0;
+ *iconified = 0;
if (clientId)
- XFree (clientId);
+ XFree(clientId);
if (windowRole)
- XFree (windowRole);
+ XFree(windowRole);
return found;
}
-
-
#ifndef HAVE_MKSTEMP
static char *
-unique_filename (
- const char *path,
- const char *prefix)
+unique_filename(const char *path, const char *prefix)
#else
static char *
-unique_filename (
- const char *path,
- const char *prefix,
- int *pFd)
+unique_filename(const char *path, const char *prefix, int *pFd)
#endif
-
{
#ifndef HAVE_MKSTEMP
#ifndef X_NOT_POSIX
- return ((char *) tempnam (path, prefix));
+ return ((char *) tempnam(path, prefix));
#else
char tempFile[PATH_MAX];
char *tmp;
- snprintf (tempFile, sizeof(tempFile), "%s/%sXXXXXX", path, prefix);
- tmp = (char *) mktemp (tempFile);
+ snprintf(tempFile, sizeof(tempFile), "%s/%sXXXXXX", path, prefix);
+ tmp = (char *) mktemp(tempFile);
if (tmp)
- return strdup (tmp);
+ return strdup(tmp);
else
- return (NULL);
+ return (NULL);
#endif
#else
char tempFile[PATH_MAX];
char *ptr;
- snprintf (tempFile, sizeof(tempFile), "%s/%sXXXXXX", path, prefix);
- ptr = strdup (tempFile);
+ snprintf(tempFile, sizeof(tempFile), "%s/%sXXXXXX", path, prefix);
+ ptr = strdup(tempFile);
if (ptr != NULL)
- *pFd = mkstemp (ptr);
+ *pFd = mkstemp(ptr);
return ptr;
#endif
}
-
-
static void
-SaveYourselfPhase2CB (SmcConn smcConn2, SmPointer clientData _X_UNUSED)
+SaveYourselfPhase2CB(SmcConn smcConn2, SmPointer clientData _X_UNUSED)
{
int scrnum;
ScreenInfo *theScreen;
@@ -735,229 +675,206 @@ SaveYourselfPhase2CB (SmcConn smcConn2, SmPointer clientData _X_UNUSED)
char discardCommand[80];
int numVals, i;
static int first_time = 1;
+
#ifdef HAVE_MKSTEMP
int fd;
#endif
- if (first_time)
- {
- char userId[20];
- char hint = SmRestartIfRunning;
-
- prop1.name = strdup(SmProgram);
- prop1.type = strdup(SmARRAY8);
- prop1.num_vals = 1;
- prop1.vals = &prop1val;
- prop1val.value = Argv[0];
- prop1val.length = (int)strlen (Argv[0]);
-
- snprintf (userId, sizeof(userId), "%ld", (long)getuid());
- prop2.name = strdup(SmUserID);
- prop2.type = strdup(SmARRAY8);
- prop2.num_vals = 1;
- prop2.vals = &prop2val;
- prop2val.value = (SmPointer) userId;
- prop2val.length = (int)strlen (userId);
-
- prop3.name = strdup(SmRestartStyleHint);
- prop3.type = strdup(SmCARD8);
- prop3.num_vals = 1;
- prop3.vals = &prop3val;
- prop3val.value = (SmPointer) &hint;
- prop3val.length = 1;
-
- props[0] = &prop1;
- props[1] = &prop2;
- props[2] = &prop3;
-
- SmcSetProperties (smcConn2, 3, props);
-
- first_time = 0;
+ if (first_time) {
+ char userId[20];
+ char hint = SmRestartIfRunning;
+
+ prop1.name = strdup(SmProgram);
+ prop1.type = strdup(SmARRAY8);
+ prop1.num_vals = 1;
+ prop1.vals = &prop1val;
+ prop1val.value = Argv[0];
+ prop1val.length = (int) strlen(Argv[0]);
+
+ snprintf(userId, sizeof(userId), "%ld", (long) getuid());
+ prop2.name = strdup(SmUserID);
+ prop2.type = strdup(SmARRAY8);
+ prop2.num_vals = 1;
+ prop2.vals = &prop2val;
+ prop2val.value = (SmPointer) userId;
+ prop2val.length = (int) strlen(userId);
+
+ prop3.name = strdup(SmRestartStyleHint);
+ prop3.type = strdup(SmCARD8);
+ prop3.num_vals = 1;
+ prop3.vals = &prop3val;
+ prop3val.value = (SmPointer) & hint;
+ prop3val.length = 1;
+
+ props[0] = &prop1;
+ props[1] = &prop2;
+ props[2] = &prop3;
+
+ SmcSetProperties(smcConn2, 3, props);
+
+ first_time = 0;
}
- path = getenv ("SM_SAVE_DIR");
- if (!path)
- {
- path = getenv ("HOME");
- if (!path)
- path = ".";
+ path = getenv("SM_SAVE_DIR");
+ if (!path) {
+ path = getenv("HOME");
+ if (!path)
+ path = ".";
}
#ifndef HAVE_MKSTEMP
- if ((filename = unique_filename (path, ".twm")) == NULL)
- goto bad;
+ if ((filename = unique_filename(path, ".twm")) == NULL)
+ goto bad;
- if (!(configFile = fopen (filename, "wb")))
- goto bad;
+ if (!(configFile = fopen(filename, "wb")))
+ goto bad;
#else
- if ((filename = unique_filename (path, ".twm", &fd)) == NULL)
- goto bad;
+ if ((filename = unique_filename(path, ".twm", &fd)) == NULL)
+ goto bad;
if (!(configFile = fdopen(fd, "wb")))
- goto bad;
+ goto bad;
#endif
- if (!write_ushort (configFile, SAVEFILE_VERSION))
- goto bad;
+ if (!write_ushort(configFile, SAVEFILE_VERSION))
+ goto bad;
success = True;
- for (scrnum = 0; scrnum < NumScreens && success; scrnum++)
- {
- if (ScreenList[scrnum] != NULL)
- {
- theScreen = ScreenList[scrnum];
- theWindow = theScreen->TwmRoot.next;
+ for (scrnum = 0; scrnum < NumScreens && success; scrnum++) {
+ if (ScreenList[scrnum] != NULL) {
+ theScreen = ScreenList[scrnum];
+ theWindow = theScreen->TwmRoot.next;
- while (theWindow && success)
- {
- clientId = GetClientID (theWindow->w);
- windowRole = GetWindowRole (theWindow->w);
+ while (theWindow && success) {
+ clientId = GetClientID(theWindow->w);
+ windowRole = GetWindowRole(theWindow->w);
- if (!WriteWinConfigEntry (configFile, theWindow,
- clientId, windowRole))
- success = False;
+ if (!WriteWinConfigEntry(configFile, theWindow,
+ clientId, windowRole))
+ success = False;
- if (clientId)
- XFree (clientId);
+ if (clientId)
+ XFree(clientId);
- if (windowRole)
- XFree (windowRole);
+ if (windowRole)
+ XFree(windowRole);
- theWindow = theWindow->next;
- }
- }
+ theWindow = theWindow->next;
+ }
+ }
}
prop1.name = strdup(SmRestartCommand);
prop1.type = strdup(SmLISTofARRAY8);
- prop1.vals = malloc ((size_t)(Argc + 4) * sizeof (SmPropValue));
+ prop1.vals = malloc((size_t) (Argc + 4) * sizeof(SmPropValue));
- if (!prop1.vals)
- {
- success = False;
- goto bad;
+ if (!prop1.vals) {
+ success = False;
+ goto bad;
}
numVals = 0;
- for (i = 0; i < Argc; i++)
- {
- if (strcmp (Argv[i], "-clientId") == 0 ||
- strcmp (Argv[i], "-restore") == 0)
- {
- i++;
- }
- else
- {
- prop1.vals[numVals].value = (SmPointer) Argv[i];
- prop1.vals[numVals++].length = (int)strlen (Argv[i]);
- }
+ for (i = 0; i < Argc; i++) {
+ if (strcmp(Argv[i], "-clientId") == 0 ||
+ strcmp(Argv[i], "-restore") == 0) {
+ i++;
+ }
+ else {
+ prop1.vals[numVals].value = (SmPointer) Argv[i];
+ prop1.vals[numVals++].length = (int) strlen(Argv[i]);
+ }
}
prop1.vals[numVals].value = strdup("-clientId");
prop1.vals[numVals++].length = 9;
prop1.vals[numVals].value = strdup(twm_clientId);
- prop1.vals[numVals++].length = (int)strlen (twm_clientId);
+ prop1.vals[numVals++].length = (int) strlen(twm_clientId);
prop1.vals[numVals].value = strdup("-restore");
prop1.vals[numVals++].length = 8;
prop1.vals[numVals].value = strdup(filename);
- prop1.vals[numVals++].length = (int)strlen (filename);
+ prop1.vals[numVals++].length = (int) strlen(filename);
prop1.num_vals = numVals;
- snprintf (discardCommand, sizeof(discardCommand), "rm %s", filename);
+ snprintf(discardCommand, sizeof(discardCommand), "rm %s", filename);
prop2.name = strdup(SmDiscardCommand);
prop2.type = strdup(SmARRAY8);
prop2.num_vals = 1;
prop2.vals = &prop2val;
prop2val.value = (SmPointer) discardCommand;
- prop2val.length = (int)strlen (discardCommand);
+ prop2val.length = (int) strlen(discardCommand);
props[0] = &prop1;
props[1] = &prop2;
- SmcSetProperties (smcConn2, 2, props);
- free (prop1.vals);
+ SmcSetProperties(smcConn2, 2, props);
+ free(prop1.vals);
bad:
- SmcSaveYourselfDone (smcConn2, success);
+ SmcSaveYourselfDone(smcConn2, success);
sent_save_done = 1;
if (configFile)
- fclose (configFile);
+ fclose(configFile);
if (filename)
- free (filename);
+ free(filename);
}
-
-
static void
-SaveYourselfCB (
- SmcConn smcConn2,
- SmPointer clientData _X_UNUSED,
- int saveType _X_UNUSED,
- Bool shutdown _X_UNUSED,
- int interactStyle _X_UNUSED,
- Bool fast _X_UNUSED)
+SaveYourselfCB(SmcConn smcConn2,
+ SmPointer clientData _X_UNUSED,
+ int saveType _X_UNUSED,
+ Bool shutdown _X_UNUSED,
+ int interactStyle _X_UNUSED, Bool fast _X_UNUSED)
{
- if (!SmcRequestSaveYourselfPhase2 (smcConn2, SaveYourselfPhase2CB, NULL))
- {
- SmcSaveYourselfDone (smcConn2, False);
- sent_save_done = 1;
+ if (!SmcRequestSaveYourselfPhase2(smcConn2, SaveYourselfPhase2CB, NULL)) {
+ SmcSaveYourselfDone(smcConn2, False);
+ sent_save_done = 1;
}
else
- sent_save_done = 0;
+ sent_save_done = 0;
}
-
-
static void
-DieCB (SmcConn smcConn2, SmPointer clientData _X_UNUSED)
+DieCB(SmcConn smcConn2, SmPointer clientData _X_UNUSED)
{
- SmcCloseConnection (smcConn2, 0, NULL);
- XtRemoveInput (iceInputId);
+ SmcCloseConnection(smcConn2, 0, NULL);
+ XtRemoveInput(iceInputId);
Done(NULL, NULL);
}
-
-
static void
-SaveCompleteCB (SmcConn smcConnm _X_UNUSED, SmPointer clientData _X_UNUSED)
+SaveCompleteCB(SmcConn smcConnm _X_UNUSED, SmPointer clientData _X_UNUSED)
{
;
}
-
-
static void
-ShutdownCancelledCB (SmcConn smcConn2, SmPointer clientData _X_UNUSED)
+ShutdownCancelledCB(SmcConn smcConn2, SmPointer clientData _X_UNUSED)
{
- if (!sent_save_done)
- {
- SmcSaveYourselfDone (smcConn2, False);
- sent_save_done = 1;
+ if (!sent_save_done) {
+ SmcSaveYourselfDone(smcConn2, False);
+ sent_save_done = 1;
}
}
-
-
static void
-ProcessIceMsgProc (XtPointer client_data, int *source _X_UNUSED, XtInputId *id _X_UNUSED)
+ProcessIceMsgProc(XtPointer client_data, int *source _X_UNUSED,
+ XtInputId *id _X_UNUSED)
{
- IceConn ice_conn = (IceConn) client_data;
+ IceConn ice_conn = (IceConn) client_data;
- IceProcessMessages (ice_conn, NULL, NULL);
+ IceProcessMessages(ice_conn, NULL, NULL);
}
-
-
void
-ConnectToSessionManager (char *previous_id)
+ConnectToSessionManager(char *previous_id)
{
char errorMsg[256];
unsigned long mask;
@@ -965,7 +882,7 @@ ConnectToSessionManager (char *previous_id)
IceConn iceConn;
mask = SmcSaveYourselfProcMask | SmcDieProcMask |
- SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask;
+ SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask;
callbacks.save_yourself.callback = SaveYourselfCB;
callbacks.save_yourself.client_data = (SmPointer) NULL;
@@ -979,29 +896,21 @@ ConnectToSessionManager (char *previous_id)
callbacks.shutdown_cancelled.callback = ShutdownCancelledCB;
callbacks.shutdown_cancelled.client_data = (SmPointer) NULL;
- smcConn = SmcOpenConnection (
- NULL, /* use SESSION_MANAGER env */
- (SmPointer) appContext,
- SmProtoMajor,
- SmProtoMinor,
- mask,
- &callbacks,
- previous_id,
- &twm_clientId,
- 256, errorMsg);
+ smcConn = SmcOpenConnection(NULL, /* use SESSION_MANAGER env */
+ (SmPointer) appContext,
+ SmProtoMajor,
+ SmProtoMinor,
+ mask,
+ &callbacks,
+ previous_id, &twm_clientId, 256, errorMsg);
if (smcConn == NULL)
- return;
+ return;
- iceConn = SmcGetIceConnection (smcConn);
+ iceConn = SmcGetIceConnection(smcConn);
- iceInputId = XtAppAddInput (
- appContext,
- IceConnectionNumber (iceConn),
- (XtPointer) XtInputReadMask,
- ProcessIceMsgProc,
- (XtPointer) iceConn);
+ iceInputId = XtAppAddInput(appContext,
+ IceConnectionNumber(iceConn),
+ (XtPointer) XtInputReadMask,
+ ProcessIceMsgProc, (XtPointer) iceConn);
}
-
-
-
diff --git a/src/session.h b/src/session.h
index 05b51fe..3b93fb7 100644
--- a/src/session.h
+++ b/src/session.h
@@ -27,9 +27,14 @@
#define _SESSION_H
#include <X11/SM/SMlib.h>
-extern void ConnectToSessionManager ( char *previous_id );
-extern int GetWindowConfig ( TwmWindow *theWindow, short *x, short *y, unsigned short *width, unsigned short *height, Bool *iconified, Bool *icon_info_present, short *icon_x, short *icon_y, Bool *width_ever_changed_by_user, Bool *height_ever_changed_by_user );
-extern void ReadWinConfigFile ( char *filename );
+extern void ConnectToSessionManager(char *previous_id);
+extern int GetWindowConfig(TwmWindow *theWindow, short *x, short *y,
+ unsigned short *width, unsigned short *height,
+ Bool *iconified, Bool *icon_info_present,
+ short *icon_x, short *icon_y,
+ Bool *width_ever_changed_by_user,
+ Bool *height_ever_changed_by_user);
+extern void ReadWinConfigFile(char *filename);
extern SmcConn smcConn;
diff --git a/src/twm.c b/src/twm.c
index d05d992..d9a8f6c 100644
--- a/src/twm.c
+++ b/src/twm.c
@@ -50,7 +50,6 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* twm - "Tom's Window Manager"
@@ -85,87 +84,87 @@ in this Software without prior written authorization from The Open Group.
#ifdef XPRINT
#include <X11/extensions/Print.h>
-#endif /* XPRINT */
+#endif /* XPRINT */
#ifdef HAVE_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
-static void InitVariables ( void );
+static void InitVariables(void);
-XtAppContext appContext; /* Xt application context */
+XtAppContext appContext; /* Xt application context */
XtSignalId si;
-Display *dpy = NULL; /* which display are we talking to */
-Window ResizeWindow; /* the window we are resizing */
+Display *dpy = NULL; /* which display are we talking to */
+Window ResizeWindow; /* the window we are resizing */
-int MultiScreen = TRUE; /* try for more than one screen? */
+int MultiScreen = TRUE; /* try for more than one screen? */
int NoPrintscreens = False; /* ignore special handling of print screens? */
-int NumScreens; /* number of screens in ScreenList */
-int HasShape; /* server supports shape extension? */
+int NumScreens; /* number of screens in ScreenList */
+int HasShape; /* server supports shape extension? */
#ifdef HAVE_XRANDR
-int HasXrandr; /* server supports Xrandr extension? */
+int HasXrandr; /* server supports Xrandr extension? */
int XrandrEventBase, XrandrErrorBase;
#endif
int ShapeEventBase, ShapeErrorBase;
-int HasSync; /* server supports SYNC extension? */
+int HasSync; /* server supports SYNC extension? */
int SyncEventBase, SyncErrorBase;
-ScreenInfo **ScreenList; /* structures for each screen */
-ScreenInfo *Scr = NULL; /* the cur and prev screens */
-int PreviousScreen; /* last screen that we were on */
-int FirstScreen; /* TRUE ==> first screen of display */
-static Bool PrintErrorMessages = False; /* controls error messages */
-static int RedirectError; /* TRUE ==> another window manager running */
-static int TwmErrorHandler ( Display *dpy, XErrorEvent *event ); /* for settting RedirectError */
-static int CatchRedirectError ( Display *dpy, XErrorEvent *event ); /* for everything else */
+ScreenInfo **ScreenList; /* structures for each screen */
+ScreenInfo *Scr = NULL; /* the cur and prev screens */
+int PreviousScreen; /* last screen that we were on */
+int FirstScreen; /* TRUE ==> first screen of display */
+static Bool PrintErrorMessages = False; /* controls error messages */
+static int RedirectError; /* TRUE ==> another window manager running */
+static int TwmErrorHandler(Display *dpy, XErrorEvent *event); /* for settting RedirectError */
+static int CatchRedirectError(Display *dpy, XErrorEvent *event); /* for everything else */
static void sigHandler(int);
-char Info[INFO_LINES][INFO_SIZE]; /* info strings to print */
+char Info[INFO_LINES][INFO_SIZE]; /* info strings to print */
int InfoLines;
static char *InitFile = NULL;
-Cursor UpperLeftCursor; /* upper Left corner cursor */
+Cursor UpperLeftCursor; /* upper Left corner cursor */
Cursor RightButt;
Cursor MiddleButt;
Cursor LeftButt;
-XContext TwmContext; /* context for twm windows */
-XContext MenuContext; /* context for all menu windows */
-XContext IconManagerContext; /* context for all window list windows */
-XContext ScreenContext; /* context to get screen data */
-XContext ColormapContext; /* context for colormap operations */
+XContext TwmContext; /* context for twm windows */
+XContext MenuContext; /* context for all menu windows */
+XContext IconManagerContext; /* context for all window list windows */
+XContext ScreenContext; /* context to get screen data */
+XContext ColormapContext; /* context for colormap operations */
-XClassHint NoClass; /* for applications with no class */
+XClassHint NoClass; /* for applications with no class */
XGCValues Gcv;
-const char *Home; /* the HOME environment variable */
-int HomeLen; /* length of Home */
-int ParseError; /* error parsing the .twmrc file */
+const char *Home; /* the HOME environment variable */
+int HomeLen; /* length of Home */
+int ParseError; /* error parsing the .twmrc file */
-int HandlingEvents = FALSE; /* are we handling events yet? */
+int HandlingEvents = FALSE; /* are we handling events yet? */
-Window JunkRoot; /* junk window */
-Window JunkChild; /* junk window */
-int JunkX; /* junk variable */
-int JunkY; /* junk variable */
+Window JunkRoot; /* junk window */
+Window JunkChild; /* junk window */
+int JunkX; /* junk variable */
+int JunkY; /* junk variable */
unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask;
char *ProgramName;
int Argc;
char **Argv;
-Bool RestartPreviousState = False; /* try to restart in previous state */
+Bool RestartPreviousState = False; /* try to restart in previous state */
static unsigned long black, white;
Atom TwmAtoms[11];
-Bool use_fontset; /* use XFontSet-related functions or not */
+Bool use_fontset; /* use XFontSet-related functions or not */
/* don't change the order of these strings */
-static char* atom_names[11] = {
+static char *atom_names[11] = {
"_MIT_PRIORITY_COLORS",
"WM_CHANGE_STATE",
"WM_STATE",
@@ -183,31 +182,33 @@ static char* atom_names[11] = {
/* |hasExtension()| and |IsPrintScreen()| have been stolen from
* xc/programs/xdpyinfo/xdpyinfo.c */
static
-Bool hasExtension(Display *dpy, char *extname)
+ Bool
+hasExtension(Display *dpy, char *extname)
{
- int num_extensions,
- i;
- char **extensions;
- extensions = XListExtensions(dpy, &num_extensions);
- for (i = 0; i < num_extensions &&
+ int num_extensions, i;
+ char **extensions;
+
+ extensions = XListExtensions(dpy, &num_extensions);
+ for (i = 0; i < num_extensions &&
(strcmp(extensions[i], extname) != 0); i++);
- XFreeExtensionList(extensions);
- return i != num_extensions;
+ XFreeExtensionList(extensions);
+ return i != num_extensions;
}
static
-Bool IsPrintScreen(Screen *s)
+ Bool
+IsPrintScreen(Screen *s)
{
Display *dpy = XDisplayOfScreen(s);
- int i;
+ int i;
/* Check whether this is a screen of a print DDX */
if (hasExtension(dpy, XP_PRINTNAME)) {
Screen **pscreens;
- int pscrcount;
+ int pscrcount;
pscreens = XpQueryScreens(dpy, &pscrcount);
- for( i = 0 ; (i < pscrcount) && pscreens ; i++ ) {
+ for (i = 0; (i < pscrcount) && pscreens; i++) {
if (s == pscreens[i]) {
return True;
}
@@ -216,12 +217,12 @@ Bool IsPrintScreen(Screen *s)
}
return False;
}
-#endif /* XPRINT */
+#endif /* XPRINT */
/***********************************************************************
*
* Procedure:
- * main - start of twm
+ * main - start of twm
*
***********************************************************************
*/
@@ -233,8 +234,8 @@ main(int argc, char *argv[])
unsigned int nchildren;
int i, j;
char *display_name = NULL;
- unsigned long valuemask; /* mask for create windows */
- XSetWindowAttributes attributes; /* attributes for create windows */
+ unsigned long valuemask; /* mask for create windows */
+ XSetWindowAttributes attributes; /* attributes for create windows */
int numManaged, firstscrn, lastscrn, scrnum;
int zero = 0;
char *restore_filename = NULL;
@@ -246,120 +247,126 @@ main(int argc, char *argv[])
Argv = argv;
for (i = 1; i < argc; i++) {
- if (argv[i][0] == '-') {
- switch (argv[i][1]) {
- case 'd': /* -display dpy */
- if (strcmp(&argv[i][1], "display")) goto usage;
- if (++i >= argc) goto usage;
- display_name = argv[i];
- continue;
- case 's': /* -single */
- MultiScreen = FALSE;
- continue;
+ if (argv[i][0] == '-') {
+ switch (argv[i][1]) {
+ case 'd': /* -display dpy */
+ if (strcmp(&argv[i][1], "display"))
+ goto usage;
+ if (++i >= argc)
+ goto usage;
+ display_name = argv[i];
+ continue;
+ case 's': /* -single */
+ MultiScreen = FALSE;
+ continue;
#ifdef XPRINT
- case 'n': /* -noprint */
- if (strcmp(&argv[i][1], "noprint")) goto usage;
- NoPrintscreens = True;
- continue;
-#endif /* XPRINT */
- case 'f': /* -file twmrcfilename */
- if (++i >= argc) goto usage;
- InitFile = argv[i];
- continue;
- case 'v': /* -verbose */
- PrintErrorMessages = True;
- continue;
- case 'c': /* -clientId */
- if (strcmp(&argv[i][1], "clientId")) goto usage;
- if (++i >= argc) goto usage;
- client_id = argv[i];
- continue;
- case 'r': /* -restore */
- if (strcmp(&argv[i][1], "restore")) goto usage;
- if (++i >= argc) goto usage;
- restore_filename = argv[i];
- continue;
- case 'q': /* -quiet */
- PrintErrorMessages = False;
- continue;
- }
- }
- usage:
- fprintf (stderr,
- "usage: %s [-display dpy] [-f file] [-s] [-q] [-v]"
+ case 'n': /* -noprint */
+ if (strcmp(&argv[i][1], "noprint"))
+ goto usage;
+ NoPrintscreens = True;
+ continue;
+#endif /* XPRINT */
+ case 'f': /* -file twmrcfilename */
+ if (++i >= argc)
+ goto usage;
+ InitFile = argv[i];
+ continue;
+ case 'v': /* -verbose */
+ PrintErrorMessages = True;
+ continue;
+ case 'c': /* -clientId */
+ if (strcmp(&argv[i][1], "clientId"))
+ goto usage;
+ if (++i >= argc)
+ goto usage;
+ client_id = argv[i];
+ continue;
+ case 'r': /* -restore */
+ if (strcmp(&argv[i][1], "restore"))
+ goto usage;
+ if (++i >= argc)
+ goto usage;
+ restore_filename = argv[i];
+ continue;
+ case 'q': /* -quiet */
+ PrintErrorMessages = False;
+ continue;
+ }
+ }
+ usage:
+ fprintf(stderr, "usage: %s [-display dpy] [-f file] [-s] [-q] [-v]"
#ifdef XPRINT
- " [-noprint]"
-#endif /* XPRINT */
- " [-clientId id] [-restore file]\n",
- ProgramName);
- exit (1);
+ " [-noprint]"
+#endif /* XPRINT */
+ " [-clientId id] [-restore file]\n", ProgramName);
+ exit(1);
}
loc = setlocale(LC_ALL, "");
if (!loc || !strcmp(loc, "C") || !strcmp(loc, "POSIX") ||
- !XSupportsLocale()) {
- use_fontset = False;
- } else {
- use_fontset = True;
+ !XSupportsLocale()) {
+ use_fontset = False;
+ }
+ else {
+ use_fontset = True;
}
#define newhandler(sig) \
if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, sigHandler)
-
- newhandler (SIGINT);
- newhandler (SIGHUP);
- newhandler (SIGQUIT);
- newhandler (SIGTERM);
+ newhandler(SIGINT);
+ newhandler(SIGHUP);
+ newhandler(SIGQUIT);
+ newhandler(SIGTERM);
#undef newhandler
Home = getenv("HOME");
if (Home != NULL) {
- char *temp_p;
+ char *temp_p;
- /*
- * Make a copy of Home because the string returned by getenv() can be
- * overwritten by some POSIX.1 and ANSI-C implementations of getenv()
- * when further calls to getenv() are made
- */
+ /*
+ * Make a copy of Home because the string returned by getenv() can be
+ * overwritten by some POSIX.1 and ANSI-C implementations of getenv()
+ * when further calls to getenv() are made
+ */
- temp_p = strdup(Home);
- Home = temp_p;
+ temp_p = strdup(Home);
+ Home = temp_p;
}
if (Home == NULL)
- Home = "./";
+ Home = "./";
- HomeLen = (int)strlen(Home);
+ HomeLen = (int) strlen(Home);
NoClass.res_name = NoName;
NoClass.res_class = NoName;
- XtToolkitInitialize ();
- appContext = XtCreateApplicationContext ();
+ XtToolkitInitialize();
+ appContext = XtCreateApplicationContext();
si = XtAppAddSignal(appContext, Done, NULL);
- if (!(dpy = XtOpenDisplay (appContext, display_name, "twm", "twm",
- NULL, 0, &zero, NULL))) {
- fprintf (stderr, "%s: unable to open display \"%s\"\n",
- ProgramName, XDisplayName(display_name));
- exit (1);
+ if (!(dpy = XtOpenDisplay(appContext, display_name, "twm", "twm",
+ NULL, 0, &zero, NULL))) {
+ fprintf(stderr, "%s: unable to open display \"%s\"\n",
+ ProgramName, XDisplayName(display_name));
+ exit(1);
}
if (fcntl(ConnectionNumber(dpy), F_SETFD, 1) == -1) {
- fprintf (stderr,
- "%s: unable to mark display connection as close-on-exec\n",
- ProgramName);
- exit (1);
+ fprintf(stderr,
+ "%s: unable to mark display connection as close-on-exec\n",
+ ProgramName);
+ exit(1);
}
if (restore_filename)
- ReadWinConfigFile (restore_filename);
+ ReadWinConfigFile(restore_filename);
- HasShape = XShapeQueryExtension (dpy, &ShapeEventBase, &ShapeErrorBase);
- HasSync = XSyncQueryExtension(dpy, &SyncEventBase, &SyncErrorBase);
+ HasShape = XShapeQueryExtension(dpy, &ShapeEventBase, &ShapeErrorBase);
+ HasSync = XSyncQueryExtension(dpy, &SyncEventBase, &SyncErrorBase);
#ifdef HAVE_XRANDR
HasXrandr = XRRQueryExtension(dpy, &XrandrEventBase, &XrandrErrorBase);
#endif
@@ -370,321 +377,313 @@ main(int argc, char *argv[])
ColormapContext = XUniqueContext();
(void) XInternAtoms(dpy, atom_names, sizeof TwmAtoms / sizeof TwmAtoms[0],
- False, TwmAtoms);
+ False, TwmAtoms);
/* Set up the per-screen global information. */
NumScreens = ScreenCount(dpy);
- if (MultiScreen)
- {
- firstscrn = 0;
- lastscrn = NumScreens - 1;
+ if (MultiScreen) {
+ firstscrn = 0;
+ lastscrn = NumScreens - 1;
}
- else
- {
- firstscrn = lastscrn = DefaultScreen(dpy);
+ else {
+ firstscrn = lastscrn = DefaultScreen(dpy);
}
InfoLines = 0;
/* for simplicity, always allocate NumScreens ScreenInfo struct pointers */
- ScreenList = calloc ((size_t)NumScreens, sizeof (ScreenInfo *));
- if (ScreenList == NULL)
- {
- fprintf (stderr, "%s: Unable to allocate memory for screen list, exiting.\n",
- ProgramName);
- exit (1);
+ ScreenList = calloc((size_t) NumScreens, sizeof(ScreenInfo *));
+ if (ScreenList == NULL) {
+ fprintf(stderr,
+ "%s: Unable to allocate memory for screen list, exiting.\n",
+ ProgramName);
+ exit(1);
}
numManaged = 0;
PreviousScreen = DefaultScreen(dpy);
FirstScreen = TRUE;
- for (scrnum = firstscrn ; scrnum <= lastscrn; scrnum++)
- {
+ for (scrnum = firstscrn; scrnum <= lastscrn; scrnum++) {
#ifdef XPRINT
/* Ignore print screens to avoid that users accidentally warp on a
* print screen (which are not visible on video displays) */
- if ((!NoPrintscreens) && IsPrintScreen(XScreenOfDisplay(dpy, scrnum)))
- {
- fprintf (stderr, "%s: skipping print screen %d\n",
- ProgramName, scrnum);
+ if ((!NoPrintscreens) && IsPrintScreen(XScreenOfDisplay(dpy, scrnum))) {
+ fprintf(stderr, "%s: skipping print screen %d\n",
+ ProgramName, scrnum);
continue;
}
-#endif /* XPRINT */
+#endif /* XPRINT */
/* Make sure property priority colors is empty */
- XChangeProperty (dpy, RootWindow(dpy, scrnum), _XA_MIT_PRIORITY_COLORS,
- XA_CARDINAL, 32, PropModeReplace, NULL, 0);
- RedirectError = FALSE;
- XSetErrorHandler(CatchRedirectError);
- XSelectInput(dpy, RootWindow (dpy, scrnum),
- ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
- SubstructureRedirectMask | KeyPressMask |
- ButtonPressMask | ButtonReleaseMask);
- XSync(dpy, 0);
- XSetErrorHandler(TwmErrorHandler);
-
- if (RedirectError)
- {
- fprintf (stderr, "%s: another window manager is already running.",
- ProgramName);
- if (MultiScreen && NumScreens > 0)
- fprintf(stderr, " on screen %d?\n", scrnum);
- else
- fprintf(stderr, "?\n");
- continue;
- }
-
- numManaged ++;
-
- /* Note: ScreenInfo struct is calloc'ed to initialize to zero. */
- Scr = ScreenList[scrnum] = calloc(1, sizeof(ScreenInfo));
- if (Scr == NULL)
- {
- fprintf (stderr, "%s: unable to allocate memory for ScreenInfo structure for screen %d.\n",
- ProgramName, scrnum);
- continue;
- }
-
- /* initialize list pointers, remember to put an initialization
- * in InitVariables also
- */
- Scr->BorderColorL = NULL;
- Scr->IconBorderColorL = NULL;
- Scr->BorderTileForegroundL = NULL;
- Scr->BorderTileBackgroundL = NULL;
- Scr->TitleForegroundL = NULL;
- Scr->TitleBackgroundL = NULL;
- Scr->IconForegroundL = NULL;
- Scr->IconBackgroundL = NULL;
- Scr->NoTitle = NULL;
- Scr->MakeTitle = NULL;
- Scr->AutoRaise = NULL;
- Scr->IconNames = NULL;
- Scr->NoHighlight = NULL;
- Scr->NoStackModeL = NULL;
- Scr->NoTitleHighlight = NULL;
- Scr->DontIconify = NULL;
- Scr->IconMgrNoShow = NULL;
- Scr->IconMgrShow = NULL;
- Scr->IconifyByUn = NULL;
- Scr->IconManagerFL = NULL;
- Scr->IconManagerBL = NULL;
- Scr->IconMgrs = NULL;
- Scr->StartIconified = NULL;
- Scr->SqueezeTitleL = NULL;
- Scr->DontSqueezeTitleL = NULL;
- Scr->WindowRingL = NULL;
- Scr->WarpCursorL = NULL;
- /* remember to put an initialization in InitVariables also
- */
-
- Scr->screen = scrnum;
- Scr->d_depth = DefaultDepth(dpy, scrnum);
- Scr->d_visual = DefaultVisual(dpy, scrnum);
- Scr->Root = RootWindow(dpy, scrnum);
- XSaveContext (dpy, Scr->Root, ScreenContext, (XPointer) Scr);
-
- Scr->TwmRoot.cmaps.number_cwins = 1;
- Scr->TwmRoot.cmaps.cwins = malloc(sizeof(ColormapWindow *));
- Scr->TwmRoot.cmaps.cwins[0] =
- CreateColormapWindow(Scr->Root, True, False);
- Scr->TwmRoot.cmaps.cwins[0]->visibility = VisibilityPartiallyObscured;
-
- Scr->cmapInfo.cmaps = NULL;
- Scr->cmapInfo.maxCmaps =
- MaxCmapsOfScreen(ScreenOfDisplay(dpy, Scr->screen));
- Scr->cmapInfo.root_pushes = 0;
- InstallWindowColormaps(0, &Scr->TwmRoot);
-
- Scr->StdCmapInfo.head = Scr->StdCmapInfo.tail =
- Scr->StdCmapInfo.mru = NULL;
- Scr->StdCmapInfo.mruindex = 0;
- LocateStandardColormaps();
-
- Scr->TBInfo.nleft = Scr->TBInfo.nright = 0;
- Scr->TBInfo.head = NULL;
- Scr->TBInfo.border = 1;
- Scr->TBInfo.width = 0;
- Scr->TBInfo.leftx = 0;
- Scr->TBInfo.titlex = 0;
-
- Scr->MyDisplayWidth = DisplayWidth(dpy, scrnum);
- Scr->MyDisplayHeight = DisplayHeight(dpy, scrnum);
- Scr->MaxWindowWidth = 32767 - Scr->MyDisplayWidth;
- Scr->MaxWindowHeight = 32767 - Scr->MyDisplayHeight;
-
- Scr->XORvalue = (((unsigned long) 1) << Scr->d_depth) - 1;
-
- if (DisplayCells(dpy, scrnum) < 3)
- Scr->Monochrome = MONOCHROME;
- else if (DefaultVisual(dpy, scrnum)->class == GrayScale)
- Scr->Monochrome = GRAYSCALE;
- else
- Scr->Monochrome = COLOR;
-
- /* setup default colors */
- Scr->FirstTime = TRUE;
- GetColor(Scr->Monochrome, &black, "black");
- Scr->Black = black;
- GetColor(Scr->Monochrome, &white, "white");
- Scr->White = white;
-
- if (FirstScreen)
- {
- SetFocus ((TwmWindow *)NULL, CurrentTime);
-
- /* define cursors */
-
- NewFontCursor(&UpperLeftCursor, "top_left_corner");
- NewFontCursor(&RightButt, "rightbutton");
- NewFontCursor(&LeftButt, "leftbutton");
- NewFontCursor(&MiddleButt, "middlebutton");
- }
-
- Scr->iconmgr.x = 0;
- Scr->iconmgr.y = 0;
- Scr->iconmgr.width = 150;
- Scr->iconmgr.height = 5;
- Scr->iconmgr.next = NULL;
- Scr->iconmgr.prev = NULL;
- Scr->iconmgr.lasti = &(Scr->iconmgr);
- Scr->iconmgr.first = NULL;
- Scr->iconmgr.last = NULL;
- Scr->iconmgr.active = NULL;
- Scr->iconmgr.scr = Scr;
- Scr->iconmgr.columns = 1;
- Scr->iconmgr.count = 0;
- Scr->iconmgr.name = "TWM";
- Scr->iconmgr.icon_name = "Icons";
-
- Scr->IconDirectory = NULL;
-
- Scr->siconifyPm = None;
- Scr->pullPm = None;
- Scr->hilitePm = None;
- Scr->tbpm.xlogo = None;
- Scr->tbpm.resize = None;
- Scr->tbpm.question = None;
- Scr->tbpm.menu = None;
- Scr->tbpm.delete = None;
-
- InitVariables();
- InitMenus();
-
- /* Parse it once for each screen. */
- ParseTwmrc(InitFile);
- assign_var_savecolor(); /* storeing pixels for twmrc "entities" */
- if (Scr->SqueezeTitle == -1) Scr->SqueezeTitle = FALSE;
- if (!Scr->HaveFonts) CreateFonts();
- CreateGCs();
- MakeMenus();
-
- Scr->TitleBarFont.y += Scr->FramePadding;
- Scr->TitleHeight = Scr->TitleBarFont.height + Scr->FramePadding * 2;
- /* make title height be odd so buttons look nice and centered */
- if (!(Scr->TitleHeight & 1)) Scr->TitleHeight++;
-
- InitTitlebarButtons (); /* menus are now loaded! */
-
- XGrabServer(dpy);
- XSync(dpy, 0);
-
- JunkX = 0;
- JunkY = 0;
-
- XQueryTree(dpy, Scr->Root, &root, &parent, &children, &nchildren);
- CreateIconManagers();
- if (!Scr->NoIconManagers)
- Scr->iconmgr.twm_win->icon = TRUE;
-
- /*
- * weed out icon windows
- */
- for (i = 0; (unsigned)i < nchildren; i++) {
- if (children[i]) {
- XWMHints *wmhintsp = XGetWMHints (dpy, children[i]);
-
- if (wmhintsp) {
- if (wmhintsp->flags & IconWindowHint) {
- for (j = 0; (unsigned)j < nchildren; j++) {
- if (children[j] == wmhintsp->icon_window) {
- children[j] = None;
- break;
- }
- }
- }
- XFree (wmhintsp);
- }
- }
- }
-
- /*
- * map all of the non-override windows
- */
- for (i = 0; (unsigned)i < nchildren; i++)
- {
- if (children[i] && MappedNotOverride(children[i]))
- {
- XUnmapWindow(dpy, children[i]);
- SimulateMapRequest(children[i]);
- }
- }
-
- if (Scr->ShowIconManager && !Scr->NoIconManagers)
- {
- Scr->iconmgr.twm_win->icon = FALSE;
- if (Scr->iconmgr.count)
- {
- SetMapStateProp (Scr->iconmgr.twm_win, NormalState);
- XMapWindow(dpy, Scr->iconmgr.w);
- XMapWindow(dpy, Scr->iconmgr.twm_win->frame);
- }
- }
-
-
- attributes.border_pixel = Scr->DefaultC.fore;
- attributes.background_pixel = Scr->DefaultC.back;
- attributes.event_mask = (ExposureMask | ButtonPressMask |
- KeyPressMask | ButtonReleaseMask);
- attributes.backing_store = NotUseful;
- attributes.cursor = XCreateFontCursor (dpy, XC_hand2);
- valuemask = (CWBorderPixel | CWBackPixel | CWEventMask |
- CWBackingStore | CWCursor);
- Scr->InfoWindow = XCreateWindow (dpy, Scr->Root, 0, 0,
- (unsigned int) 5, (unsigned int) 5,
- (unsigned int) BW, 0,
- (unsigned int) CopyFromParent,
- (Visual *) CopyFromParent,
- valuemask, &attributes);
-
- Scr->SizeStringWidth = MyFont_TextWidth (&Scr->SizeFont,
- " 8888 x 8888 ", 13);
- valuemask = (CWBorderPixel | CWBackPixel | CWBitGravity);
- attributes.bit_gravity = NorthWestGravity;
- Scr->SizeWindow = XCreateWindow (dpy, Scr->Root, 0, 0,
- (unsigned int) Scr->SizeStringWidth,
- (unsigned int) (Scr->SizeFont.height +
- SIZE_VINDENT*2),
- (unsigned int) BW, 0,
- (unsigned int) CopyFromParent,
- (Visual *) CopyFromParent,
- valuemask, &attributes);
-
- XUngrabServer(dpy);
-
- FirstScreen = FALSE;
- Scr->FirstTime = FALSE;
- } /* for */
+ XChangeProperty(dpy, RootWindow(dpy, scrnum), _XA_MIT_PRIORITY_COLORS,
+ XA_CARDINAL, 32, PropModeReplace, NULL, 0);
+ RedirectError = FALSE;
+ XSetErrorHandler(CatchRedirectError);
+ XSelectInput(dpy, RootWindow(dpy, scrnum),
+ ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
+ SubstructureRedirectMask | KeyPressMask |
+ ButtonPressMask | ButtonReleaseMask);
+ XSync(dpy, 0);
+ XSetErrorHandler(TwmErrorHandler);
+
+ if (RedirectError) {
+ fprintf(stderr, "%s: another window manager is already running.",
+ ProgramName);
+ if (MultiScreen && NumScreens > 0)
+ fprintf(stderr, " on screen %d?\n", scrnum);
+ else
+ fprintf(stderr, "?\n");
+ continue;
+ }
+
+ numManaged++;
+
+ /* Note: ScreenInfo struct is calloc'ed to initialize to zero. */
+ Scr = ScreenList[scrnum] = calloc(1, sizeof(ScreenInfo));
+ if (Scr == NULL) {
+ fprintf(stderr,
+ "%s: unable to allocate memory for ScreenInfo structure for screen %d.\n",
+ ProgramName, scrnum);
+ continue;
+ }
+
+ /* initialize list pointers, remember to put an initialization
+ * in InitVariables also
+ */
+ Scr->BorderColorL = NULL;
+ Scr->IconBorderColorL = NULL;
+ Scr->BorderTileForegroundL = NULL;
+ Scr->BorderTileBackgroundL = NULL;
+ Scr->TitleForegroundL = NULL;
+ Scr->TitleBackgroundL = NULL;
+ Scr->IconForegroundL = NULL;
+ Scr->IconBackgroundL = NULL;
+ Scr->NoTitle = NULL;
+ Scr->MakeTitle = NULL;
+ Scr->AutoRaise = NULL;
+ Scr->IconNames = NULL;
+ Scr->NoHighlight = NULL;
+ Scr->NoStackModeL = NULL;
+ Scr->NoTitleHighlight = NULL;
+ Scr->DontIconify = NULL;
+ Scr->IconMgrNoShow = NULL;
+ Scr->IconMgrShow = NULL;
+ Scr->IconifyByUn = NULL;
+ Scr->IconManagerFL = NULL;
+ Scr->IconManagerBL = NULL;
+ Scr->IconMgrs = NULL;
+ Scr->StartIconified = NULL;
+ Scr->SqueezeTitleL = NULL;
+ Scr->DontSqueezeTitleL = NULL;
+ Scr->WindowRingL = NULL;
+ Scr->WarpCursorL = NULL;
+ /* remember to put an initialization in InitVariables also
+ */
+
+ Scr->screen = scrnum;
+ Scr->d_depth = DefaultDepth(dpy, scrnum);
+ Scr->d_visual = DefaultVisual(dpy, scrnum);
+ Scr->Root = RootWindow(dpy, scrnum);
+ XSaveContext(dpy, Scr->Root, ScreenContext, (XPointer) Scr);
+
+ Scr->TwmRoot.cmaps.number_cwins = 1;
+ Scr->TwmRoot.cmaps.cwins = malloc(sizeof(ColormapWindow *));
+ Scr->TwmRoot.cmaps.cwins[0] =
+ CreateColormapWindow(Scr->Root, True, False);
+ Scr->TwmRoot.cmaps.cwins[0]->visibility = VisibilityPartiallyObscured;
+
+ Scr->cmapInfo.cmaps = NULL;
+ Scr->cmapInfo.maxCmaps =
+ MaxCmapsOfScreen(ScreenOfDisplay(dpy, Scr->screen));
+ Scr->cmapInfo.root_pushes = 0;
+ InstallWindowColormaps(0, &Scr->TwmRoot);
+
+ Scr->StdCmapInfo.head = Scr->StdCmapInfo.tail =
+ Scr->StdCmapInfo.mru = NULL;
+ Scr->StdCmapInfo.mruindex = 0;
+ LocateStandardColormaps();
+
+ Scr->TBInfo.nleft = Scr->TBInfo.nright = 0;
+ Scr->TBInfo.head = NULL;
+ Scr->TBInfo.border = 1;
+ Scr->TBInfo.width = 0;
+ Scr->TBInfo.leftx = 0;
+ Scr->TBInfo.titlex = 0;
+
+ Scr->MyDisplayWidth = DisplayWidth(dpy, scrnum);
+ Scr->MyDisplayHeight = DisplayHeight(dpy, scrnum);
+ Scr->MaxWindowWidth = 32767 - Scr->MyDisplayWidth;
+ Scr->MaxWindowHeight = 32767 - Scr->MyDisplayHeight;
+
+ Scr->XORvalue = (((unsigned long) 1) << Scr->d_depth) - 1;
+
+ if (DisplayCells(dpy, scrnum) < 3)
+ Scr->Monochrome = MONOCHROME;
+ else if (DefaultVisual(dpy, scrnum)->class == GrayScale)
+ Scr->Monochrome = GRAYSCALE;
+ else
+ Scr->Monochrome = COLOR;
+
+ /* setup default colors */
+ Scr->FirstTime = TRUE;
+ GetColor(Scr->Monochrome, &black, "black");
+ Scr->Black = black;
+ GetColor(Scr->Monochrome, &white, "white");
+ Scr->White = white;
+
+ if (FirstScreen) {
+ SetFocus((TwmWindow *) NULL, CurrentTime);
+
+ /* define cursors */
+
+ NewFontCursor(&UpperLeftCursor, "top_left_corner");
+ NewFontCursor(&RightButt, "rightbutton");
+ NewFontCursor(&LeftButt, "leftbutton");
+ NewFontCursor(&MiddleButt, "middlebutton");
+ }
+
+ Scr->iconmgr.x = 0;
+ Scr->iconmgr.y = 0;
+ Scr->iconmgr.width = 150;
+ Scr->iconmgr.height = 5;
+ Scr->iconmgr.next = NULL;
+ Scr->iconmgr.prev = NULL;
+ Scr->iconmgr.lasti = &(Scr->iconmgr);
+ Scr->iconmgr.first = NULL;
+ Scr->iconmgr.last = NULL;
+ Scr->iconmgr.active = NULL;
+ Scr->iconmgr.scr = Scr;
+ Scr->iconmgr.columns = 1;
+ Scr->iconmgr.count = 0;
+ Scr->iconmgr.name = "TWM";
+ Scr->iconmgr.icon_name = "Icons";
+
+ Scr->IconDirectory = NULL;
+
+ Scr->siconifyPm = None;
+ Scr->pullPm = None;
+ Scr->hilitePm = None;
+ Scr->tbpm.xlogo = None;
+ Scr->tbpm.resize = None;
+ Scr->tbpm.question = None;
+ Scr->tbpm.menu = None;
+ Scr->tbpm.delete = None;
+
+ InitVariables();
+ InitMenus();
+
+ /* Parse it once for each screen. */
+ ParseTwmrc(InitFile);
+ assign_var_savecolor(); /* storeing pixels for twmrc "entities" */
+ if (Scr->SqueezeTitle == -1)
+ Scr->SqueezeTitle = FALSE;
+ if (!Scr->HaveFonts)
+ CreateFonts();
+ CreateGCs();
+ MakeMenus();
+
+ Scr->TitleBarFont.y += Scr->FramePadding;
+ Scr->TitleHeight = Scr->TitleBarFont.height + Scr->FramePadding * 2;
+ /* make title height be odd so buttons look nice and centered */
+ if (!(Scr->TitleHeight & 1))
+ Scr->TitleHeight++;
+
+ InitTitlebarButtons(); /* menus are now loaded! */
+
+ XGrabServer(dpy);
+ XSync(dpy, 0);
+
+ JunkX = 0;
+ JunkY = 0;
+
+ XQueryTree(dpy, Scr->Root, &root, &parent, &children, &nchildren);
+ CreateIconManagers();
+ if (!Scr->NoIconManagers)
+ Scr->iconmgr.twm_win->icon = TRUE;
+
+ /*
+ * weed out icon windows
+ */
+ for (i = 0; (unsigned) i < nchildren; i++) {
+ if (children[i]) {
+ XWMHints *wmhintsp = XGetWMHints(dpy, children[i]);
+
+ if (wmhintsp) {
+ if (wmhintsp->flags & IconWindowHint) {
+ for (j = 0; (unsigned) j < nchildren; j++) {
+ if (children[j] == wmhintsp->icon_window) {
+ children[j] = None;
+ break;
+ }
+ }
+ }
+ XFree(wmhintsp);
+ }
+ }
+ }
+
+ /*
+ * map all of the non-override windows
+ */
+ for (i = 0; (unsigned) i < nchildren; i++) {
+ if (children[i] && MappedNotOverride(children[i])) {
+ XUnmapWindow(dpy, children[i]);
+ SimulateMapRequest(children[i]);
+ }
+ }
+
+ if (Scr->ShowIconManager && !Scr->NoIconManagers) {
+ Scr->iconmgr.twm_win->icon = FALSE;
+ if (Scr->iconmgr.count) {
+ SetMapStateProp(Scr->iconmgr.twm_win, NormalState);
+ XMapWindow(dpy, Scr->iconmgr.w);
+ XMapWindow(dpy, Scr->iconmgr.twm_win->frame);
+ }
+ }
+
+ attributes.border_pixel = Scr->DefaultC.fore;
+ attributes.background_pixel = Scr->DefaultC.back;
+ attributes.event_mask = (ExposureMask | ButtonPressMask |
+ KeyPressMask | ButtonReleaseMask);
+ attributes.backing_store = NotUseful;
+ attributes.cursor = XCreateFontCursor(dpy, XC_hand2);
+ valuemask = (CWBorderPixel | CWBackPixel | CWEventMask |
+ CWBackingStore | CWCursor);
+ Scr->InfoWindow = XCreateWindow(dpy, Scr->Root, 0, 0,
+ (unsigned int) 5, (unsigned int) 5,
+ (unsigned int) BW, 0,
+ (unsigned int) CopyFromParent,
+ (Visual *) CopyFromParent,
+ valuemask, &attributes);
+
+ Scr->SizeStringWidth = MyFont_TextWidth(&Scr->SizeFont,
+ " 8888 x 8888 ", 13);
+ valuemask = (CWBorderPixel | CWBackPixel | CWBitGravity);
+ attributes.bit_gravity = NorthWestGravity;
+ Scr->SizeWindow = XCreateWindow(dpy, Scr->Root, 0, 0,
+ (unsigned int) Scr->SizeStringWidth,
+ (unsigned int) (Scr->SizeFont.height +
+ SIZE_VINDENT * 2),
+ (unsigned int) BW, 0,
+ (unsigned int) CopyFromParent,
+ (Visual *) CopyFromParent,
+ valuemask, &attributes);
+
+ XUngrabServer(dpy);
+
+ FirstScreen = FALSE;
+ Scr->FirstTime = FALSE;
+ } /* for */
if (numManaged == 0) {
- if (MultiScreen && NumScreens > 0)
- fprintf (stderr, "%s: unable to find any unmanaged %sscreens.\n",
- ProgramName, NoPrintscreens?"":"video ");
- exit (1);
+ if (MultiScreen && NumScreens > 0)
+ fprintf(stderr, "%s: unable to find any unmanaged %sscreens.\n",
+ ProgramName, NoPrintscreens ? "" : "video ");
+ exit(1);
}
- (void) ConnectToSessionManager (client_id);
+ (void) ConnectToSessionManager(client_id);
RestartPreviousState = False;
HandlingEvents = TRUE;
@@ -761,16 +760,16 @@ InitVariables(void)
Scr->IconBorderColor = black;
Scr->PointerForeground.pixel = black;
XQueryColor(dpy, Scr->TwmRoot.cmaps.cwins[0]->colormap->c,
- &Scr->PointerForeground);
+ &Scr->PointerForeground);
Scr->PointerBackground.pixel = white;
XQueryColor(dpy, Scr->TwmRoot.cmaps.cwins[0]->colormap->c,
- &Scr->PointerBackground);
+ &Scr->PointerBackground);
Scr->IconManagerC.fore = black;
Scr->IconManagerC.back = white;
Scr->IconManagerHighlight = black;
- Scr->FramePadding = 2; /* values that look "nice" on */
- Scr->TitlePadding = 8; /* 75 and 100dpi displays */
+ Scr->FramePadding = 2; /* values that look "nice" on */
+ Scr->TitlePadding = 8; /* 75 and 100dpi displays */
Scr->ButtonIndent = 1;
Scr->SizeStringOffset = 0;
Scr->BorderWidth = BW;
@@ -797,7 +796,7 @@ InitVariables(void)
Scr->DecorateTransients = FALSE;
Scr->IconifyByUnmapping = FALSE;
Scr->ShowIconManager = FALSE;
- Scr->IconManagerDontShow =FALSE;
+ Scr->IconManagerDontShow = FALSE;
Scr->BackingStore = TRUE;
Scr->SaveUnder = TRUE;
Scr->RandomPlacement = FALSE;
@@ -805,7 +804,7 @@ InitVariables(void)
Scr->Highlight = TRUE;
Scr->StackMode = TRUE;
Scr->TitleHighlight = TRUE;
- Scr->MoveDelta = 1; /* so that f.deltastop will work */
+ Scr->MoveDelta = 1; /* so that f.deltastop will work */
Scr->ZoomCount = 8;
Scr->SortIconMgr = FALSE;
Scr->Shadow = TRUE;
@@ -816,7 +815,7 @@ InitVariables(void)
Scr->FirstRegion = NULL;
Scr->LastRegion = NULL;
Scr->FirstTime = TRUE;
- Scr->HaveFonts = FALSE; /* i.e. not loaded yet */
+ Scr->HaveFonts = FALSE; /* i.e. not loaded yet */
Scr->CaseSensitive = TRUE;
Scr->WarpUnmapped = FALSE;
@@ -846,7 +845,7 @@ InitVariables(void)
}
void
-CreateFonts (void)
+CreateFonts(void)
{
GetFont(&Scr->TitleBarFont);
GetFont(&Scr->MenuFont);
@@ -858,77 +857,76 @@ CreateFonts (void)
}
void
-RestoreWithdrawnLocation (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)) {
+ 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;
+ GetGravityOffsets(tmp, &gravx, &gravy);
+ if (gravy < 0)
+ xwc.y -= tmp->title_height;
- if (bw != (unsigned)tmp->old_bw) {
- int xoff, yoff;
+ if (bw != (unsigned) tmp->old_bw) {
+ int xoff, yoff;
- if (!Scr->ClientBorderWidth) {
- xoff = gravx;
- yoff = gravy;
- } else {
- xoff = 0;
- yoff = 0;
- }
+ if (!Scr->ClientBorderWidth) {
+ xoff = gravx;
+ yoff = gravy;
+ }
+ else {
+ xoff = 0;
+ yoff = 0;
+ }
- xwc.x -= (xoff + 1) * tmp->old_bw;
- xwc.y -= (yoff + 1) * tmp->old_bw;
- }
- if (!Scr->ClientBorderWidth) {
- xwc.x += gravx * tmp->frame_bw;
- xwc.y += gravy * tmp->frame_bw;
- }
+ xwc.x -= (xoff + 1) * tmp->old_bw;
+ xwc.y -= (yoff + 1) * tmp->old_bw;
+ }
+ if (!Scr->ClientBorderWidth) {
+ xwc.x += gravx * tmp->frame_bw;
+ xwc.y += gravy * tmp->frame_bw;
+ }
- mask = (CWX | CWY);
- if (bw != (unsigned)tmp->old_bw) {
- xwc.border_width = tmp->old_bw;
- mask |= CWBorderWidth;
- }
+ mask = (CWX | CWY);
+ if (bw != (unsigned) tmp->old_bw) {
+ xwc.border_width = tmp->old_bw;
+ mask |= CWBorderWidth;
+ }
- XConfigureWindow (dpy, tmp->w, mask, &xwc);
+ XConfigureWindow(dpy, tmp->w, mask, &xwc);
- if (tmp->wmhints && (tmp->wmhints->flags & IconWindowHint)) {
- XUnmapWindow (dpy, tmp->wmhints->icon_window);
- }
+ if (tmp->wmhints && (tmp->wmhints->flags & IconWindowHint)) {
+ XUnmapWindow(dpy, tmp->wmhints->icon_window);
+ }
}
}
-
void
-Reborder (Time time)
+Reborder(Time time)
{
- TwmWindow *tmp; /* temp twm window structure */
+ 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);
- }
+ 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);
+ XUngrabServer(dpy);
+ SetFocus((TwmWindow *) NULL, time);
}
static void
@@ -943,15 +941,13 @@ sigHandler(int sig _X_UNUSED)
void
Done(XtPointer client_data _X_UNUSED, XtSignalId *si2 _X_UNUSED)
{
- if (dpy)
- {
- Reborder(CurrentTime);
- XCloseDisplay(dpy);
+ 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
@@ -967,15 +963,14 @@ TwmErrorHandler(Display *dpy2, 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 (dpy2, event, stderr);
+ 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(dpy2, event, stderr);
return 0;
}
-
static int
CatchRedirectError(Display *dpy2 _X_UNUSED, XErrorEvent *event)
{
diff --git a/src/twm.h b/src/twm.h
index dbb9980..1fe106d 100644
--- a/src/twm.h
+++ b/src/twm.h
@@ -50,12 +50,11 @@ from The Open Group.
*/
-
/***********************************************************************
*
* twm include file
*
- * 28-Oct-87 Thomas E. LaStrange File created
+ * 28-Oct-87 Thomas E. LaStrange File created
* 10-Oct-90 David M. Sternlicht Storeing saved colors on root
***********************************************************************/
@@ -63,7 +62,7 @@ from The Open Group.
#define _TWM_
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <X11/Xlib.h>
@@ -78,55 +77,55 @@ from The Open Group.
#define WithdrawnState 0
#endif
-#define PIXEL_ALREADY_TYPEDEFED /* for Xmu/Drawing.h */
+#define PIXEL_ALREADY_TYPEDEFED /* for Xmu/Drawing.h */
-typedef void (*SigProc)(int); /* type of function returned by signal() */
+typedef void (*SigProc) (int); /* type of function returned by signal() */
-#define BW 2 /* border width */
-#define BW2 4 /* border width * 2 */
+#define BW 2 /* border width */
+#define BW2 4 /* border width * 2 */
#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
+#define TRUE 1
+#define FALSE 0
#endif
#define NULLSTR ((char *) NULL)
-#define MAX_BUTTONS 16 /* max mouse buttons supported */
+#define MAX_BUTTONS 16 /* max mouse buttons supported */
/* info stings defines */
#define INFO_LINES 30
#define INFO_SIZE 200
/* contexts for button presses */
-#define C_NO_CONTEXT -1
-#define C_WINDOW 0
-#define C_TITLE 1
-#define C_ICON 2
-#define C_ROOT 3
-#define C_FRAME 4
-#define C_ICONMGR 5
-#define C_NAME 6
+#define C_NO_CONTEXT -1
+#define C_WINDOW 0
+#define C_TITLE 1
+#define C_ICON 2
+#define C_ROOT 3
+#define C_FRAME 4
+#define C_ICONMGR 5
+#define C_NAME 6
#define C_IDENTIFY 7
-#define NUM_CONTEXTS 8
+#define NUM_CONTEXTS 8
-#define C_WINDOW_BIT (1 << C_WINDOW)
-#define C_TITLE_BIT (1 << C_TITLE)
-#define C_ICON_BIT (1 << C_ICON)
-#define C_ROOT_BIT (1 << C_ROOT)
-#define C_FRAME_BIT (1 << C_FRAME)
-#define C_ICONMGR_BIT (1 << C_ICONMGR)
-#define C_NAME_BIT (1 << C_NAME)
+#define C_WINDOW_BIT (1 << C_WINDOW)
+#define C_TITLE_BIT (1 << C_TITLE)
+#define C_ICON_BIT (1 << C_ICON)
+#define C_ROOT_BIT (1 << C_ROOT)
+#define C_FRAME_BIT (1 << C_FRAME)
+#define C_ICONMGR_BIT (1 << C_ICONMGR)
+#define C_NAME_BIT (1 << C_NAME)
-#define C_ALL_BITS (C_WINDOW_BIT | C_TITLE_BIT | C_ICON_BIT |\
- C_ROOT_BIT | C_FRAME_BIT | C_ICONMGR_BIT)
+#define C_ALL_BITS (C_WINDOW_BIT | C_TITLE_BIT | C_ICON_BIT |\
+ C_ROOT_BIT | C_FRAME_BIT | C_ICONMGR_BIT)
/* modifiers for button presses */
-#define MOD_SIZE ((ShiftMask | ControlMask | Mod1Mask \
- | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) + 1)
+#define MOD_SIZE ((ShiftMask | ControlMask | Mod1Mask \
+ | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) + 1)
-#define TITLE_BAR_SPACE 1 /* 2 pixel space bordering chars */
-#define TITLE_BAR_FONT_HEIGHT 15 /* max of 15 pixel high chars */
+#define TITLE_BAR_SPACE 1 /* 2 pixel space bordering chars */
+#define TITLE_BAR_FONT_HEIGHT 15 /* max of 15 pixel high chars */
#define TITLE_BAR_HEIGHT (TITLE_BAR_FONT_HEIGHT+(2*TITLE_BAR_SPACE))
/* defines for zooming/unzooming */
@@ -137,167 +136,161 @@ typedef void (*SigProc)(int); /* type of function returned by signal() */
Gcv.background = fix_back;\
XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground,&Gcv)
-typedef struct MyFont
-{
- const char *name; /* name of the font */
- XFontStruct *font; /* font structure */
- XFontSet fontset; /* fontset structure */
- int height; /* height of the font */
- int y; /* Y coordinate to draw characters */
+typedef struct MyFont {
+ const char *name; /* name of the font */
+ XFontStruct *font; /* font structure */
+ XFontSet fontset; /* fontset structure */
+ int height; /* height of the font */
+ int y; /* Y coordinate to draw characters */
int ascent;
int descent;
} MyFont;
-typedef struct ColorPair
-{
+typedef struct ColorPair {
Pixel fore, back;
} ColorPair;
typedef struct _TitleButton {
- struct _TitleButton *next; /* next link in chain */
- const char *name; /* bitmap name in case of deferal */
- Pixmap bitmap; /* image to display in button */
- int srcx, srcy; /* from where to start copying */
- unsigned int width, height; /* size of pixmap */
- int dstx, dsty; /* to where to start copying */
- int func; /* function to execute */
- const char *action; /* optional action arg */
- struct MenuRoot *menuroot; /* menu to pop on F_MENU */
- Bool rightside; /* t: on right, f: on left */
+ struct _TitleButton *next; /* next link in chain */
+ const char *name; /* bitmap name in case of deferal */
+ Pixmap bitmap; /* image to display in button */
+ int srcx, srcy; /* from where to start copying */
+ unsigned int width, height; /* size of pixmap */
+ int dstx, dsty; /* to where to start copying */
+ int func; /* function to execute */
+ const char *action; /* optional action arg */
+ struct MenuRoot *menuroot; /* menu to pop on F_MENU */
+ Bool rightside; /* t: on right, f: on left */
} TitleButton;
typedef struct _TBWindow {
- Window window; /* which window in this frame */
- TitleButton *info; /* description of this window */
+ Window window; /* which window in this frame */
+ TitleButton *info; /* description of this window */
} TBWindow;
typedef struct _SqueezeInfo {
- int justify; /* left, center, right */
- int num; /* signed pixel count or numerator */
- int denom; /* 0 for pix count or denominator */
+ int justify; /* left, center, right */
+ int num; /* signed pixel count or numerator */
+ int denom; /* 0 for pix count or denominator */
} SqueezeInfo;
-#define J_LEFT 1
-#define J_CENTER 2
-#define J_RIGHT 3
+#define J_LEFT 1
+#define J_CENTER 2
+#define J_RIGHT 3
/* Colormap window entry for each window in WM_COLORMAP_WINDOWS
* ICCCM property.
*/
-typedef struct TwmColormap
-{
- Colormap c; /* Colormap id */
- int state; /* install(ability) state */
- unsigned long install_req; /* request number which installed it */
- Window w; /* window causing load of color table */
+typedef struct TwmColormap {
+ Colormap c; /* Colormap id */
+ int state; /* install(ability) state */
+ unsigned long install_req; /* request number which installed it */
+ Window w; /* window causing load of color table */
int refcnt;
} TwmColormap;
-#define CM_INSTALLABLE 1
-#define CM_INSTALLED 2
-#define CM_INSTALL 4
+#define CM_INSTALLABLE 1
+#define CM_INSTALLED 2
+#define CM_INSTALL 4
-typedef struct ColormapWindow
-{
- Window w; /* Window id */
- TwmColormap *colormap; /* Colormap for this window */
- int visibility; /* Visibility of this window */
+typedef struct ColormapWindow {
+ Window w; /* Window id */
+ TwmColormap *colormap; /* Colormap for this window */
+ int visibility; /* Visibility of this window */
int refcnt;
} ColormapWindow;
-typedef struct Colormaps
-{
- ColormapWindow **cwins; /* current list of colormap windows */
- int number_cwins; /* number of elements in current list */
- char *scoreboard; /* conflicts between installable colortables */
+typedef struct Colormaps {
+ ColormapWindow **cwins; /* current list of colormap windows */
+ int number_cwins; /* number of elements in current list */
+ char *scoreboard; /* conflicts between installable colortables */
} Colormaps;
#define ColormapsScoreboardLength(cm) (size_t)((cm)->number_cwins * \
- ((cm)->number_cwins - 1) / 2)
+ ((cm)->number_cwins - 1) / 2)
/* for each window that is on the display, one of these structures
* is allocated and linked into a list
*/
-typedef struct TwmWindow
-{
- struct TwmWindow *next; /* next twm window */
- struct TwmWindow *prev; /* previous twm window */
- Window w; /* the child window */
- int old_bw; /* border width before reparenting */
- Window frame; /* the frame window */
- Window title_w; /* the title bar window */
- Window hilite_w; /* the hilite window */
+typedef struct TwmWindow {
+ struct TwmWindow *next; /* next twm window */
+ struct TwmWindow *prev; /* previous twm window */
+ Window w; /* the child window */
+ int old_bw; /* border width before reparenting */
+ Window frame; /* the frame window */
+ Window title_w; /* the title bar window */
+ Window hilite_w; /* the hilite window */
Pixmap gray;
- Window icon_w; /* the icon window */
- Window icon_bm_w; /* the icon bitmap window */
- int frame_x; /* x position of frame */
- int frame_y; /* y position of frame */
- int frame_width; /* width of frame */
- int frame_height; /* height of frame */
- int frame_bw; /* borderwidth of frame */
+ Window icon_w; /* the icon window */
+ Window icon_bm_w; /* the icon bitmap window */
+ int frame_x; /* x position of frame */
+ int frame_y; /* y position of frame */
+ int frame_width; /* width of frame */
+ int frame_height; /* height of frame */
+ int frame_bw; /* borderwidth of frame */
int title_x;
int title_y;
- int icon_x; /* icon text x coordinate */
- int icon_y; /* icon text y coordiante */
- int icon_w_width; /* width of the icon window */
- int icon_w_height; /* height of the icon window */
- int icon_width; /* width of the icon bitmap */
- int icon_height; /* height of the icon bitmap */
- int title_height; /* height of the title bar */
- int title_width; /* width of the title bar */
- char *full_name; /* full name of the window */
- char *name; /* name of the window */
- char *icon_name; /* name of the icon */
- int name_width; /* width of name text */
- int highlightx; /* start of highlight window */
- int rightx; /* start of right buttons */
- XWindowAttributes attr; /* the child window attributes */
- XSizeHints hints; /* normal hints */
- XWMHints *wmhints; /* WM hints */
- Window group; /* group ID */
+ int icon_x; /* icon text x coordinate */
+ int icon_y; /* icon text y coordiante */
+ int icon_w_width; /* width of the icon window */
+ int icon_w_height; /* height of the icon window */
+ int icon_width; /* width of the icon bitmap */
+ int icon_height; /* height of the icon bitmap */
+ int title_height; /* height of the title bar */
+ int title_width; /* width of the title bar */
+ char *full_name; /* full name of the window */
+ char *name; /* name of the window */
+ char *icon_name; /* name of the icon */
+ int name_width; /* width of name text */
+ int highlightx; /* start of highlight window */
+ int rightx; /* start of right buttons */
+ XWindowAttributes attr; /* the child window attributes */
+ XSizeHints hints; /* normal hints */
+ XWMHints *wmhints; /* WM hints */
+ Window group; /* group ID */
XClassHint class;
struct WList *list;
/***********************************************************************
* color definitions per window
**********************************************************************/
- Pixel border; /* border color */
- Pixel icon_border; /* border color */
+ Pixel border; /* border color */
+ Pixel icon_border; /* border color */
ColorPair border_tile;
ColorPair title;
ColorPair iconc;
- short iconified; /* has the window ever been iconified? */
- short icon; /* is the window an icon now ? */
- short icon_on; /* is the icon visible */
- short mapped; /* is the window mapped ? */
- short auto_raise; /* should we auto-raise this window ? */
- short forced; /* has had an icon forced upon it */
- short icon_not_ours; /* icon pixmap or window supplied to us */
- short icon_moved; /* user explicitly moved the icon */
- short highlight; /* should highlight this window */
- short stackmode; /* honor stackmode requests */
- short iconify_by_unmapping; /* unmap window to iconify it */
- short iconmgr; /* this is an icon manager window */
- short transient; /* this is a transient window */
- Window transientfor; /* window contained in XA_XM_TRANSIENT_FOR */
- short titlehighlight; /* should I highlight the title bar */
- struct IconMgr *iconmgrp; /* pointer to it if this is an icon manager */
- int save_frame_x; /* x position of frame */
- int save_frame_y; /* y position of frame */
- int save_frame_width; /* width of frame */
- int save_frame_height; /* height of frame */
- short zoomed; /* is the window zoomed? */
- short wShaped; /* this window has a bounding shape */
- unsigned long protocols; /* which protocols this window handles */
- Colormaps cmaps; /* colormaps for this application */
+ short iconified; /* has the window ever been iconified? */
+ short icon; /* is the window an icon now ? */
+ short icon_on; /* is the icon visible */
+ short mapped; /* is the window mapped ? */
+ short auto_raise; /* should we auto-raise this window ? */
+ short forced; /* has had an icon forced upon it */
+ short icon_not_ours; /* icon pixmap or window supplied to us */
+ short icon_moved; /* user explicitly moved the icon */
+ short highlight; /* should highlight this window */
+ short stackmode; /* honor stackmode requests */
+ short iconify_by_unmapping; /* unmap window to iconify it */
+ short iconmgr; /* this is an icon manager window */
+ short transient; /* this is a transient window */
+ Window transientfor; /* window contained in XA_XM_TRANSIENT_FOR */
+ short titlehighlight; /* should I highlight the title bar */
+ struct IconMgr *iconmgrp; /* pointer to it if this is an icon manager */
+ int save_frame_x; /* x position of frame */
+ int save_frame_y; /* y position of frame */
+ int save_frame_width; /* width of frame */
+ int save_frame_height; /* height of frame */
+ short zoomed; /* is the window zoomed? */
+ short wShaped; /* this window has a bounding shape */
+ unsigned long protocols; /* which protocols this window handles */
+ Colormaps cmaps; /* colormaps for this application */
TBWindow *titlebuttons;
- SqueezeInfo *squeeze_info; /* should the title be squeezed? */
+ SqueezeInfo *squeeze_info; /* should the title be squeezed? */
struct {
- struct TwmWindow *next, *prev;
- Bool cursor_valid;
- int curs_x, curs_y;
+ struct TwmWindow *next, *prev;
+ Bool cursor_valid;
+ int curs_x, curs_y;
} ring;
- Bool nameChanged; /* did WM_NAME ever change? */
+ Bool nameChanged; /* did WM_NAME ever change? */
/* did the user ever change the width/height? {yes, no, or unknown} */
@@ -306,9 +299,7 @@ typedef struct TwmWindow
} TwmWindow;
-
-typedef struct TWMWinConfigEntry
-{
+typedef struct TWMWinConfigEntry {
struct TWMWinConfigEntry *next;
int tag;
char *client_id;
@@ -326,37 +317,41 @@ typedef struct TWMWinConfigEntry
Bool height_ever_changed_by_user;
} TWMWinConfigEntry;
+#define DoesWmTakeFocus (1L << 0)
+#define DoesWmSaveYourself (1L << 1)
+#define DoesWmDeleteWindow (1L << 2)
-#define DoesWmTakeFocus (1L << 0)
-#define DoesWmSaveYourself (1L << 1)
-#define DoesWmDeleteWindow (1L << 2)
-
-#define TBPM_DOT ":dot" /* name of titlebar pixmap for dot */
-#define TBPM_ICONIFY ":iconify" /* same image as dot */
-#define TBPM_RESIZE ":resize" /* name of titlebar pixmap for resize button */
-#define TBPM_XLOGO ":xlogo" /* name of titlebar pixmap for xlogo */
-#define TBPM_DELETE ":delete" /* same image as xlogo */
-#define TBPM_MENU ":menu" /* name of titlebar pixmap for menus */
-#define TBPM_QUESTION ":question" /* name of unknown titlebar pixmap */
+#define TBPM_DOT ":dot" /* name of titlebar pixmap for dot */
+#define TBPM_ICONIFY ":iconify" /* same image as dot */
+#define TBPM_RESIZE ":resize" /* name of titlebar pixmap for resize button */
+#define TBPM_XLOGO ":xlogo" /* name of titlebar pixmap for xlogo */
+#define TBPM_DELETE ":delete" /* same image as xlogo */
+#define TBPM_MENU ":menu" /* name of titlebar pixmap for menus */
+#define TBPM_QUESTION ":question" /* name of unknown titlebar pixmap */
#include <X11/Xosdefs.h>
#include <stdlib.h>
-extern void CreateFonts ( void );
-extern void RestoreWithdrawnLocation ( TwmWindow *tmp );
-extern void Reborder( Time time);
-extern void Done( XtPointer, XtSignalId * ) _X_NORETURN;
-extern void ComputeCommonTitleOffsets ( void );
-extern void ComputeTitleLocation ( TwmWindow *tmp );
-extern void ComputeWindowTitleOffsets ( TwmWindow *tmp_win, int width, Bool squeeze );
+extern void CreateFonts(void);
+extern void RestoreWithdrawnLocation(TwmWindow *tmp);
+extern void Reborder(Time time);
+extern void
+Done(XtPointer, XtSignalId *)
+ _X_NORETURN;
+extern void
+ComputeCommonTitleOffsets(void);
+extern void
+ComputeTitleLocation(TwmWindow *tmp);
+extern void
+ComputeWindowTitleOffsets(TwmWindow *tmp_win, int width, Bool squeeze);
extern char *ProgramName;
extern Display *dpy;
extern XtAppContext appContext;
-extern Window ResizeWindow; /* the window we are resizing */
-extern int HasShape; /* this server supports Shape extension */
-extern int HasSync; /* this server supports SYNC extension */
+extern Window ResizeWindow; /* the window we are resizing */
+extern int HasShape; /* this server supports Shape extension */
+extern int HasSync; /* this server supports SYNC extension */
#ifdef HAVE_XRANDR
-extern int HasXrandr; /* this server supports Xrandr extension */
+extern int HasXrandr; /* this server supports Xrandr extension */
#endif
extern int PreviousScreen;
@@ -390,9 +385,12 @@ extern int InfoLines;
extern char Info[][INFO_SIZE];
extern int Argc;
extern char **Argv;
-extern void NewFontCursor ( Cursor *cp, const char *str );
-extern void NewBitmapCursor ( Cursor *cp, char *source, char *mask );
-extern Pixmap CreateMenuIcon ( int height, unsigned int *widthp, unsigned int *heightp );
+extern void
+NewFontCursor(Cursor *cp, const char *str);
+extern void
+NewBitmapCursor(Cursor *cp, char *source, char *mask);
+extern Pixmap
+CreateMenuIcon(int height, unsigned int *widthp, unsigned int *heightp);
extern Bool ErrorOccurred;
extern XErrorEvent LastErrorEvent;
@@ -400,12 +398,16 @@ extern XErrorEvent LastErrorEvent;
#define ResetError() (ErrorOccurred = False)
extern Bool RestartPreviousState;
-extern Bool GetWMState ( Window w, int *statep, Window *iwp );
+extern Bool
+GetWMState(Window w, int *statep, Window *iwp);
-extern void twmrc_error_prefix ( void );
+extern void
+twmrc_error_prefix(void);
-extern int yyparse ( void );
-extern int yylex ( void );
+extern int
+yyparse(void);
+extern int
+yylex(void);
extern Atom TwmAtoms[];
@@ -419,16 +421,16 @@ extern int XrandrEventBase;
extern int XrandrErrorBase;
#endif
-#define _XA_MIT_PRIORITY_COLORS TwmAtoms[0]
-#define _XA_WM_CHANGE_STATE TwmAtoms[1]
-#define _XA_WM_STATE TwmAtoms[2]
-#define _XA_WM_COLORMAP_WINDOWS TwmAtoms[3]
-#define _XA_WM_PROTOCOLS TwmAtoms[4]
-#define _XA_WM_TAKE_FOCUS TwmAtoms[5]
-#define _XA_WM_SAVE_YOURSELF TwmAtoms[6]
-#define _XA_WM_DELETE_WINDOW TwmAtoms[7]
-#define _XA_SM_CLIENT_ID TwmAtoms[8]
-#define _XA_WM_CLIENT_LEADER TwmAtoms[9]
-#define _XA_WM_WINDOW_ROLE TwmAtoms[10]
-
-#endif /* _TWM_ */
+#define _XA_MIT_PRIORITY_COLORS TwmAtoms[0]
+#define _XA_WM_CHANGE_STATE TwmAtoms[1]
+#define _XA_WM_STATE TwmAtoms[2]
+#define _XA_WM_COLORMAP_WINDOWS TwmAtoms[3]
+#define _XA_WM_PROTOCOLS TwmAtoms[4]
+#define _XA_WM_TAKE_FOCUS TwmAtoms[5]
+#define _XA_WM_SAVE_YOURSELF TwmAtoms[6]
+#define _XA_WM_DELETE_WINDOW TwmAtoms[7]
+#define _XA_SM_CLIENT_ID TwmAtoms[8]
+#define _XA_WM_CLIENT_LEADER TwmAtoms[9]
+#define _XA_WM_WINDOW_ROLE TwmAtoms[10]
+
+#endif /* _TWM_ */
diff --git a/src/util.c b/src/util.c
index d52324a..34d5623 100644
--- a/src/util.c
+++ b/src/util.c
@@ -49,12 +49,11 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* utility routines for twm
*
- * 28-Oct-87 Thomas E. LaStrange File created
+ * 28-Oct-87 Thomas E. LaStrange File created
*
***********************************************************************/
@@ -68,16 +67,11 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xmu/Drawing.h>
#include <X11/Xmu/CharSet.h>
-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 );
+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;
@@ -90,98 +84,99 @@ int HotX, HotY;
* \param bw border width of the frame
* \param th title height
*/
-void MoveOutline(Window root, int x, int y, int width, int height, int bw, int 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;
+ 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;
+ && lastBW == bw && th == lastTH)
+ return;
r = outline;
#define DRAWIT() \
- if (lastWidth || lastHeight) \
- { \
- xl = lastx; \
- xr = lastx + lastWidth - 1; \
- yt = lasty; \
- yb = lasty + lastHeight - 1; \
- xinnerl = xl + lastBW; \
- xinnerr = xr - lastBW; \
- yinnert = yt + lastTH + lastBW; \
- yinnerb = yb - lastBW; \
- xthird = (xinnerr - xinnerl) / 3; \
- ythird = (yinnerb - yinnert) / 3; \
- \
- r->x1 = (short)(xl); \
- r->y1 = (short)(yt); \
- r->x2 = (short)(xr); \
- r->y2 = (short)(yt); \
- r++; \
- \
- r->x1 = (short)(xl); \
- r->y1 = (short)(yb); \
- r->x2 = (short)(xr); \
- r->y2 = (short)(yb); \
- r++; \
- \
- r->x1 = (short)(xl); \
- r->y1 = (short)(yt); \
- r->x2 = (short)(xl); \
- r->y2 = (short)(yb); \
- r++; \
- \
- r->x1 = (short)(xr); \
- r->y1 = (short)(yt); \
- r->x2 = (short)(xr); \
- r->y2 = (short)(yb); \
- r++; \
- \
- r->x1 = (short)(xinnerl + xthird); \
- r->y1 = (short)(yinnert); \
- r->x2 = (short)(r->x1); \
- r->y2 = (short)(yinnerb); \
- r++; \
- \
- r->x1 = (short)(xinnerl + (2 * xthird)); \
- r->y1 = (short)(yinnert); \
- r->x2 = (short)(r->x1); \
- r->y2 = (short)(yinnerb); \
- r++; \
- \
- r->x1 = (short)(xinnerl); \
- r->y1 = (short)(yinnert + ythird); \
- r->x2 = (short)(xinnerr); \
- r->y2 = (short)(r->y1); \
- r++; \
- \
- r->x1 = (short)(xinnerl); \
- r->y1 = (short)(yinnert + (2 * ythird)); \
- r->x2 = (short)(xinnerr); \
- r->y2 = (short)(r->y1); \
- r++; \
- \
- if (lastTH != 0) { \
- r->x1 = (short)(xl); \
- r->y1 = (short)(yt + lastTH); \
- r->x2 = (short)(xr); \
- r->y2 = (short)(r->y1); \
- r++; \
- } \
+ if (lastWidth || lastHeight) \
+ { \
+ xl = lastx; \
+ xr = lastx + lastWidth - 1; \
+ yt = lasty; \
+ yb = lasty + lastHeight - 1; \
+ xinnerl = xl + lastBW; \
+ xinnerr = xr - lastBW; \
+ yinnert = yt + lastTH + lastBW; \
+ yinnerb = yb - lastBW; \
+ xthird = (xinnerr - xinnerl) / 3; \
+ ythird = (yinnerb - yinnert) / 3; \
+ \
+ r->x1 = (short)(xl); \
+ r->y1 = (short)(yt); \
+ r->x2 = (short)(xr); \
+ r->y2 = (short)(yt); \
+ r++; \
+ \
+ r->x1 = (short)(xl); \
+ r->y1 = (short)(yb); \
+ r->x2 = (short)(xr); \
+ r->y2 = (short)(yb); \
+ r++; \
+ \
+ r->x1 = (short)(xl); \
+ r->y1 = (short)(yt); \
+ r->x2 = (short)(xl); \
+ r->y2 = (short)(yb); \
+ r++; \
+ \
+ r->x1 = (short)(xr); \
+ r->y1 = (short)(yt); \
+ r->x2 = (short)(xr); \
+ r->y2 = (short)(yb); \
+ r++; \
+ \
+ r->x1 = (short)(xinnerl + xthird); \
+ r->y1 = (short)(yinnert); \
+ r->x2 = (short)(r->x1); \
+ r->y2 = (short)(yinnerb); \
+ r++; \
+ \
+ r->x1 = (short)(xinnerl + (2 * xthird)); \
+ r->y1 = (short)(yinnert); \
+ r->x2 = (short)(r->x1); \
+ r->y2 = (short)(yinnerb); \
+ r++; \
+ \
+ r->x1 = (short)(xinnerl); \
+ r->y1 = (short)(yinnert + ythird); \
+ r->x2 = (short)(xinnerr); \
+ r->y2 = (short)(r->y1); \
+ r++; \
+ \
+ r->x1 = (short)(xinnerl); \
+ r->y1 = (short)(yinnert + (2 * ythird)); \
+ r->x2 = (short)(xinnerr); \
+ r->y2 = (short)(r->y1); \
+ r++; \
+ \
+ if (lastTH != 0) { \
+ r->x1 = (short)(xl); \
+ r->y1 = (short)(yt + lastTH); \
+ r->x2 = (short)(xr); \
+ r->y2 = (short)(r->y1); \
+ r++; \
+ } \
}
/* undraw the old one, if any */
- DRAWIT ();
+ DRAWIT();
lastx = x;
lasty = y;
@@ -191,14 +186,12 @@ void MoveOutline(Window root, int x, int y, int width, int height, int bw, int t
lastTH = th;
/* draw the new one, if any */
- DRAWIT ();
+ DRAWIT();
#undef DRAWIT
-
- if (r != outline)
- {
- XDrawSegments(dpy, root, Scr->DrawGC, outline, (int)(r - outline));
+ if (r != outline) {
+ XDrawSegments(dpy, root, Scr->DrawGC, outline, (int) (r - outline));
}
}
@@ -211,39 +204,40 @@ void MoveOutline(Window root, int x, int y, int width, int height, int bw, int t
void
Zoom(Window wf, Window wt)
{
- int fx, fy, tx, ty; /* from, to */
- unsigned int fw, fh, tw, th; /* from, to */
+ 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 (!Scr->DoZoom || Scr->ZoomCount < 1)
+ return;
- if (wf == None || wt == None) 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);
+ 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 */
+ 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);
+ 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);
}
}
@@ -251,7 +245,7 @@ Zoom(Window wf, Window wt)
* expand the tilde character to HOME if it is the first
* character of the filename
*
- * \return a pointer to the new name
+ * \return a pointer to the new name
*
* \param name the filename to expand
*/
@@ -260,16 +254,19 @@ ExpandFilename(const char *name)
{
char *newname;
- if (name[0] != '~') return strdup(name);
+ if (name[0] != '~')
+ return strdup(name);
- newname = malloc ((size_t)HomeLen + strlen(name) + 2);
+ newname = malloc((size_t) HomeLen + strlen(name) + 2);
if (!newname) {
- fprintf (stderr,
- "%s: unable to allocate %ld bytes to expand filename %s/%s\n",
- ProgramName, (unsigned long)HomeLen + (unsigned long)strlen(name) + 2,
- Home, &name[1]);
- } else {
- (void) sprintf (newname, "%s/%s", Home, &name[1]);
+ fprintf(stderr,
+ "%s: unable to allocate %ld bytes to expand filename %s/%s\n",
+ ProgramName,
+ (unsigned long) HomeLen + (unsigned long) strlen(name) + 2,
+ Home, &name[1]);
+ }
+ else {
+ (void) sprintf(newname, "%s/%s", Home, &name[1]);
}
return newname;
@@ -283,29 +280,30 @@ ExpandFilename(const char *name)
void
GetUnknownIcon(const 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);
+ if ((Scr->UnknownPm = GetBitmap(name)) != None) {
+ XGetGeometry(dpy, Scr->UnknownPm, &JunkRoot, &JunkX, &JunkY,
+ (unsigned int *) &Scr->UnknownWidth,
+ (unsigned int *) &Scr->UnknownHeight, &JunkBW, &JunkDepth);
}
}
/**
- * FindBitmap - read in a bitmap file and return size
+ * FindBitmap - read in a bitmap file and return size
*
* \return pixmap associated with bitmap
*
* \param name filename to read
* \param[out] widthp pointer to width of bitmap
- * \param[out] heightp pointer to height of bitmap
+ * \param[out] heightp pointer to height of bitmap
*/
Pixmap
-FindBitmap (const char *name, unsigned *widthp, unsigned *heightp)
+FindBitmap(const char *name, unsigned *widthp, unsigned *heightp)
{
char *bigname;
Pixmap pm;
- if (!name) return None;
+ if (!name)
+ return None;
/*
* Names of the form :name refer to hardcoded images that are scaled to
@@ -313,27 +311,29 @@ FindBitmap (const char *name, unsigned *widthp, unsigned *heightp)
* menu symbol as well....
*/
if (name[0] == ':') {
- int i;
- static struct {
- const char *name;
- Pixmap (*proc)(unsigned int *, unsigned int *);
- } pmtab[] = {
- { TBPM_DOT, CreateDotPixmap },
- { TBPM_ICONIFY, CreateDotPixmap },
- { TBPM_RESIZE, CreateResizePixmap },
- { TBPM_XLOGO, CreateXLogoPixmap },
- { TBPM_DELETE, CreateXLogoPixmap },
- { TBPM_MENU, CreateMenuPixmap },
- { TBPM_QUESTION, CreateQuestionPixmap },
- };
-
- for (i = 0; (size_t)i < (sizeof pmtab)/(sizeof pmtab[0]); i++) {
- if (XmuCompareISOLatin1 (pmtab[i].name, name) == 0)
- return (*pmtab[i].proc) (widthp, heightp);
- }
- fprintf (stderr, "%s: no such built-in bitmap \"%s\"\n",
- ProgramName, name);
- return None;
+ int i;
+ /* *INDENT-OFF* */
+ static struct {
+ const char *name;
+ Pixmap (*proc)(unsigned int *, unsigned int *);
+ } pmtab[] = {
+ { TBPM_DOT, CreateDotPixmap },
+ { TBPM_ICONIFY, CreateDotPixmap },
+ { TBPM_RESIZE, CreateResizePixmap },
+ { TBPM_XLOGO, CreateXLogoPixmap },
+ { TBPM_DELETE, CreateXLogoPixmap },
+ { TBPM_MENU, CreateMenuPixmap },
+ { TBPM_QUESTION, CreateQuestionPixmap },
+ };
+ /* *INDENT-ON* */
+
+ for (i = 0; (size_t) i < (sizeof pmtab) / (sizeof pmtab[0]); i++) {
+ if (XmuCompareISOLatin1(pmtab[i].name, name) == 0)
+ return (*pmtab[i].proc) (widthp, heightp);
+ }
+ fprintf(stderr, "%s: no such built-in bitmap \"%s\"\n",
+ ProgramName, name);
+ return None;
}
/*
@@ -341,80 +341,86 @@ FindBitmap (const char *name, unsigned *widthp, unsigned *heightp)
* are used. If the bigname is different from name, bigname will need to
* be freed.
*/
- bigname = ExpandFilename (name);
- if (!bigname) return None;
+ bigname = ExpandFilename(name);
+ if (!bigname)
+ return None;
/*
* look along bitmapFilePath resource same as toolkit clients
*/
- pm = XmuLocateBitmapFile (ScreenOfDisplay(dpy, Scr->screen), bigname, NULL,
- 0, (int *)widthp, (int *)heightp, &HotX, &HotY);
+ pm = XmuLocateBitmapFile(ScreenOfDisplay(dpy, Scr->screen), bigname, NULL,
+ 0, (int *) widthp, (int *) heightp, &HotX, &HotY);
if (pm == None && Scr->IconDirectory && bigname[0] != '/') {
- free (bigname);
- /*
- * Attempt to find icon in old IconDirectory (now obsolete)
- */
- bigname = malloc (strlen(name) + strlen(Scr->IconDirectory) + 2);
- if (!bigname) {
- fprintf (stderr,
- "%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;
- }
- }
- free (bigname);
+ free(bigname);
+ /*
+ * Attempt to find icon in old IconDirectory (now obsolete)
+ */
+ bigname = malloc(strlen(name) + strlen(Scr->IconDirectory) + 2);
+ if (!bigname) {
+ fprintf(stderr,
+ "%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;
+ }
+ }
+ free(bigname);
if (pm == None) {
- fprintf (stderr, "%s: unable to find bitmap \"%s\"\n",
- ProgramName, name);
+ fprintf(stderr, "%s: unable to find bitmap \"%s\"\n",
+ ProgramName, name);
}
return pm;
}
Pixmap
-GetBitmap (const char *name)
+GetBitmap(const char *name)
{
- return FindBitmap (name, &JunkWidth, &JunkHeight);
+ return FindBitmap(name, &JunkWidth, &JunkHeight);
}
void
-InsertRGBColormap (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 = malloc (sizeof (StdCmap));
- if (!sc) {
- fprintf (stderr, "%s: unable to allocate %ld bytes for StdCmap\n",
- ProgramName, (unsigned long)sizeof (StdCmap));
- return;
- }
- replace = False;
- }
-
- if (replace) { /* just update contents */
- if (sc->maps) XFree (sc->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;
+ 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 = malloc(sizeof(StdCmap));
+ if (!sc) {
+ fprintf(stderr, "%s: unable to allocate %ld bytes for StdCmap\n",
+ ProgramName, (unsigned long) sizeof(StdCmap));
+ return;
+ }
+ replace = False;
+ }
+
+ if (replace) { /* just update contents */
+ if (sc->maps)
+ XFree(sc->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;
@@ -423,21 +429,27 @@ InsertRGBColormap (Atom a, XStandardColormap *maps, int nmaps, Bool replace)
}
void
-RemoveRGBColormap (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->atom == a)
+ break;
+ prev = sc;
}
- if (sc) { /* found one */
- if (sc->maps) XFree (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;
+ if (sc) { /* found one */
+ if (sc->maps)
+ XFree(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;
}
@@ -449,17 +461,18 @@ LocateStandardColormaps(void)
int natoms;
int i;
- atoms = XListProperties (dpy, Scr->Root, &natoms);
+ atoms = XListProperties(dpy, Scr->Root, &natoms);
for (i = 0; i < natoms; i++) {
- XStandardColormap *maps = NULL;
- int nmaps;
+ 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 (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 (atoms);
+ if (atoms)
+ XFree(atoms);
return;
}
@@ -472,70 +485,70 @@ GetColor(int kind, Pixel *what, const char *name)
#ifndef TOM
if (!Scr->FirstTime)
- return;
+ 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;
-
- /* parse the named color */
- if (name[0] != '#')
- stat = XParseColor (dpy, cmap, name, &color);
- if (!stat)
- {
- fprintf (stderr, "%s: invalid color name \"%s\"\n",
- ProgramName, name);
- return;
- }
-
- /*
- * look through the list of standard colormaps (check cache first)
- */
- if (Scr->StdCmapInfo.mru && Scr->StdCmapInfo.mru->maps &&
- (Scr->StdCmapInfo.mru->maps[Scr->StdCmapInfo.mruindex].colormap ==
- cmap)) {
- stdcmap = &(Scr->StdCmapInfo.mru->maps[Scr->StdCmapInfo.mruindex]);
- } else {
- StdCmap *sc;
-
- for (sc = Scr->StdCmapInfo.head; sc; sc = sc->next) {
- int i;
-
- for (i = 0; i < sc->nmaps; i++) {
- if (sc->maps[i].colormap == cmap) {
- Scr->StdCmapInfo.mru = sc;
- Scr->StdCmapInfo.mruindex = i;
- stdcmap = &(sc->maps[i]);
- goto gotit;
- }
- }
- }
- }
-
- gotit:
- if (stdcmap) {
+ 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;
+
+ /* parse the named color */
+ if (name[0] != '#')
+ stat = XParseColor(dpy, cmap, name, &color);
+ if (!stat) {
+ fprintf(stderr, "%s: invalid color name \"%s\"\n",
+ ProgramName, name);
+ return;
+ }
+
+ /*
+ * look through the list of standard colormaps (check cache first)
+ */
+ if (Scr->StdCmapInfo.mru && Scr->StdCmapInfo.mru->maps &&
+ (Scr->StdCmapInfo.mru->maps[Scr->StdCmapInfo.mruindex].colormap ==
+ cmap)) {
+ stdcmap = &(Scr->StdCmapInfo.mru->maps[Scr->StdCmapInfo.mruindex]);
+ }
+ else {
+ StdCmap *sc;
+
+ for (sc = Scr->StdCmapInfo.head; sc; sc = sc->next) {
+ int i;
+
+ for (i = 0; i < sc->nmaps; i++) {
+ if (sc->maps[i].colormap == cmap) {
+ Scr->StdCmapInfo.mru = sc;
+ Scr->StdCmapInfo.mruindex = i;
+ stdcmap = &(sc->maps[i]);
+ goto gotit;
+ }
+ }
+ }
+ }
+
+ gotit:
+ if (stdcmap) {
color.pixel = (stdcmap->base_pixel +
- ((Pixel)(((float)color.red / 65535.0) *
- (double)stdcmap->red_max + 0.5) *
- stdcmap->red_mult) +
- ((Pixel)(((float)color.green /65535.0) *
- (double)stdcmap->green_max + 0.5) *
- stdcmap->green_mult) +
- ((Pixel)(((float)color.blue / 65535.0) *
- (double)stdcmap->blue_max + 0.5) *
- stdcmap->blue_mult));
- } else {
- fprintf (stderr, "%s: unable to allocate color \"%s\"\n",
- ProgramName, name);
- return;
- }
+ ((Pixel) (((float) color.red / 65535.0) *
+ (double) stdcmap->red_max + 0.5) *
+ stdcmap->red_mult) +
+ ((Pixel) (((float) color.green / 65535.0) *
+ (double) stdcmap->green_max + 0.5) *
+ stdcmap->green_mult) +
+ ((Pixel) (((float) color.blue / 65535.0) *
+ (double) stdcmap->blue_max + 0.5) *
+ stdcmap->blue_mult));
+ }
+ else {
+ fprintf(stderr, "%s: unable to allocate color \"%s\"\n",
+ ProgramName, name);
+ return;
+ }
}
*what = color.pixel;
@@ -549,20 +562,17 @@ GetColorValue(int kind, XColor *what, const char *name)
#ifndef TOM
if (!Scr->FirstTime)
- return;
+ return;
#endif
if (Scr->Monochrome != kind)
- return;
+ return;
- if (!XLookupColor (dpy, cmap, name, what, &junkcolor))
- {
- fprintf (stderr, "%s: invalid color name \"%s\"\n",
- ProgramName, name);
+ if (!XLookupColor(dpy, cmap, name, what, &junkcolor)) {
+ fprintf(stderr, "%s: invalid color name \"%s\"\n", ProgramName, name);
}
- else
- {
- what->pixel = AllPlanes;
+ else {
+ what->pixel = AllPlanes;
}
}
@@ -581,41 +591,42 @@ FindFontSet(MyFont *font, const char *fontname)
int fnum;
if (use_fontset) {
- if (font->fontset != NULL){
- XFreeFontSet(dpy, font->fontset);
- }
-
- if( (font->fontset = XCreateFontSet(dpy, fontname,
- &missing_charset_list_return,
- &missing_charset_count_return,
- &def_string_return)) == NULL) {
- return False;
- }
- for(i=0; i<missing_charset_count_return; i++){
- printf("%s: warning: font for charset %s is lacking.\n",
- ProgramName, missing_charset_list_return[i]);
- }
-
- font_extents = XExtentsOfFontSet(font->fontset);
- fnum = XFontsOfFontSet(font->fontset, &xfonts, &font_names);
- for( i = 0, ascent = 0, descent = 0; i<fnum; i++){
- if (ascent < (*xfonts)->ascent) ascent = (*xfonts)->ascent;
- if (descent < (*xfonts)->descent) descent = (*xfonts)->descent;
- xfonts++;
- }
- font->height = font_extents->max_logical_extent.height;
- font->y = ascent;
- font->ascent = ascent;
- font->descent = descent;
- return True;
+ if (font->fontset != NULL) {
+ XFreeFontSet(dpy, font->fontset);
+ }
+
+ if ((font->fontset = XCreateFontSet(dpy, fontname,
+ &missing_charset_list_return,
+ &missing_charset_count_return,
+ &def_string_return)) == NULL) {
+ return False;
+ }
+ for (i = 0; i < missing_charset_count_return; i++) {
+ printf("%s: warning: font for charset %s is lacking.\n",
+ ProgramName, missing_charset_list_return[i]);
+ }
+
+ font_extents = XExtentsOfFontSet(font->fontset);
+ fnum = XFontsOfFontSet(font->fontset, &xfonts, &font_names);
+ for (i = 0, ascent = 0, descent = 0; i < fnum; i++) {
+ if (ascent < (*xfonts)->ascent)
+ ascent = (*xfonts)->ascent;
+ if (descent < (*xfonts)->descent)
+ descent = (*xfonts)->descent;
+ xfonts++;
+ }
+ font->height = font_extents->max_logical_extent.height;
+ font->y = ascent;
+ font->ascent = ascent;
+ font->descent = descent;
+ return True;
}
if (font->font != NULL)
- XFreeFont(dpy, font->font);
+ XFreeFont(dpy, font->font);
- if ((font->font = XLoadQueryFont(dpy, fontname)) == NULL)
- {
- return False;
+ if ((font->font = XLoadQueryFont(dpy, fontname)) == NULL) {
+ return False;
}
font->height = font->font->ascent + font->font->descent;
font->y = font->font->ascent;
@@ -640,18 +651,19 @@ GetFont(MyFont *font)
const char *deffontname = "fixed";
if (!FindFontSet(font, font->name)) {
- const char *what = "fonts";
-
- if (use_fontset) {
- what = "fontsets";
- } else if (Scr->DefaultFont.name) {
- deffontname = Scr->DefaultFont.name;
- }
- if (!FindFontSet(font, deffontname)) {
- fprintf (stderr, "%s: unable to open %s \"%s\" or \"%s\"\n",
- ProgramName, what, font->name, deffontname);
- exit(1);
- }
+ const char *what = "fonts";
+
+ if (use_fontset) {
+ what = "fontsets";
+ }
+ else if (Scr->DefaultFont.name) {
+ deffontname = Scr->DefaultFont.name;
+ }
+ if (!FindFontSet(font, deffontname)) {
+ fprintf(stderr, "%s: unable to open %s \"%s\" or \"%s\"\n",
+ ProgramName, what, font->name, deffontname);
+ exit(1);
+ }
}
}
@@ -662,9 +674,8 @@ MyFont_TextWidth(MyFont *font, const char *string, int len)
XRectangle logical_rect;
if (use_fontset) {
- XmbTextExtents(font->fontset, string, len,
- &ink_rect, &logical_rect);
- return logical_rect.width;
+ XmbTextExtents(font->fontset, string, len, &ink_rect, &logical_rect);
+ return logical_rect.width;
}
return XTextWidth(font->font, string, len);
}
@@ -674,10 +685,10 @@ MyFont_DrawImageString(Display *dpy2, Drawable d, MyFont *font, GC gc,
int x, int y, const char *string, int len)
{
if (use_fontset) {
- XmbDrawImageString(dpy2, d, font->fontset, gc, x, y, string, len);
- return;
+ XmbDrawImageString(dpy2, d, font->fontset, gc, x, y, string, len);
+ return;
}
- XDrawImageString (dpy2, d, gc, x, y, string, len);
+ XDrawImageString(dpy2, d, gc, x, y, string, len);
}
void
@@ -685,10 +696,10 @@ MyFont_DrawString(Display *dpy2, Drawable d, MyFont *font, GC gc,
int x, int y, const char *string, int len)
{
if (use_fontset) {
- XmbDrawString(dpy2, d, font->fontset, gc, x, y, string, len);
- return;
+ XmbDrawString(dpy2, d, font->fontset, gc, x, y, string, len);
+ return;
}
- XDrawString (dpy2, d, gc, x, y, string, len);
+ XDrawString(dpy2, d, gc, x, y, string, len);
}
void
@@ -698,11 +709,11 @@ MyFont_ChangeGC(unsigned long fix_fore, unsigned long fix_back,
Gcv.foreground = fix_fore;
Gcv.background = fix_back;
if (use_fontset) {
- XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground, &Gcv);
- return;
+ XChangeGC(dpy, Scr->NormalGC, GCForeground | GCBackground, &Gcv);
+ return;
}
Gcv.font = fix_font->font->fid;
- XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv);
+ XChangeGC(dpy, Scr->NormalGC, GCFont | GCForeground | GCBackground, &Gcv);
}
/*
@@ -716,23 +727,23 @@ MyFont_ChangeGC(unsigned long fix_fore, unsigned long fix_back,
Status
I18N_FetchName(Display *dpy2, Window w, char **winname)
{
- int status;
+ int status;
XTextProperty text_prop;
char **list;
- int num;
+ int num;
status = XGetWMName(dpy2, w, &text_prop);
if (!status || !text_prop.value || !text_prop.nitems) {
- *winname = NULL;
- return 0;
+ *winname = NULL;
+ return 0;
}
status = XmbTextPropertyToTextList(dpy2, &text_prop, &list, &num);
if (status < Success || !num || !*list) {
- *winname = NULL;
- return 0;
+ *winname = NULL;
+ return 0;
}
XFree(text_prop.value);
- *winname = (char *)strdup(*list);
+ *winname = (char *) strdup(*list);
XFreeStringList(list);
return 1;
}
@@ -740,17 +751,19 @@ I18N_FetchName(Display *dpy2, Window w, char **winname)
Status
I18N_GetIconName(Display *dpy2, Window w, char **iconname)
{
- int status;
+ int status;
XTextProperty text_prop;
char **list;
- int num;
+ int num;
status = XGetWMIconName(dpy2, w, &text_prop);
- if (!status || !text_prop.value || !text_prop.nitems) return 0;
+ if (!status || !text_prop.value || !text_prop.nitems)
+ return 0;
status = XmbTextPropertyToTextList(dpy2, &text_prop, &list, &num);
- if (status < Success || !num || !*list) return 0;
+ if (status < Success || !num || !*list)
+ return 0;
XFree(text_prop.value);
- *iconname = (char *)strdup(*list);
+ *iconname = (char *) strdup(*list);
XFreeStringList(list);
return 1;
}
@@ -760,134 +773,147 @@ I18N_GetIconName(Display *dpy2, Window w, char **iconname)
* and easier to debug
*/
void
-SetFocus (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)");
+ 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);
+ XSetInputFocus(dpy, w, RevertToPointerRoot, time);
}
static Pixmap
-CreateXLogoPixmap (unsigned *widthp, unsigned *heightp)
+CreateXLogoPixmap(unsigned *widthp, unsigned *heightp)
{
int h = Scr->TBInfo.width - Scr->TBInfo.border * 2;
- if (h < 0) h = 0;
+
+ 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, (unsigned)h, (unsigned)h, 1);
- gc = XCreateGC (dpy, Scr->tbpm.xlogo, 0L, NULL);
- XSetForeground (dpy, gc, 0);
- XFillRectangle (dpy, Scr->tbpm.xlogo, gc, 0, 0, (unsigned)h, (unsigned)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, (unsigned)(h + 2), (unsigned)(h + 2));
- XDrawRectangle (dpy, Scr->tbpm.xlogo, gcBack, 0, 0, (unsigned)(h - 1), (unsigned)(h - 1));
-
- /*
- * done drawing
- */
- XFreeGC (dpy, gc);
- XFreeGC (dpy, gcBack);
+ GC gc, gcBack;
+
+ Scr->tbpm.xlogo =
+ XCreatePixmap(dpy, Scr->Root, (unsigned) h, (unsigned) h, 1);
+ gc = XCreateGC(dpy, Scr->tbpm.xlogo, 0L, NULL);
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle(dpy, Scr->tbpm.xlogo, gc, 0, 0, (unsigned) h,
+ (unsigned) 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,
+ (unsigned) (h + 2), (unsigned) (h + 2));
+ XDrawRectangle(dpy, Scr->tbpm.xlogo, gcBack, 0, 0, (unsigned) (h - 1),
+ (unsigned) (h - 1));
+
+ /*
+ * done drawing
+ */
+ XFreeGC(dpy, gc);
+ XFreeGC(dpy, gcBack);
}
return Scr->tbpm.xlogo;
}
-
static Pixmap
-CreateResizePixmap (unsigned *widthp, unsigned *heightp)
+CreateResizePixmap(unsigned *widthp, unsigned *heightp)
{
int h = Scr->TBInfo.width - Scr->TBInfo.border * 2;
- if (h < 1) h = 1;
+
+ 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, (unsigned)h, (unsigned)h, 1);
- gc = XCreateGC (dpy, Scr->tbpm.resize, 0L, NULL);
- XSetForeground (dpy, gc, 0);
- XFillRectangle (dpy, Scr->tbpm.resize, gc, 0, 0, (unsigned)h, (unsigned)h);
- XSetForeground (dpy, gc, 1);
- lw = h / 16;
- if (lw == 1)
- lw = 0;
- XSetLineAttributes (dpy, gc, (unsigned)lw, LineSolid, CapButt, JoinMiter);
-
- /*
- * draw the resize button,
- */
- w = (h * 2) / 3;
- points[0].x = (short)w;
- points[0].y = 0;
- points[1].x = (short)w;
- points[1].y = (short)w;
- points[2].x = 0;
- points[2].y = (short)w;
- XDrawLines (dpy, Scr->tbpm.resize, gc, points, 3, CoordModeOrigin);
- w = w / 2;
- points[0].x = (short)w;
- points[0].y = 0;
- points[1].x = (short)w;
- points[1].y = (short)w;
- points[2].x = 0;
- points[2].y = (short)w;
- XDrawLines (dpy, Scr->tbpm.resize, gc, points, 3, CoordModeOrigin);
-
- /*
- * done drawing
- */
- XFreeGC(dpy, gc);
+ XPoint points[3];
+ GC gc;
+ int w;
+ int lw;
+
+ /*
+ * create the pixmap
+ */
+ Scr->tbpm.resize =
+ XCreatePixmap(dpy, Scr->Root, (unsigned) h, (unsigned) h, 1);
+ gc = XCreateGC(dpy, Scr->tbpm.resize, 0L, NULL);
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle(dpy, Scr->tbpm.resize, gc, 0, 0, (unsigned) h,
+ (unsigned) h);
+ XSetForeground(dpy, gc, 1);
+ lw = h / 16;
+ if (lw == 1)
+ lw = 0;
+ XSetLineAttributes(dpy, gc, (unsigned) lw, LineSolid, CapButt,
+ JoinMiter);
+
+ /*
+ * draw the resize button,
+ */
+ w = (h * 2) / 3;
+ points[0].x = (short) w;
+ points[0].y = 0;
+ points[1].x = (short) w;
+ points[1].y = (short) w;
+ points[2].x = 0;
+ points[2].y = (short) w;
+ XDrawLines(dpy, Scr->tbpm.resize, gc, points, 3, CoordModeOrigin);
+ w = w / 2;
+ points[0].x = (short) w;
+ points[0].y = 0;
+ points[1].x = (short) w;
+ points[1].y = (short) w;
+ points[2].x = 0;
+ points[2].y = (short) w;
+ XDrawLines(dpy, Scr->tbpm.resize, gc, points, 3, CoordModeOrigin);
+
+ /*
+ * done drawing
+ */
+ XFreeGC(dpy, gc);
}
return Scr->tbpm.resize;
}
-
static Pixmap
-CreateDotPixmap (unsigned *widthp, unsigned *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 = 1;
if (!(h & 1))
- h--;
+ h--;
*widthp = *heightp = (unsigned int) h;
if (Scr->tbpm.delete == None) {
- GC gc;
- Pixmap pix;
-
- pix = Scr->tbpm.delete = XCreatePixmap (dpy, Scr->Root, (unsigned)h, (unsigned)h, 1);
- gc = XCreateGC (dpy, pix, 0L, NULL);
- XSetLineAttributes (dpy, gc, (unsigned)h, LineSolid, CapRound, JoinRound);
- XSetForeground (dpy, gc, 0L);
- XFillRectangle (dpy, pix, gc, 0, 0, (unsigned)h, (unsigned)h);
- XSetForeground (dpy, gc, 1L);
- XDrawLine (dpy, pix, gc, h/2, h/2, h/2, h/2);
- XFreeGC (dpy, gc);
+ GC gc;
+ Pixmap pix;
+
+ pix = Scr->tbpm.delete =
+ XCreatePixmap(dpy, Scr->Root, (unsigned) h, (unsigned) h, 1);
+ gc = XCreateGC(dpy, pix, 0L, NULL);
+ XSetLineAttributes(dpy, gc, (unsigned) h, LineSolid, CapRound,
+ JoinRound);
+ XSetForeground(dpy, gc, 0L);
+ XFillRectangle(dpy, pix, gc, 0, 0, (unsigned) h, (unsigned) h);
+ XSetForeground(dpy, gc, 1L);
+ XDrawLine(dpy, pix, gc, h / 2, h / 2, h / 2, h / 2);
+ XFreeGC(dpy, gc);
}
return Scr->tbpm.delete;
}
@@ -895,18 +921,19 @@ CreateDotPixmap (unsigned *widthp, unsigned *heightp)
#define questionmark_width 8
#define questionmark_height 8
static char questionmark_bits[] = {
- 0x38, 0x7c, 0x64, 0x30, 0x18, 0x00, 0x18, 0x18};
+ 0x38, 0x7c, 0x64, 0x30, 0x18, 0x00, 0x18, 0x18
+};
static Pixmap
-CreateQuestionPixmap (unsigned *widthp, unsigned *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);
+ Scr->tbpm.question = XCreateBitmapFromData(dpy, Scr->Root,
+ questionmark_bits,
+ questionmark_width,
+ questionmark_height);
}
/*
* this must succeed or else we are in deep trouble elsewhere
@@ -914,84 +941,84 @@ CreateQuestionPixmap (unsigned *widthp, unsigned *heightp)
return Scr->tbpm.question;
}
-
static Pixmap
-CreateMenuPixmap (unsigned *widthp, unsigned *heightp)
+CreateMenuPixmap(unsigned *widthp, unsigned *heightp)
{
- return CreateMenuIcon (Scr->TBInfo.width - Scr->TBInfo.border * 2,
- widthp,heightp);
+ return CreateMenuIcon(Scr->TBInfo.width - Scr->TBInfo.border * 2,
+ widthp, heightp);
}
Pixmap
-CreateMenuIcon (int height, unsigned *widthp, unsigned *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 ix, iy;
+ int mh, mw;
+ int tw, th;
+ int lw, lh;
+ int lx, ly;
+ int lines, dly;
int off;
- int bw;
+ int bw;
h = height;
w = h * 7 / 8;
if (h < 1)
- h = 1;
+ h = 1;
if (w < 1)
- w = 1;
- *widthp = (unsigned)w;
- *heightp = (unsigned)h;
+ w = 1;
+ *widthp = (unsigned) w;
+ *heightp = (unsigned) h;
if (Scr->tbpm.menu == None) {
- Pixmap pix;
- GC gc;
-
- pix = Scr->tbpm.menu = XCreatePixmap (dpy, Scr->Root, (unsigned)w, (unsigned)h, 1);
- gc = XCreateGC (dpy, pix, 0L, NULL);
- XSetForeground (dpy, gc, 0L);
- XFillRectangle (dpy, pix, gc, 0, 0, (unsigned)w, (unsigned)h);
- XSetForeground (dpy, gc, 1L);
- ix = 1;
- iy = 1;
- ih = h - iy * 2;
- iw = w - ix * 2;
- off = ih / 8;
- mh = ih - off;
- mw = iw - off;
- bw = mh / 16;
- if (bw == 0 && mw > 2)
- bw = 1;
- tw = mw - bw * 2;
- th = mh - bw * 2;
- XFillRectangle (dpy, pix, gc, ix, iy, (unsigned)mw, (unsigned)mh);
- XFillRectangle (dpy, pix, gc, ix + iw - mw, iy + ih - mh, (unsigned)mw, (unsigned)mh);
- XSetForeground (dpy, gc, 0L);
- XFillRectangle (dpy, pix, gc, ix+bw, iy+bw, (unsigned)tw, (unsigned)th);
- XSetForeground (dpy, gc, 1L);
- lw = tw / 2;
- if ((tw & 1) ^ (lw & 1))
- lw++;
- lx = ix + bw + (tw - lw) / 2;
-
- lh = th / 2 - bw;
- if ((lh & 1) ^ ((th - bw) & 1))
- 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, (unsigned)lw, (unsigned)bw);
- ly += dly;
- }
- XFreeGC (dpy, gc);
+ Pixmap pix;
+ GC gc;
+
+ pix = Scr->tbpm.menu =
+ XCreatePixmap(dpy, Scr->Root, (unsigned) w, (unsigned) h, 1);
+ gc = XCreateGC(dpy, pix, 0L, NULL);
+ XSetForeground(dpy, gc, 0L);
+ XFillRectangle(dpy, pix, gc, 0, 0, (unsigned) w, (unsigned) h);
+ XSetForeground(dpy, gc, 1L);
+ ix = 1;
+ iy = 1;
+ ih = h - iy * 2;
+ iw = w - ix * 2;
+ off = ih / 8;
+ mh = ih - off;
+ mw = iw - off;
+ bw = mh / 16;
+ if (bw == 0 && mw > 2)
+ bw = 1;
+ tw = mw - bw * 2;
+ th = mh - bw * 2;
+ XFillRectangle(dpy, pix, gc, ix, iy, (unsigned) mw, (unsigned) mh);
+ XFillRectangle(dpy, pix, gc, ix + iw - mw, iy + ih - mh, (unsigned) mw,
+ (unsigned) mh);
+ XSetForeground(dpy, gc, 0L);
+ XFillRectangle(dpy, pix, gc, ix + bw, iy + bw, (unsigned) tw,
+ (unsigned) th);
+ XSetForeground(dpy, gc, 1L);
+ lw = tw / 2;
+ if ((tw & 1) ^ (lw & 1))
+ lw++;
+ lx = ix + bw + (tw - lw) / 2;
+
+ lh = th / 2 - bw;
+ if ((lh & 1) ^ ((th - bw) & 1))
+ 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, (unsigned) lw, (unsigned) bw);
+ ly += dly;
+ }
+ XFreeGC(dpy, gc);
}
return Scr->tbpm.menu;
}
diff --git a/src/util.h b/src/util.h
index 4b2d3a8..195432c 100644
--- a/src/util.h
+++ b/src/util.h
@@ -49,64 +49,63 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-
/***********************************************************************
*
* utility routines header file
*
- * 28-Oct-87 Thomas E. LaStrange File created
+ * 28-Oct-87 Thomas E. LaStrange File created
*
***********************************************************************/
#ifndef _UTIL_
#define _UTIL_
-extern void MoveOutline ( Window root, int x, int y, int width, int height,
- int bw, int th );
-extern void Zoom ( Window wf, Window wt );
-extern char * ExpandFilename ( const char *name );
-extern void GetUnknownIcon ( const char *name );
-extern Pixmap FindBitmap ( const char *name, unsigned int *widthp,
- unsigned int *heightp );
-extern Pixmap GetBitmap ( const char *name );
-extern void InsertRGBColormap ( Atom a, XStandardColormap *maps, int nmaps,
- Bool replace );
-extern void RemoveRGBColormap ( Atom a );
-extern void LocateStandardColormaps ( void );
-extern void GetColor ( int kind, Pixel *what, const char *name );
-extern void GetColorValue ( int kind, XColor *what, const char *name );
-extern void GetFont ( MyFont *font );
-extern int MyFont_TextWidth( MyFont *font, const char *string, int len);
-extern void MyFont_DrawImageString( Display *dpy, Drawable d, MyFont *font,
- GC gc, int x, int y, const char * string,
- int len);
-extern void MyFont_DrawString( Display *dpy, Drawable d, MyFont *font, GC gc,
- int x, int y, const char * string, int len);
-extern void MyFont_ChangeGC( unsigned long fix_fore, unsigned long fix_back,
- MyFont *fix_font);
-extern Status I18N_FetchName( Display *dpy, Window win, char **winname);
-extern Status I18N_GetIconName( Display *dpy, Window win, char **iconname);
-extern void SetFocus ( TwmWindow *tmp_win, Time time );
-extern void Bell ( int type, int percent, Window win );
+extern void MoveOutline(Window root, int x, int y, int width, int height,
+ int bw, int th);
+extern void Zoom(Window wf, Window wt);
+extern char *ExpandFilename(const char *name);
+extern void GetUnknownIcon(const char *name);
+extern Pixmap FindBitmap(const char *name, unsigned int *widthp,
+ unsigned int *heightp);
+extern Pixmap GetBitmap(const char *name);
+extern void InsertRGBColormap(Atom a, XStandardColormap *maps, int nmaps,
+ Bool replace);
+extern void RemoveRGBColormap(Atom a);
+extern void LocateStandardColormaps(void);
+extern void GetColor(int kind, Pixel *what, const char *name);
+extern void GetColorValue(int kind, XColor *what, const char *name);
+extern void GetFont(MyFont *font);
+extern int MyFont_TextWidth(MyFont *font, const char *string, int len);
+extern void MyFont_DrawImageString(Display *dpy, Drawable d, MyFont *font,
+ GC gc, int x, int y, const char *string,
+ int len);
+extern void MyFont_DrawString(Display *dpy, Drawable d, MyFont *font, GC gc,
+ int x, int y, const char *string, int len);
+extern void MyFont_ChangeGC(unsigned long fix_fore, unsigned long fix_back,
+ MyFont *fix_font);
+extern Status I18N_FetchName(Display *dpy, Window win, char **winname);
+extern Status I18N_GetIconName(Display *dpy, Window win, char **iconname);
+extern void SetFocus(TwmWindow *tmp_win, Time time);
+extern void Bell(int type, int percent, Window win);
extern int HotX, HotY;
-#define WM_BELL 0
-#define MINOR_ERROR_BELL 1
-#define MAJOR_ERROR_BELL 2
-#define INFO_BELL 3
-#define NUM_BELLS 4
+#define WM_BELL 0
+#define MINOR_ERROR_BELL 1
+#define MAJOR_ERROR_BELL 2
+#define INFO_BELL 3
+#define NUM_BELLS 4
-#define QUIET_BELL -100
-#define MODERATE_BELL 0
-#define LOUD_BELL 100
+#define QUIET_BELL -100
+#define MODERATE_BELL 0
+#define LOUD_BELL 100
#ifdef XKB
#include <X11/extensions/XKBbells.h>
#else
-#define XkbBI_Info 0
-#define XkbBI_MinorError 1
-#define XkbBI_MajorError 2
+#define XkbBI_Info 0
+#define XkbBI_MinorError 1
+#define XkbBI_MajorError 2
#endif
-#endif /* _UTIL_ */
+#endif /* _UTIL_ */
diff --git a/src/version.c b/src/version.c
index cf06076..e7eae94 100644
--- a/src/version.c
+++ b/src/version.c
@@ -49,5 +49,4 @@ in this Software without prior written authorization from The Open Group.
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
-const char *Version = XVENDORNAME", "XORG_RELEASE;
-
+const char *Version = XVENDORNAME ", " XORG_RELEASE;
diff --git a/src/version.h b/src/version.h
index 24ed8bd..553b613 100644
--- a/src/version.h
+++ b/src/version.h
@@ -62,4 +62,4 @@ in this Software without prior written authorization from The Open Group.
extern const char *Version;
-#endif /* _VERSION_ */
+#endif /* _VERSION_ */