void CaptureAllWindows(void) { int i, j; unsigned int nchildren; Window root, parent, *children; PPosOverride = TRUE; if (!XQueryTree(dpy, Scr.Root, &root, &parent, &children, &nchildren)) return; /* * weed out icon windows */ for (i = 0; i < nchildren; i++) { if (children[i]) { XWMHints *wmhintsp = XGetWMHints(dpy, children[i]); if (wmhintsp) { if (wmhintsp->flags & IconWindowHint) { for (j = 0; j < nchildren; j++) { if (children[j] == wmhintsp->icon_window) { children[j] = None; break; } } } XFree((char *) wmhintsp); } } } /* * map all of the non-override windows */ for (i = 0; i < nchildren; i++) { if (children[i] && MappedNotOverride(children[i])) { XUnmapWindow(dpy, children[i]); Event.xmaprequest.window = children[i]; HandleMapRequestKeepRaised(BlackoutWin); } } isIconicState = DontCareState; if (nchildren > 0) XFree((char *) children); /* after the windows already on the screen are in place, * don't use PPosition */ PPosOverride = FALSE; Scr.flags |= WindowsCaptured; KeepOnTop(); }
/*********************************************************************** * * Procedure: * HandleMapNotify - MapNotify event handler * ***********************************************************************/ void HandleMapNotify() { Boolean OnThisPage = False; DBUG("HandleMapNotify","Routine Entered"); if (!Tmp_win) { if((Event.xmap.override_redirect == True)&& (Event.xmap.window != Scr.NoFocusWin)) { XSelectInput(dpy,Event.xmap.window,FocusChangeMask); Scr.UnknownWinFocused = Event.xmap.window; } return; } /* Except for identifying over-ride redirect window mappings, we * don't need or want windows associated with the sunstructurenotifymask */ if(Event.xmap.event != Event.xmap.window) return; /* Make sure at least part of window is on this page before giving it focus... */ if ( (Tmp_win->Desk == Scr.CurrentDesk) && ( ((Tmp_win->frame_x + Tmp_win->frame_width) >= 0 && Tmp_win->frame_x < Scr.MyDisplayWidth) && ((Tmp_win->frame_y + Tmp_win->frame_height) >= 0 && Tmp_win->frame_y < Scr.MyDisplayHeight) ) ) { OnThisPage = True; } /* * Need to do the grab to avoid race condition of having server send * MapNotify to client before the frame gets mapped; this is bad because * the client would think that the window has a chance of being viewable * when it really isn't. */ MyXGrabServer (dpy); if (Tmp_win->icon_w) XUnmapWindow(dpy, Tmp_win->icon_w); if(Tmp_win->icon_pixmap_w != None) XUnmapWindow(dpy, Tmp_win->icon_pixmap_w); XMapSubwindows(dpy, Tmp_win->frame); if(Tmp_win->Desk == Scr.CurrentDesk) { XMapWindow(dpy, Tmp_win->frame); } if(Tmp_win->flags & ICONIFIED) BroadcastPacket(M_DEICONIFY, 3, Tmp_win->w, Tmp_win->frame, (unsigned long)Tmp_win); else BroadcastPacket(M_MAP, 3, Tmp_win->w,Tmp_win->frame, (unsigned long)Tmp_win); if((Tmp_win->flags & ClickToFocus)&& ((!Scr.Focus)||(Scr.Focus->flags & ClickToFocus))) { if (OnThisPage) { SetFocus(Tmp_win->w,Tmp_win,1); } } if((!(Tmp_win->flags &(BORDER|TITLE)))&&(Tmp_win->boundary_width <2)) { SetBorder(Tmp_win,False,True,True,Tmp_win->frame); } XSync(dpy,0); MyXUngrabServer (dpy); XFlush (dpy); Tmp_win->flags |= MAPPED; Tmp_win->flags &= ~MAP_PENDING; Tmp_win->flags &= ~ICONIFIED; Tmp_win->flags &= ~ICON_UNMAPPED; KeepOnTop(); }
/*********************************************************************** * * Procedure: * HandleConfigureRequest - ConfigureRequest event handler * ************************************************************************/ void HandleConfigureRequest() { XWindowChanges xwc; unsigned long xwcm; int x, y, width, height; XConfigureRequestEvent *cre = &Event.xconfigurerequest; Bool sendEvent=False; FvwmWindow *FvwmSib; DBUG("HandleConfigureRequest","Routine Entered"); /* * 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, FvwmContext, (caddr_t *) &Tmp_win) == XCNOENT) Tmp_win = NULL; /* * According to the July 27, 1988 ICCCM draft, we should ignore size and * position fields in the WM_NORMAL_HINTS property when we map a window. * Instead, we'll read the current geometry. Therefore, we should respond * to configuration requests for windows which have never been mapped. */ if (!Tmp_win || cre->window == Tmp_win->icon_w || cre->window == Tmp_win->icon_pixmap_w) { xwcm = cre->value_mask & (CWX | CWY | CWWidth | CWHeight | CWBorderWidth); xwc.x = cre->x; xwc.y = cre->y; if((Tmp_win)&&((Tmp_win->icon_pixmap_w == cre->window))) { Tmp_win->icon_p_height = cre->height+ cre->border_width + cre->border_width; } else if((Tmp_win)&&((Tmp_win->icon_w == cre->window))) { Tmp_win->icon_xl_loc = cre->x; Tmp_win->icon_x_loc = cre->x + (Tmp_win->icon_w_width - Tmp_win->icon_p_width)/2; Tmp_win->icon_y_loc = cre->y - Tmp_win->icon_p_height; if(!(Tmp_win->flags & ICON_UNMAPPED)) BroadcastPacket(M_ICON_LOCATION, 7, Tmp_win->w, Tmp_win->frame, (unsigned long)Tmp_win, Tmp_win->icon_x_loc, Tmp_win->icon_y_loc, Tmp_win->icon_w_width, Tmp_win->icon_w_height + Tmp_win->icon_p_height); } xwc.width = cre->width; xwc.height = cre->height; xwc.border_width = cre->border_width; XConfigureWindow(dpy, Event.xany.window, xwcm, &xwc); if(Tmp_win) { if (cre->window != Tmp_win->icon_pixmap_w && Tmp_win->icon_pixmap_w != None) { xwc.x = Tmp_win->icon_x_loc; xwc.y = Tmp_win->icon_y_loc - Tmp_win->icon_p_height; xwcm = cre->value_mask & (CWX | CWY); XConfigureWindow(dpy, Tmp_win->icon_pixmap_w, xwcm, &xwc); } if(Tmp_win->icon_w != None) { xwc.x = Tmp_win->icon_x_loc; xwc.y = Tmp_win->icon_y_loc; xwcm = cre->value_mask & (CWX | CWY); XConfigureWindow(dpy, Tmp_win->icon_w, xwcm, &xwc); } } return; } /* Stacking order change requested... */ if (cre->value_mask & CWStackMode) { FvwmWindow *otherwin; otherwin = NULL; xwc.sibling = (((cre->value_mask & CWSibling) && (XFindContext (dpy, cre->above, FvwmContext, (caddr_t *) &otherwin) == XCSUCCESS)) ? otherwin->frame : cre->above); xwc.stack_mode = cre->detail; XConfigureWindow (dpy, Tmp_win->frame, cre->value_mask & (CWSibling | CWStackMode), &xwc); sendEvent = True; /* RBW - Update the stacking order ring. */ if (xwc.stack_mode == Above || xwc.stack_mode == Below) { FvwmSib = (otherwin != NULL ) ? otherwin: Scr.FvwmRoot.stack_next; /* Set up for Above. */ if (xwc.stack_mode == Below) { /* If Below-sibling, raise above next lower window. If no sibling, bottom of stack is "above" Scr.FvwmRoot in the ring. */ FvwmSib = (FvwmSib == otherwin) ? FvwmSib->stack_next: FvwmSib->stack_prev; } if (Tmp_win != FvwmSib) /* Don't chain it to itself! */ { Tmp_win->stack_prev->stack_next = Tmp_win->stack_next; /* Pluck from chain. */ Tmp_win->stack_next->stack_prev = Tmp_win->stack_prev; Tmp_win->stack_next = FvwmSib; /* Set new pointers. */ Tmp_win->stack_prev = FvwmSib->stack_prev; FvwmSib->stack_prev->stack_next = Tmp_win; /* Re-insert above sibling. */ FvwmSib->stack_prev = Tmp_win; } } else { /* Oh, bother! We have to rebuild the stacking order ring to figure out where this one went (TopIf, BottomIf, or Opposite). */ ResyncFvwmStackRing(); } } #ifdef SHAPE if (ShapesSupported) { int xws, yws, xbs, ybs; unsigned wws, hws, wbs, hbs; int boundingShaped, clipShaped; XShapeQueryExtents (dpy, Tmp_win->w,&boundingShaped, &xws, &yws, &wws, &hws,&clipShaped, &xbs, &ybs, &wbs, &hbs); Tmp_win->wShaped = boundingShaped; } #endif /* SHAPE */ /* Don't modify frame_XXX fields before calling SetupWindow! */ x = Tmp_win->frame_x; y = Tmp_win->frame_y; width = Tmp_win->frame_width; height = Tmp_win->frame_height; /* for restoring */ if (cre->value_mask & CWBorderWidth) { Tmp_win->old_bw = cre->border_width; } /* override even if border change */ if (cre->value_mask & CWX) x = cre->x - Tmp_win->boundary_width - Tmp_win->bw; if (cre->value_mask & CWY) y = cre->y - Tmp_win->boundary_width - Tmp_win->title_height - Tmp_win->bw; if (cre->value_mask & CWWidth) width = cre->width + 2*Tmp_win->boundary_width; if (cre->value_mask & CWHeight) height = cre->height+Tmp_win->title_height+2*Tmp_win->boundary_width; /* * SetupWindow (x,y) are the location of the upper-left outer corner and * are passed directly to XMoveResizeWindow (frame). The (width,height) * are the inner size of the frame. The inner width is the same as the * requested client window width; the inner height is the same as the * requested client window height plus any title bar slop. */ ConstrainSize(Tmp_win, &width, &height, False, 0, 0); SetupFrame (Tmp_win, x, y, width, height,sendEvent); KeepOnTop(); }
void HandleMapRequestKeepRaised(Window KeepRaised) { extern long isIconicState; extern Boolean PPosOverride; Boolean OnThisPage = False; Event.xany.window = Event.xmaprequest.window; if(XFindContext(dpy, Event.xany.window, FvwmContext, (caddr_t *)&Tmp_win)==XCNOENT) Tmp_win = NULL; if(!PPosOverride) XFlush(dpy); /* If the window has never been mapped before ... */ if(!Tmp_win) { /* Add decorations. */ Tmp_win = AddWindow(Event.xany.window); if (Tmp_win == NULL) return; } /* Make sure at least part of window is on this page before giving it focus... */ if ( (Tmp_win->Desk == Scr.CurrentDesk) && ( ((Tmp_win->frame_x + Tmp_win->frame_width) >= 0 && Tmp_win->frame_x < Scr.MyDisplayWidth) && ((Tmp_win->frame_y + Tmp_win->frame_height) >= 0 && Tmp_win->frame_y < Scr.MyDisplayHeight) ) ) { OnThisPage = True; } if(KeepRaised != None) XRaiseWindow(dpy,KeepRaised); /* If it's not merely iconified, and we have hints, use them. */ if (!(Tmp_win->flags & ICONIFIED)) { int state; if(Tmp_win->wmhints && (Tmp_win->wmhints->flags & StateHint)) state = Tmp_win->wmhints->initial_state; else state = NormalState; if(Tmp_win->flags & STARTICONIC) state = IconicState; if(isIconicState != DontCareState) state = isIconicState; MyXGrabServer(dpy); switch (state) { case DontCareState: case NormalState: case InactiveState: default: if (Tmp_win->Desk == Scr.CurrentDesk) { XMapWindow(dpy, Tmp_win->w); XMapWindow(dpy, Tmp_win->frame); Tmp_win->flags |= MAP_PENDING; SetMapStateProp(Tmp_win, NormalState); if((Tmp_win->flags & ClickToFocus)&& ((!Scr.Focus)||(Scr.Focus->flags & ClickToFocus))) { if (OnThisPage) { SetFocus(Tmp_win->w,Tmp_win,1); } } } else { XMapWindow(dpy, Tmp_win->w); SetMapStateProp(Tmp_win, NormalState); } break; case IconicState: if (Tmp_win->wmhints) { Iconify(Tmp_win, Tmp_win->wmhints->icon_x, Tmp_win->wmhints->icon_y); } else { Iconify(Tmp_win, 0, 0); } break; } if(!PPosOverride) XSync(dpy,0); MyXUngrabServer(dpy); } /* If no hints, or currently an icon, just "deiconify" */ else { DeIconify(Tmp_win); } if(!PPosOverride) KeepOnTop(); }
/*********************************************************************** * * Procedure: * HandleButtonPress - ButtonPress event handler * ***********************************************************************/ void HandleButtonPress() { unsigned int modifier; Binding *MouseEntry; Window x; int LocalContext; DBUG("HandleButtonPress","Routine Entered"); /* click to focus stuff goes here */ if((Tmp_win)&&(Tmp_win->flags & ClickToFocus)&&(Tmp_win != Scr.Ungrabbed) && ((Event.xbutton.state& (ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) == 0)) { SetFocus(Tmp_win->w,Tmp_win,1); /* #ifdef CLICKY_MODE_1 */ if (Scr.ClickToFocusRaises || ((Event.xany.window != Tmp_win->w)&& (Event.xbutton.subwindow != Tmp_win->w)&& (Event.xany.window != Tmp_win->Parent)&& (Event.xbutton.subwindow != Tmp_win->Parent))) /* #endif */ { RaiseWindow(Tmp_win); } KeepOnTop(); /* Why is this here? Seems to cause breakage with * non-focusing windows! */ if(!(Tmp_win->flags & ICONIFIED)) { XSync(dpy,0); /* pass click event to just clicked to focus window? */ if (Scr.ClickToFocusPassesClick) XAllowEvents(dpy,ReplayPointer,CurrentTime); else /* don't pass click to just focused window */ XAllowEvents(dpy,AsyncPointer,CurrentTime); XSync(dpy,0); return; } } else if ((Tmp_win) && !(Tmp_win->flags & ClickToFocus) && (Event.xbutton.window == Tmp_win->frame) && Scr.MouseFocusClickRaises) { if (Tmp_win != Scr.LastWindowRaised && (Event.xbutton.state & (ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) == 0 && GetContext(Tmp_win,&Event, &PressedW) == C_WINDOW) { RaiseWindow(Tmp_win); KeepOnTop(); } XSync(dpy,0); XAllowEvents(dpy,ReplayPointer,CurrentTime); XSync(dpy,0); return; } XSync(dpy,0); XAllowEvents(dpy,ReplayPointer,CurrentTime); XSync(dpy,0); Context = GetContext(Tmp_win,&Event, &PressedW); LocalContext = Context; x= PressedW; if(Context == C_TITLE) SetTitleBar(Tmp_win,(Scr.Hilite == Tmp_win),False); else SetBorder(Tmp_win,(Scr.Hilite == Tmp_win),True,True,PressedW); ButtonWindow = Tmp_win; /* we have to execute a function or pop up a menu */ modifier = (Event.xbutton.state & mods_used); /* need to search for an appropriate mouse binding */ for (MouseEntry = Scr.AllBindings; MouseEntry != NULL; MouseEntry= MouseEntry->NextBinding) { if(((MouseEntry->Button_Key == Event.xbutton.button)|| (MouseEntry->Button_Key == 0))&& (MouseEntry->Context & Context)&& ((MouseEntry->Modifier == AnyModifier)|| (MouseEntry->Modifier == (modifier& (~LockMask))))&& (MouseEntry->IsMouse == 1)) { /* got a match, now process it */ ExecuteFunction(MouseEntry->Action,Tmp_win, &Event,Context,-1); break; } } PressedW = None; if(LocalContext!=C_TITLE) SetBorder(ButtonWindow,(Scr.Hilite == ButtonWindow),True,True,x); else SetTitleBar(ButtonWindow,(Scr.Hilite==ButtonWindow),False); ButtonWindow = NULL; }