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

📄 functions.c

📁 安装DDD之前
💻 C
📖 第 1 页 / 共 3 页
字号:
	    {		char *disp_scr;		char *p_colon, *p_rdot;		/*		 * Make the child run on proper screen rather than on one		 * default for this instance of window manager. 		 */		disp_scr=(char *)malloc(strlen(DisplayString(dpy))+12);		strcpy(disp_scr, DisplayString(dpy));		p_colon = strrchr(disp_scr, ':');		if (p_colon == NULL)		    exit(102); 			/* erroneous display string */		p_rdot = strrchr(p_colon, '.');		if (p_rdot == NULL) {		    p_rdot = disp_scr + strlen(disp_scr);		}		sprintf(p_rdot, ".%lu", scr->screen);		if (SetEnvironment("DISPLAY", disp_scr) == -1)		    exit(104);		if (execl(shell, shell, "-c", action, (char *)0) == -1)		    exit(100);	    }#else         {          int childpid;          char *disp_scr;          char *p_colon, *p_rdot;		/*		 * Make the child run on proper screen rather than on one		 * default for this instance of window manager. 		 */		disp_scr=(char *)malloc(strlen(DisplayString(dpy))+12);		strcpy(disp_scr, DisplayString(dpy));		p_colon = strrchr(disp_scr, ':');		if (p_colon == NULL)		    exit(102); 			/* erroneous display string */		p_rdot = strrchr(p_colon, '.');		if (p_rdot == NULL) {		    p_rdot = disp_scr + strlen(disp_scr);		}		sprintf(p_rdot, ".%lu", scr->screen);		if (SetEnvironment("DISPLAY", disp_scr) == -1)		    exit(104);          /* FIXME: this shouldn't be an unconditional call to cmd.exe.                    Instead we should figure out which shell to call                    according to the XFree86 OS/2 standard! */	    childpid = spawnl(P_NOWAIT, "cmd.exe", "cmd.exe", "/C",                     action,(char *)0);         }#endif	    XUngrabPointer(dpy, CurrentTime);	    XSync(dpy, 0);	}	break;    case F_FOCUS:	WIN_ChangeFocus(scr, tmp_win, 0);	break;    case F_FOCUS_COLOR:	fprintf(stderr, "FOCUS_COLOR NOT SUPPORTED YET\n");	break;    case F_GOTO_PAGE:	/* back up 1 virtual desktop page */	x = val1 * scr->d_width;	y = val2 * scr->d_height;	PAGER_MoveViewPort(scr, x, y, True);	break;    case F_ICONIFY:	if (tmp_win == NULL)	    break;	if (tmp_win->flags & ICONIFIED)	{	    if (val1 <= 0)		ICON_DeIconify(scr, tmp_win);	}	else	{	    if (function_allowed(func, tmp_win) == 0)	    {		XBell(dpy, scr->screen);		break;	    }	    if (val1 >= 0)	    {		if (function_allowed(func, tmp_win) == 0)		{		    XBell(dpy, scr->screen);		    break;		}		ICON_Iconify(scr, tmp_win,			     eventp->xbutton.x_root - 5,			     eventp->xbutton.y_root - 5);	    }	}	break;    case F_LOWER:	if (tmp_win == NULL)	    break;	WIN_Lower(scr, MISC_RootOfTree(tmp_win));	break;    case F_MAXIMIZE:	if (tmp_win == NULL) {           fprintf(stderr, "Could not maximize - tmp_win is 0\n");	    break;        }	if (function_allowed(func, tmp_win) == 0)	{           fprintf(stderr, "Could not maximize - op not allowed\n");	    XBell(dpy, scr->screen);	    break;	}	maximize(scr, tmp_win, val1, val2, val1_unit, val2_unit);	break;    case F_MOVE:	if (tmp_win == NULL)	    break;	if (function_allowed(func, tmp_win) == 0)	{	    XBell(dpy, scr->screen);	    break;	}	move(scr, eventp, w, tmp_win, context, val1, val2, val1_unit, val2_unit);	break;    case F_MOVECURSOR:	XQueryPointer(dpy, scr->root_win, &JunkRoot, &JunkChild,		      &x, &y, &JunkX, &JunkY, &JunkMask);	delta_x = 0;	delta_y = 0;	warp_x = 0;	warp_y = 0;	if (x >= scr->d_width - 2)	{	    delta_x = scr->edge_scroll_x;	    warp_x = scr->edge_scroll_x - 4;	}	if (y >= scr->d_height - 2)	{	    delta_y = scr->edge_scroll_y;	    warp_y = scr->edge_scroll_y - 4;	}	if (x < 2)	{	    delta_x = -scr->edge_scroll_x;	    warp_x = -scr->edge_scroll_x + 4;	}	if (y < 2)	{	    delta_y = -scr->edge_scroll_y;	    warp_y = -scr->edge_scroll_y + 4;	}	if (scr->virt_x + delta_x < 0)	    delta_x = -scr->virt_x;	if (scr->virt_y + delta_y < 0)	    delta_y = -scr->virt_y;	if (scr->virt_x + delta_x > scr->virt_x_max)	    delta_x = scr->virt_x_max - scr->virt_x;	if (scr->virt_y + delta_y > scr->virt_y_max)	    delta_y = scr->virt_y_max - scr->virt_y;	if ((delta_x != 0) || (delta_y != 0))	{	    PAGER_MoveViewPort(scr, scr->virt_x + delta_x, scr->virt_y + delta_y, True);	    XWarpPointer(dpy, scr->root_win, scr->root_win, 0, 0, scr->d_width,			 scr->d_height,			 x - warp_x,			 y - warp_y);	}	XWarpPointer(dpy, scr->root_win, scr->root_win, 0, 0, scr->d_width,		     scr->d_height, x + val1 * val1_unit / 100 - warp_x,		     y + val2 * val2_unit / 100 - warp_y);	break;    case F_NEXT_CMAP:	fprintf(stderr, "NEXT_COLORMAP NOT SUPPORTED YET\n");	break;    case F_NEXT_KEY:#if 1	ExplicitMoveFocus(scr, tmp_win, eventp);#else	fprintf(stderr, "NEXT_KEY NOT SUPPORTED YET\n");#endif	break;    case F_NORMALIZE:	if (tmp_win == NULL)	    break;	normalize(scr, tmp_win, val1, val2, val1_unit, val2_unit);	break;    case F_NORM_AND_RAISE:	normalize(scr, tmp_win, val1, val2, val1_unit, val2_unit);	if (tmp_win)	    WIN_Raise(scr, MISC_RootOfTree(tmp_win));	break;    case F_PACK_ICONS:	fprintf(stderr, "PACK_ICONS NOT SUPPORTED YET\n");	break;    case F_PASS_KEYS:	fprintf(stderr, "PASS_KEYS NOT SUPPORTED YET\n");	break;    case F_POPUP:	MENU_Reset();	menuFromFrameOrWindowOrTitlebar = False;	MENU_PopupMenu(scr, menu);	break;    case F_PREV_CMAP:	fprintf(stderr, "PREV_CMAP NOT SUPPORTED YET\n");	break;    case F_PREV_KEY:	fprintf(stderr, "PREV_KEY NOT SUPPORTED YET\n");	break;    case F_QUIT:	if (Mwm.show_feedback & MWM_FEEDBACK_QUIT)	    quit(scr);	else	    MWM_Done(0, NULL);	break;    case F_RAISE:	if (tmp_win)	    WIN_Raise(scr, MISC_RootOfTree(tmp_win));	break;    case F_RAISE_IT:	if (val1 != 0)	{	    WIN_ChangeFocus(scr, (MwmWindow *)val1, 0);	    if (((MwmWindow *)(val1))->flags & ICONIFIED)	    {		ICON_DeIconify(scr, (MwmWindow *)val1);		WIN_ChangeFocus(scr, (MwmWindow *)val1, 0);	    }	}	break;    case F_RAISELOWER:	if (tmp_win == NULL)	    break;	if ((tmp_win == scr->mwm_last_raised) ||	    (tmp_win->flags & VISIBLE))	{	    WIN_Lower(scr, tmp_win);	}	else	    WIN_Raise(scr, tmp_win);	break;    case F_REFRESH:	{	    XSetWindowAttributes attributes;	    unsigned long valuemask;	    valuemask = (CWBackPixel);	    attributes.background_pixel = scr->components[MWM_BORDER].foreground;	    attributes.backing_store = NotUseful;	    w = XCreateWindow(dpy, scr->root_win, 0, 0,			      (unsigned int)scr->d_width,			      (unsigned int)scr->d_height,			      (unsigned int)0,			      CopyFromParent, (unsigned int)CopyFromParent,			      (Visual *)CopyFromParent, valuemask,			      &attributes);	    XMapWindow(dpy, w);	    XDestroyWindow(dpy, w);	    XFlush(dpy);	}	break;    case F_REFRESH_WIN:	fprintf(stderr, "REFRESH_WIN NOT SUPPORTED YET\n");	break;    case F_RESIZE:	if (tmp_win == NULL)	    break;	if (function_allowed(func, tmp_win) == 0)	{	    XBell(dpy, scr->screen);	    break;	}	tmp_win->flags &= ~MAXIMIZED;	RESIZE_EventLoop(scr, w, tmp_win, val1, val2, val1_unit, val2_unit);	break;    case F_RESTART:       if ((Mwm.show_feedback & MWM_FEEDBACK_RESTART) && (!action || !*action))	    restart(scr);	else {         if (!action || !*action) {	    MWM_Done(1, g_argv[0]);	  }  else {	    MWM_Done(1, action);	  }	}	break;    case F_RESTORE_AND_RAISE:	fprintf(stderr, "RESTORE_AND_RAISE NOT SUPPORTED YET\n");	break;    case F_SCROLL:	if ((val1 > -100000) && (val1 < 100000))	    x = scr->virt_x + val1 * val1_unit / 100;	else	    x = scr->virt_x + (val1 / 1000) * val1_unit / 100;	if ((val2 > -100000) && (val2 < 100000))	    y = scr->virt_y + val2 * val2_unit / 100;	else	    y = scr->virt_y + (val2 / 1000) * val2_unit / 100;	if (((val1 <= -100000) || (val1 >= 100000)) && (x > scr->virt_x_max))	{	    x = 0;	    y += scr->d_height;	    if (y > scr->virt_y_max)		y = 0;	}	if (((val1 <= -100000) || (val1 >= 100000)) && (x < 0))	{	    x = scr->virt_x_max;	    y -= scr->d_height;	    if (y < 0)		y = scr->virt_y_max;	}	if (((val2 <= -100000) || (val2 >= 100000)) && (y > scr->virt_y_max))	{	    y = 0;	    x += scr->d_width;	    if (x > scr->virt_x_max)		x = 0;	}	if (((val2 <= -100000) || (val2 >= 100000)) && (y < 0))	{	    y = scr->virt_y_max;	    x -= scr->d_width;	    if (x < 0)		x = scr->virt_x_max;	}	PAGER_MoveViewPort(scr, x, y, True);	break;    case F_SCREEN:	{	    if (prev_screen == -1)                prev_screen = scr->screen;	    if (strcmp(action, "next") == 0)	        scrno = scr->screen + 1;	    else if (strcmp(action, "prev") == 0)	        scrno = scr->screen - 1;	    else if (strcmp(action, "back") == 0)	        scrno = prev_screen;	    else	        scrno = atoi(action);	    /* A.R. This assumes we have all our screens managed.	     * FIXME: Skip unmanaged screens if any...	     */	    scrno %= Mwm.number_of_screens;	    if (scrno < 0)	        scrno += Mwm.number_of_screens;	    if (scrno == scr->screen)		    break;	    prev_screen = scr->screen;	    /* FIXME: 	     * Without this call to MISC_Ungrab() f.screen does not 	     * work when called from a menu. That's because upper functions	     * from menus.c grab the pointer and we are not able to warp to	     * another root window.	     *     "Note you cannot use XWarpPointer to move the pointer	     *      outside the confine_to window of an active grab."	     *	     * MISC_Ungrab() here does much more things than we really 	     * need. IMHO, the design of update_menu() and friends should	     * better be changed to restore from all those settings	     * actual for the menu only, before FUNC_Exec() is invoked.	     * For now, MISC_Ungrab() is called here.	     * 	     * 		Andrei Rezvov <rezvov@niisi.msk.ru>	     */	    MISC_Ungrab(scr);	    XQueryPointer(dpy, scr->root_win/*eventp->root*/, 		          &JunkRoot, &JunkChild,		          &x, &y, &JunkX, &JunkY, &JunkMask);	    XWarpPointer(dpy, None, Mwm.screen_info[scrno]->root_win, 		          0, 0, 0, 0, x, y);	    XSetInputFocus(dpy, PointerRoot, RevertToParent, CurrentTime);	    XFlush(dpy);	}	break;    case F_SEND_MSG:	if (tmp_win && (tmp_win->flags & MWM_MESSAGES) &&	    PROP_VerifyMwmMessage(tmp_win, atoi(action)))	    PROP_SendMwmMessage(tmp_win->w, atoi(action), CurrentTime);	break;    case F_SET_BEHAVIOR:	if (Mwm.show_feedback & MWM_FEEDBACK_BEHAVIOR)	    set_behavior(scr);	else	    toggle_behavior(NULL, (XtPointer)scr, NULL);	break;    case F_STICK:	if (tmp_win == NULL)	    break;	if (scr->mwm_highlight != tmp_win)	{	    /* Need to make DEC_DrawDecorations change the window back color */	    temp = scr->mwm_highlight;	    DEC_DrawDecorations(scr, tmp_win, True, True, True, None);	    DEC_DrawDecorations(scr, tmp_win, False, True, True, None);	    DEC_DrawDecorations(scr, temp, True, True, True, None);	}	PAGER_UpdateView(scr, tmp_win);	/* Need to re-draw pager_view in case the window	 * is unsticking */	if (scr->mwm_highlight == tmp_win)	{	    TextColor = scr->components[MWM_PAGER].active_foreground;	    BackPixmap = scr->components[MWM_PAGER].active_background_pixmap;	    BackColor = scr->components[MWM_PAGER].active_background;	}	else	{	    TextColor = scr->components[MWM_PAGER].foreground;	    BackPixmap = scr->components[MWM_PAGER].background_pixmap;	    BackColor = scr->components[MWM_PAGER].background;	}	if (scr->d_depth < 2 && BackPixmap != XmUNSPECIFIED_PIXMAP)	    XSetWindowBackgroundPixmap(dpy, tmp_win->pager_view, BackPixmap);	else	    XSetWindowBackground(dpy, tmp_win->pager_view, BackColor);	XClearWindow(dpy, tmp_win->pager_view);	if ((tmp_win->icon_label != NULL) &&	    (scr->components[MWM_PAGER].f_height > 0))	{	    XDrawString(dpy, tmp_win->pager_view,			scr->components[MWM_PAGER].normal_GC,			2, scr->components[MWM_PAGER].f_y + 2,			tmp_win->icon_label, strlen(tmp_win->icon_label));	}	break;    case F_TOGGLE_PAGE:	if (DoHandlePageing)	    DoHandlePageing = 0;	else	    DoHandlePageing = 1;	PAN_CheckBounds(scr);	break;    case F_WARP:	t = circulate(scr, tmp_win, action, DOWN);	if ((t) && (t->flags & ICONIFIED))	{	    WIN_ChangeFocus(scr, t, 0);	    ICON_DeIconify(scr, t);	}	if (t)	    WIN_ChangeFocus(scr, t, 0);	break;    case F_W_POPUP:	MENU_Reset();	menuFromFrameOrWindowOrTitlebar = True;	if (tmp_win && tmp_win->custom_menu)	    menu = tmp_win->custom_menu;	if (menu)	    MENU_WinMenu(scr, menu, tmp_win,		     (eventp->type == ButtonPress ||		      eventp->type == ButtonRelease) &&		     scr->event_context != C_MENUB,		     context == C_ICON);	break;    case F_WINDOWLIST:	win_list(scr, val1, val2);	break;    }    /* Only wait for an all-buttons-up condition after calls from     * regular built-ins, not from complex-functions or modules. */#if 0    MISC_WaitForButtonsUp(scr);#endif}

⌨️ 快捷键说明

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