⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 windows.c

📁 安装DDD之前
💻 C
📖 第 1 页 / 共 4 页
字号:
	if ((tmp->flags & ICONIFIED))	{	    wins[(*count)++] = tmp->icon_w;	    wins[(*count)++] = tmp->icon_pixmap_w;	}    }}/* * lower our children before ourselves */static voidlower_children(MwmWindow *win){    MwmWindow *tmp;    if (win == NULL)	return;    for (tmp = win; tmp != NULL; tmp = tmp->next)    {	if (tmp->child)	    lower_children(tmp->child);	XLowerWindow(dpy, tmp->w);    }}/* * Decorates all windows at start-up */voidWIN_CaptureWindows(ScreenInfo *scr){    unsigned int i, j;    unsigned int nchildren;    Window root, parent, *children;    PPosOverride = True;    if (!XQueryTree(dpy, scr->root_win, &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] && mapped_not_override(scr, children[i]))	{	    /* Why the unmap? MLM */	    /* Answering my own question:  if the unmap isn't there, when	     * the window manager restarts, any transients lying around never	     * get they're MAPPED flag set (no map event, so they don't go	     * through normal channels.  I'm not happy with this, but for now	     * I'm going to keep it.  Actually, it should be ok as long as	     * any transient children aren't modal.  If they are, we'll need	     * to fixup the window trees based on that modality after the	     * capture procedure.	     */	    XUnmapWindow(dpy, children[i]);	    WIN_MapWindow(scr, children[i]);	}    }    isIconicState = DontCareState;    if (nchildren > 0)	XFree((char *)children);    /* after the windows already on the screen are in place,     * don't use PPosition */    PPosOverride = False;}/* * release window decorations when exiting */voidWIN_ReleaseWindows(ScreenInfo *scr){    MwmWindow *tmp;		/* temp mwm window structure */    /*     * remove the frame components from all the windows     */    XGrabServer(dpy);    if (scr->pager_win != None)	XDestroyWindow(dpy, scr->pager_win);    COLOR_InstallWindowColorMap(scr, &scr->mwm_root);	/* force reinstall */    for (tmp = scr->mwm_root.next; tmp != NULL; tmp = tmp->next)	release_window(scr, tmp);    MENU_DestroyMenus(scr);    XUngrabServer(dpy);    XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);    XSync(dpy, 0);}/* * find the MwmWindow structure associated with a Window */MwmWindow *WIN_WindowToStruct(ScreenInfo *scr, Window target){    MwmWindow *t, *tmp_win = 0;    tmp_win = NULL;    for (t = scr->mwm_root.next; t != NULL; t = t->next)    {	if (t->pager_view == target)	{	    tmp_win = t;	}    }    return tmp_win;}/*  * set the focus window in a window tree */voidWIN_SetFocusInTree(MwmWindow *leaf){    MwmWindow *root;    root = MISC_RootOfTree(leaf);    if (root)	root->focus_in_tree = leaf;}/* * Sets the input focus to the indicated window. */voidWIN_SetFocus(ScreenInfo *scr, Window w, MwmWindow *Fw){    int i;    /* XmEXPLICIT keyboard focus policy queue manipulation */    if (Fw && Fw != scr->mwm_focus && Fw != &scr->mwm_root)    {	MwmWindow *anc;	anc = Fw->ancestor;	MISC_RemoveFromTree(scr, Fw);	MISC_AddToTree(scr, Fw);	anc = MISC_RootOfTree(Fw);	if (Fw != anc->focus_in_tree)	{	    Fw = anc->focus_in_tree;	    /* Without the if statement below, we can crash here.	     * Danny 16/4/97 */	    if (Fw)            {		w = Fw->w;            }	}    }    if (Mwm.number_of_screens > 1)    {	XQueryPointer(dpy, scr->root_win, &JunkRoot, &JunkChild,		      &JunkX, &JunkY, &JunkX, &JunkY, &JunkMask);	if (JunkRoot != scr->root_win)	{	    if ((Mwm.keyboard_focus_policy == XmEXPLICIT) &&		(scr->mwm_grabbing != NULL))	    {		/* Need to grab buttons for focus window */		XSync(dpy, 0);		for (i = 0; i < 3; i++)		    if (scr->buttons2grab & (1 << i))		    {			XGrabButton(dpy, (i + 1), 0, scr->mwm_grabbing->frame, True,				  ButtonPressMask, GrabModeSync, GrabModeAsync,				    None, scr->cursors[SYS_CURS]);			XGrabButton(dpy, (i + 1), LockMask, scr->mwm_grabbing->frame, True,				  ButtonPressMask, GrabModeSync, GrabModeAsync,				    None, scr->cursors[SYS_CURS]);		    }		scr->mwm_focus = NULL;		scr->mwm_grabbing = NULL;		XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, MISC_FetchEventTime());	    }	    return;	}    }    if ((Fw != NULL) && (Fw->Desk != scr->current_desk))    {	Fw = NULL;	w = scr->no_focus_win;    }    if ((Mwm.keyboard_focus_policy == XmEXPLICIT) && (scr->mwm_grabbing != Fw))    {	/* need to grab all buttons for window that we are about to	 * unfocus */	if (scr->mwm_grabbing != NULL)	{	    XSync(dpy, 0);	    for (i = 0; i < 3; i++)		if (scr->buttons2grab & (1 << i))		{		    XGrabButton(dpy, (i + 1), 0, scr->mwm_grabbing->frame, True,			    ButtonPressMask, GrabModeSync, GrabModeAsync, None,				scr->cursors[SYS_CURS]);		    XGrabButton(dpy, (i + 1), LockMask, scr->mwm_grabbing->frame, True,			    ButtonPressMask, GrabModeSync, GrabModeAsync, None,				scr->cursors[SYS_CURS]);		}	    scr->mwm_grabbing = NULL;	}	/* if we do click to focus, remove the grab on mouse events that	 * was made to detect the focus change */	if ((Mwm.keyboard_focus_policy == XmEXPLICIT) && (Fw != NULL))	{	    for (i = 0; i < 3; i++)		if (scr->buttons2grab & (1 << i))		{		    XUngrabButton(dpy, (i + 1), 0, Fw->frame);		    XUngrabButton(dpy, (i + 1), LockMask, Fw->frame);		}	    scr->mwm_grabbing = Fw;	}    }    if ((Fw) && (Fw->flags & ICONIFIED) && (Fw->icon_w))    {	w = Fw->icon_w;	ICON_UpdateWindow(scr, Fw, True);    }    if (!((Fw) && (Fw->wmhints) && (Fw->wmhints->flags & InputHint) &&	  (Fw->wmhints->input == False)))    {        /* Window rw; */        /* int rt; */	/* Window will accept input focus */        /* MLM: 6/??/98.  A very weird thing can happen here.  We set         * the focus, but if you add a call just below here to XGetInputFocus(),         * you'll see that the focus has reverted to the old value.  I *think*         * this is due to the XSetInputFocus calls in the menu system -- I         * think there is a race condition where a dying application with         * a posted menu can reclaim the focus *after* their window manager         * info is gone (matte and decor), but before the application         * really terminates.  This manifests itself as a "missing" FocusIn         * event, but we receive the FocusOut event when the window finally         * goes away.  The (hack) fix for this is in events.c (see FocusOut         * in the event handler).         */	XSetInputFocus(dpy, w, RevertToParent, MISC_FetchEventTime());	scr->mwm_focus = Fw;    }    else if ((scr->mwm_focus) && (scr->mwm_focus->Desk == scr->current_desk))    {	/* Window doesn't want focus. Leave focus alone */	/* XSetInputFocus (dpy,scr->mwm_highlight->w , RevertToParent, MISC_FetchEventTime()); */    }    else    {	XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, MISC_FetchEventTime());	scr->mwm_focus = NULL;    }    if ((Fw) && (Fw->flags & WM_TAKES_FOCUS))	PROP_SendClientMessage(w, XA_WM_TAKE_FOCUS, MISC_FetchEventTime());    XSync(dpy, 0);}/* * Moves focus to specified window  */voidWIN_ChangeFocus(ScreenInfo *scr, MwmWindow *t, int DeIconifyOnly){    int dx, dy;    int cx, cy;    int x, y;    if (t == (MwmWindow *)0)	return;    if (t->Desk != scr->current_desk)	DT_ChangeDesks(scr, 0, t->Desk);    if (t->flags & ICONIFIED)    {	cx = t->icon_xl_loc + t->icon_w_width / 2;	cy = t->icon_y_loc + t->icon_p_height +	    (scr->components[MWM_ICON].f_height + 6) / 2;    }    else    {	cx = t->frame_x + t->frame_width / 2;	cy = t->frame_y + t->frame_height / 2;    }    dx = (cx + scr->virt_x) / scr->d_width * scr->d_width;    dy = (cy + scr->virt_y) / scr->d_height * scr->d_height;    PAGER_MoveViewPort(scr, dx, dy, True);    if (t->flags & ICONIFIED)    {	x = t->icon_xl_loc + t->icon_w_width / 2;	y = t->icon_y_loc + t->icon_p_height +	    (scr->components[MWM_ICON].f_height + 6) / 2;    }    else    {	x = t->frame_x;	y = t->frame_y;    }    if (!(Mwm.keyboard_focus_policy == XmEXPLICIT))	XWarpPointer(dpy, None, scr->root_win, 0, 0, 0, 0, x + 2, y + 2);    WIN_Raise(scr, t);    /* If the window is still not visible, make it visible! */    if (((t->frame_x + t->frame_height) < 0) || (t->frame_y + t->frame_width < 0) ||	(t->frame_x > scr->d_width) || (t->frame_y > scr->d_height))    {	DEC_ConfigureDecorations(scr, t, 0, 0, t->frame_width, t->frame_height, False);	if (!(Mwm.keyboard_focus_policy == XmEXPLICIT))	    XWarpPointer(dpy, None, scr->root_win, 0, 0, 0, 0, 2, 2);    }    MISC_Ungrab(scr);    WIN_SetFocus(scr, t->w, t);}/* * Puts windows back where they were before mwm took over  */voidWIN_RestoreWithdrawn(ScreenInfo *scr, MwmWindow *tmp, Boolean restart){    int a, b, w2, h2;    unsigned int bw, mask;    XWindowChanges xwc;    if (!tmp)	return;    if (XGetGeometry(dpy, tmp->w, &JunkRoot, &xwc.x, &xwc.y,		     &JunkWidth, &JunkHeight, &bw, &JunkDepth))    {	XTranslateCoordinates(dpy, tmp->frame, scr->root_win, xwc.x, xwc.y,			      &a, &b, &JunkChild);	xwc.x = a + tmp->xdiff;	xwc.y = b + tmp->ydiff;	xwc.border_width = tmp->old_bw;	mask = (CWX | CWY | CWBorderWidth);	/* We can not assume that the window is currently on the screen.	 * Although this is normally the case, it is not always true.  The	 * most common example is when the user does something in an	 * application which will, after some amount of computational delay,	 * cause the window to be unmapped, but then switches screens before	 * this happens.  The XTranslateCoordinates call above will set the	 * window coordinates to either be larger than the screen, or negative.	 * This will result in the window being placed in odd, or even	 * unviewable locations when the window is remapped.  The followin code	 * forces the "relative" location to be within the bounds of the display.	 *	 * gpw -- 11/11/93	 *	 * Unfortunately, this does horrendous things during re-starts, 	 * hence the "if(restart) clause (RN) 	 *	 * Also, fixed so that it only does this stuff if a window is more than	 * half off the screen. (RN)	 */	if (!restart)	{	    /* Don't mess with it if its partially on the screen now */	    if ((tmp->frame_x < 0) || (tmp->frame_y < 0) ||		(tmp->frame_x >= scr->d_width) ||		(tmp->frame_y >= scr->d_height))	    {		w2 = (tmp->frame_width >> 1);		h2 = (tmp->frame_height >> 1);		if ((xwc.x < -w2) || (xwc.x > (scr->d_width - w2)))		{		    xwc.x = xwc.x % scr->d_width;		    if (xwc.x < -w2)			xwc.x += scr->d_width;		}		if ((xwc.y < -h2) || (xwc.y > (scr->d_height - h2)))		{		    xwc.y = xwc.y % scr->d_height;		    if (xwc.y < -h2)			xwc.y += scr->d_height;		}	    }	}	XReparentWindow(dpy, tmp->w, scr->root_win, xwc.x, xwc.y);	if ((tmp->flags & ICONIFIED))	{	    if (tmp->icon_w)		XUnmapWindow(dpy, tmp->icon_w);	    if (tmp->icon_pixmap_w)		XUnmapWindow(dpy, tmp->icon_pixmap_w);	}	XConfigureWindow(dpy, tmp->w, mask, &xwc);	XSync(dpy, 0);    }}/* * raise a window */voidWIN_Raise(ScreenInfo *scr, MwmWindow *t){    int count, i;    Window *wins;    MISC_SetTimer(0);    /* raise the target, at least */    count = 1;    count += count_transients(scr, t);    if ((t->flags & ICONIFIED))	count += 2;    if ((scr->pager_win) && !(t->flags & STICKY))	XRaiseWindow(dpy, t->pager_view);    wins = (Window *)XtMalloc(count * sizeof(Window));    i = 0;    /* now raise transients */    gather_transients(t, wins, &i);    if ((t->flags & ICONIFIED))    {	wins[i++] = t->icon_w;	wins[i++] = t->icon_pixmap_w;    }    wins[i++] = t->frame;    scr->mwm_last_raised = t;    if (i > 0)	XRaiseWindow(dpy, wins[0]);    XRestackWindows(dpy, wins, i);    XtFree((char *)wins);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -