/* * * Interprets the property MOTIF_WM_HINTS, sets decoration and functions * accordingly * */ void SelectDecor(FvwmWindow *t, window_style *pstyle, short *buttons) { int decor; int i; int border_width; int handle_width; int used_width; PropMwmHints *prop; style_flags *sflags = &(pstyle->flags); border_width = (SHAS_BORDER_WIDTH(sflags)) ? SGET_BORDER_WIDTH(*pstyle) : DEFAULT_BORDER_WIDTH; if (border_width > MAX_BORDER_WIDTH) { border_width = MAX_BORDER_WIDTH; } handle_width = (SHAS_HANDLE_WIDTH(sflags)) ? SGET_HANDLE_WIDTH(*pstyle) : DEFAULT_HANDLE_WIDTH; if (handle_width > MAX_HANDLE_WIDTH) { handle_width = MAX_HANDLE_WIDTH; } *buttons = (1 << NUMBER_OF_TITLE_BUTTONS) - 1; decor = MWM_DECOR_ALL; t->functions = MWM_FUNC_ALL; if (t->mwm_hints) { prop = (PropMwmHints *)t->mwm_hints; if (SHAS_MWM_DECOR(sflags)) { if (prop->flags & MWM_HINTS_DECORATIONS) { decor = 0; if (prop->decorations & 0x1) { decor |= MWM_DECOR_ALL; } if (prop->decorations & 0x2) { decor |= MWM_DECOR_BORDER; } if (prop->decorations & 0x4) { decor |= MWM_DECOR_RESIZEH; } if (prop->decorations & 0x8) { decor |= MWM_DECOR_TITLE; } if (prop->decorations & 0x10) { decor |= MWM_DECOR_MENU; } if (prop->decorations & 0x20) { decor |= MWM_DECOR_MINIMIZE; } if (prop->decorations & 0x40) { decor |= MWM_DECOR_MAXIMIZE; } } } if (SHAS_MWM_FUNCTIONS(sflags)) { if (prop->flags & MWM_HINTS_FUNCTIONS) { t->functions = prop->functions; } } } /* functions affect the decorations! if the user says * no iconify function, then the iconify button doesn't show * up. */ if (t->functions & MWM_FUNC_ALL) { /* If we get ALL + some other things, that means to use * ALL except the other things... */ t->functions &= ~MWM_FUNC_ALL; t->functions = (MWM_FUNC_RESIZE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_FUNC_CLOSE) & (~(t->functions)); } if (SHAS_MWM_FUNCTIONS(sflags) && IS_TRANSIENT(t)) { t->functions &= ~(MWM_FUNC_MAXIMIZE|MWM_FUNC_MINIMIZE); } if (decor & MWM_DECOR_ALL) { /* If we get ALL + some other things, that means to use * ALL except the other things... */ decor &= ~MWM_DECOR_ALL; decor = MWM_DECOR_EVERYTHING & (~decor); } /* now add/remove any functions specified in the OL hints */ if (SHAS_OL_DECOR(sflags) && (t->ol_hints & OL_ANY_HINTS)) { if (t->ol_hints & OL_DECOR_CLOSE) { t->functions |= MWM_FUNC_MINIMIZE; decor |= MWM_FUNC_MINIMIZE; } else { t->functions &= ~MWM_FUNC_MINIMIZE; decor &= ~MWM_FUNC_MINIMIZE; } if (t->ol_hints & OL_DECOR_RESIZEH) { t->functions |= (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); decor |= (MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); } else { t->functions &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); decor &= ~(MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE); } if (t->ol_hints & OL_DECOR_HEADER) { t->functions |= (MWM_DECOR_MENU | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_DECOR_TITLE); decor |= (MWM_DECOR_MENU | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_DECOR_TITLE); } else { t->functions &= ~(MWM_DECOR_MENU | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_DECOR_TITLE); decor &= ~(MWM_DECOR_MENU | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE | MWM_DECOR_TITLE); } if (t->ol_hints & OL_DECOR_ICON_NAME) { SET_HAS_NO_ICON_TITLE(t, 0); } else { SET_HAS_NO_ICON_TITLE(t, 1); } } /* Now I have the un-altered decor and functions, but with the * ALL attribute cleared and interpreted. I need to modify the * decorations that are affected by the functions */ if (!(t->functions & MWM_FUNC_RESIZE)) { decor &= ~MWM_DECOR_RESIZEH; } /* MWM_FUNC_MOVE has no impact on decorations. */ if (!(t->functions & MWM_FUNC_MINIMIZE)) { decor &= ~MWM_DECOR_MINIMIZE; } if (!(t->functions & MWM_FUNC_MAXIMIZE)) { decor &= ~MWM_DECOR_MAXIMIZE; } /* MWM_FUNC_CLOSE has no impact on decorations. */ /* This rule is implicit, but its easier to deal with if * I take care of it now */ if (decor & (MWM_DECOR_MENU| MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE)) { decor |= MWM_DECOR_TITLE; } /* Selected the mwm-decor field, now trim down, based on * .fvwmrc entries */ if (SHAS_NO_TITLE(sflags) || (!SDO_DECORATE_TRANSIENT(sflags) && IS_TRANSIENT(t))) { decor &= ~MWM_DECOR_TITLE; } if (SHAS_NO_HANDLES(sflags) || (!SDO_DECORATE_TRANSIENT(sflags) && IS_TRANSIENT(t))) { decor &= ~MWM_DECOR_RESIZEH; } if (SHAS_MWM_DECOR(sflags) && IS_TRANSIENT(t)) { decor &= ~(MWM_DECOR_MAXIMIZE|MWM_DECOR_MINIMIZE); } if (FShapesSupported) { if (t->wShaped) { decor &= ~(MWM_DECOR_BORDER|MWM_DECOR_RESIZEH); } } if (IS_EWMH_FULLSCREEN(t)) { decor &=~(MWM_DECOR_BORDER|MWM_DECOR_RESIZEH|MWM_DECOR_TITLE); } /* Assume no decorations, and build up */ SET_HAS_TITLE(t, 0); SET_HAS_HANDLES(t, 0); used_width = 0; if (decor & MWM_DECOR_BORDER) { /* A narrow border is displayed (5 pixels - 2 relief, 1 top, * (2 shadow) */ used_width = border_width; } if (decor & MWM_DECOR_TITLE) { /* A title bar with no buttons in it * window gets a 1 pixel wide black border. */ SET_HAS_TITLE(t, 1); } if (decor & MWM_DECOR_RESIZEH) { /* A wide border, with corner tiles is desplayed * (10 pixels - 2 relief, 2 shadow) */ SET_HAS_HANDLES(t, 1); used_width = handle_width; } SET_HAS_NO_BORDER(t, S_HAS_NO_BORDER(SFC(*sflags)) || used_width <= 0); if (HAS_NO_BORDER(t)) { used_width = 0; } SET_HAS_HANDLES(t, (!HAS_NO_BORDER(t) && HAS_HANDLES(t))); set_window_border_size(t, used_width); if (!(decor & MWM_DECOR_MENU)) { /* title-bar menu button omitted * window gets 1 pixel wide black border */ /* disable any buttons with the MWMDecorMenu flag */ int i; for (i = 0; i < NUMBER_OF_TITLE_BUTTONS; ++i) { if (TB_HAS_MWM_DECOR_MENU(GetDecor(t, buttons[i]))) { *buttons &= ~(1 << i); } } } if (!(decor & MWM_DECOR_MINIMIZE)) { /* title-bar + iconify button, no menu button. * window gets 1 pixel wide black border */ /* disable any buttons with the MWMDecorMinimize/MWMDecorShaded * flag */ int i; for (i = 0; i < NUMBER_OF_TITLE_BUTTONS; ++i) { if (TB_HAS_MWM_DECOR_MINIMIZE(GetDecor(t, buttons[i]))) { *buttons &= ~(1 << i); } } } if (!(decor & MWM_DECOR_MAXIMIZE)) { /* title-bar + maximize button, no menu button, no iconify. * window has 1 pixel wide black border */ /* disable any buttons with the MWMDecorMaximize flag */ int i; for (i = 0; i < NUMBER_OF_TITLE_BUTTONS; ++i) { if (TB_HAS_MWM_DECOR_MAXIMIZE(GetDecor(t, buttons[i]))) { *buttons &= ~(1 << i); } } } for (i = (1 << (NUMBER_OF_TITLE_BUTTONS - 1)); i; i >>= 1) { if (t->buttons & i) *buttons &= ~i; } t->nr_left_buttons = Scr.nr_left_buttons; t->nr_right_buttons = Scr.nr_right_buttons; for (i = 0; i / 2 < Scr.nr_left_buttons; i += 2) { if ((*buttons & (1 << i)) == 0) t->nr_left_buttons--; } for (i = 1; i / 2 < Scr.nr_right_buttons; i += 2) { if ((*buttons & (1 << i)) == 0) t->nr_right_buttons--; } return; }
/*********************************************************************** * * Procedure: * HandleFocusIn - handles focus in events * ************************************************************************/ void HandleFocusIn() { XEvent d; Window w; DBUG("HandleFocusIn","Routine Entered"); w= Event.xany.window; while(XCheckTypedEvent(dpy,FocusIn,&d)) { w = d.xany.window; } if (XFindContext (dpy, w, FvwmContext, (caddr_t *) &Tmp_win) == XCNOENT) { Tmp_win = NULL; } if(!Tmp_win) { if(w != Scr.NoFocusWin) { Scr.UnknownWinFocused = w; } else { SetBorder(Scr.Hilite,False,True,True,None); BroadcastPacket(M_FOCUS_CHANGE, 5, 0, 0, 0, Scr.DefaultDecor.HiColors.fore, Scr.DefaultDecor.HiColors.back); if (Scr.ColormapFocus == COLORMAP_FOLLOWS_FOCUS) { if((Scr.Hilite)&&(!(Scr.Hilite->flags & ICONIFIED))) { InstallWindowColormaps(Scr.Hilite); } else { InstallWindowColormaps(NULL); } } } } else if(Tmp_win != Scr.Hilite) { SetBorder(Tmp_win,True,True,True,None); BroadcastPacket(M_FOCUS_CHANGE, 5, Tmp_win->w, Tmp_win->frame, (unsigned long)Tmp_win, GetDecor(Tmp_win,HiColors.fore), GetDecor(Tmp_win,HiColors.back)); if (Scr.ColormapFocus == COLORMAP_FOLLOWS_FOCUS) { if((Scr.Hilite)&&(!(Scr.Hilite->flags & ICONIFIED))) { InstallWindowColormaps(Scr.Hilite); } else { InstallWindowColormaps(NULL); } } } }