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

📄 icons.c

📁 安装DDD之前
💻 C
📖 第 1 页 / 共 3 页
字号:
	seg[i].x2 = x + w - 1;	seg[i++].y2 = y + h - 1;	XDrawSegments(dpy, win, ShadowGC, seg, i);    }    /* left */    else    {	i = 0;	seg[i].x1 = x;	seg[i].y1 = y;	seg[i].x2 = w + x - 1;	seg[i++].y2 = y;	seg[i].x1 = x;	seg[i].y1 = y;	seg[i].x2 = x;	seg[i++].y2 = h + y - 1;	XDrawSegments(dpy, win, ReliefGC, seg, i);	i = 0;	seg[i].x1 = x;	seg[i].y1 = y + h - 1;	seg[i].x2 = w + x - 1;	seg[i++].y2 = y + h - 1;	seg[i].x1 = x + w - 1;	seg[i].y1 = y + t->icon_border_width - 1;	seg[i].x2 = x + w - 1;	seg[i++].y2 = y + h - t->icon_border_width;	XDrawSegments(dpy, win, ShadowGC, seg, i);    }}#endif/* * Creates an icon window as needed */voidICON_CreateWindow(ScreenInfo *scr, MwmWindow *tmp_win, int def_x, int def_y){    int final_x, final_y;    unsigned long valuemask;	/* mask for create windows */    XSetWindowAttributes attributes;	/* attributes for create windows */    tmp_win->flags |= ICON_OURS;    tmp_win->flags &= ~XPM_FLAG;    tmp_win->flags &= ~PIXMAP_OURS;    tmp_win->flags &= ~SHAPED_ICON;    tmp_win->icon_pixmap_w = None;    tmp_win->icon_pixmap = None;    tmp_win->icon_depth = 0;    /* First, see if it was specified in the .mwmrc */    tmp_win->icon_p_height = 0;    tmp_win->icon_p_width = 0;    if ((scr->icon_decoration & XmICON_IMAGE) && tmp_win->use_client_icon)    {	/* First, See if the app supplies its own icon window */	if ((tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0) &&	    (tmp_win->wmhints) && (tmp_win->wmhints->flags & IconWindowHint))	    get_icon_window(scr, tmp_win);	/* Next, try to get icon bitmap from the application */	if ((tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0) &&	    (tmp_win->wmhints) && (tmp_win->wmhints->flags & IconPixmapHint))	    get_icon_bitmap(tmp_win);	/* Next, check for a color pixmap */	if (tmp_win->icon_image != NULL &&	    (tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0))	    get_xpm_file(scr, tmp_win);	/* Finally, check for a monochrome bitmap */	if (tmp_win->icon_image != NULL &&	    (tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0))	    get_bitmap_file(scr, tmp_win);    }    else if (scr->icon_decoration & XmICON_IMAGE)    {	/* First, check for a color pixmap */	if (tmp_win->icon_image != NULL &&	    (tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0))	    get_xpm_file(scr, tmp_win);	/* Next, check for a monochrome bitmap */	if (tmp_win->icon_image != NULL &&	    (tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0))	    get_bitmap_file(scr, tmp_win);	/* Next, See if the app supplies its own icon window */	if ((tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0) &&	    (tmp_win->wmhints) && (tmp_win->wmhints->flags & IconWindowHint))	    get_icon_window(scr, tmp_win);	/* Finally, try to get icon bitmap from the application */	if ((tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0) &&	    (tmp_win->wmhints) && (tmp_win->wmhints->flags & IconPixmapHint))	    get_icon_bitmap(tmp_win);    }    /* If all that failed, use the default */    if ((scr->icon_decoration & XmICON_IMAGE) &&	(tmp_win->icon_p_height == 0) && (tmp_win->icon_p_width == 0))    {	tmp_win->icon_pixmap = XCreateBitmapFromData(dpy,					scr->root_win, (char *)def_bitmap_bits,					  def_bitmap_width, def_bitmap_height);	tmp_win->icon_p_width = def_bitmap_width;	tmp_win->icon_p_height = def_bitmap_height;	tmp_win->flags |= PIXMAP_OURS;    }    /* compute the icon border width, if applicable */    if (tmp_win->flags & SHAPED_ICON)	tmp_win->icon_border_width = 0;    else	tmp_win->icon_border_width = scr->frame_border_width;    /* figure out the icon label size */    tmp_win->icon_t_width =	XTextWidth(scr->components[MWM_ICON].font,		   tmp_win->icon_label, strlen(tmp_win->icon_label));    tmp_win->icon_w_height = scr->components[MWM_ICON].f_height + 6;    if ((tmp_win->flags & ICON_OURS) && (tmp_win->icon_p_height > 0))    {	tmp_win->icon_p_width += 4;	tmp_win->icon_p_height += 4;    }    if (tmp_win->icon_p_width == 0)	tmp_win->icon_p_width = tmp_win->icon_t_width + 6;    tmp_win->icon_w_width = tmp_win->icon_p_width;    /* clip to fit on screen */    final_x = def_x;    final_y = def_y;    if (final_x < 0)	final_x = 0;    if (final_y < 0)	final_y = 0;    if (final_x + tmp_win->icon_w_width >= scr->d_width)	final_x = scr->d_width - tmp_win->icon_w_width - 1;    if (final_y + tmp_win->icon_w_height >= scr->d_height)	final_y = scr->d_height - tmp_win->icon_w_height - 1;    tmp_win->icon_x_loc = final_x;    tmp_win->icon_xl_loc = final_x;    tmp_win->icon_y_loc = final_y;    attributes.background_pixel = tmp_win->icon_image_background;    valuemask = CWBorderPixel | CWCursor | CWEventMask | CWBackPixel;    attributes.border_pixel = tmp_win->icon_image_foreground;    attributes.cursor = scr->cursors[DEFAULT_CURS];    attributes.event_mask = (ButtonPressMask | ButtonReleaseMask |			     VisibilityChangeMask |			     ExposureMask | KeyPressMask | EnterWindowMask |			     FocusChangeMask);    if (scr->icon_decoration & (XmICON_LABEL | XmICON_ACTIVELABEL))    {	tmp_win->icon_w =	    XCreateWindow(dpy, scr->root_win,			  final_x, final_y + tmp_win->icon_p_height,			  tmp_win->icon_w_width, tmp_win->icon_w_height, 0,			  CopyFromParent, CopyFromParent, CopyFromParent,			  valuemask, &attributes);    }    else	tmp_win->icon_w = None;    if (scr->icon_decoration & XmICON_IMAGE)    {        /* int i; */#if 0	attributes.event_mask = KeyPressMask | ButtonPressMask;	attributes.override_redirect = True;	tmp_win->icon_frame = XCreateWindow(dpy, scr->root_win,					    final_x, final_y,					    tmp_win->icon_p_width +					    2 * tmp_win->icon_border_width,					    tmp_win->icon_p_height +					    2 * tmp_win->icon_border_width,					    0, CopyFromParent,					    CopyFromParent, CopyFromParent,#if 0					    CWEventMask | CWOverrideRedirect,#else					    valuemask,#endif					    &attributes);#endif#if 0	valuemask = CWBorderPixel | CWCursor | CWEventMask | CWBackPixel;	attributes.event_mask = (ButtonPressMask | ButtonReleaseMask |				 VisibilityChangeMask |				 ExposureMask | KeyPressMask | EnterWindowMask |				 FocusChangeMask);#endif	if ((tmp_win->flags & ICON_OURS) && (tmp_win->icon_p_width > 0) &&	    (tmp_win->icon_p_height > 0))	{	    tmp_win->icon_pixmap_w =		XCreateWindow(dpy,#if 0			      tmp_win->icon_frame,#else			      scr->root_win,#endif			      final_x + tmp_win->icon_border_width,			      final_y + tmp_win->icon_border_width,			      tmp_win->icon_p_width,			      tmp_win->icon_p_height,			      0, CopyFromParent,			      CopyFromParent, CopyFromParent,			      valuemask, &attributes);	}	else	{	    attributes.event_mask = (ButtonPressMask | ButtonReleaseMask |				     VisibilityChangeMask |				     KeyPressMask | EnterWindowMask |				     FocusChangeMask | LeaveWindowMask);	    valuemask = CWEventMask;	    XChangeWindowAttributes(dpy, tmp_win->icon_pixmap_w,				    valuemask, &attributes);#if 0	    /* This used to say:	     *   Make sure that the window is a child of the root window!	     *   Olwais screws this up, maybe others do too!	     * Now, make sure that *we're* the parent of the pixmap window	     */	    XReparentWindow(dpy, tmp_win->icon_pixmap_w, tmp_win->icon_frame,			    tmp_win->icon_border_width,			    tmp_win->icon_border_width);#else	    XReparentWindow(dpy, tmp_win->icon_pixmap_w, scr->root_win,			    0, 0);#endif	}#if 0	if (!(tmp_win->flags & SHAPED_ICON))	{	    for (i = 0; i < 4; i++)	    {		tmp_win->icon_borders[i] =		    XCreateWindow(dpy, tmp_win->icon_frame, 0, 0,				  tmp_win->icon_border_width,				  tmp_win->icon_border_width,				  0, CopyFromParent,				  CopyFromParent, CopyFromParent,				  valuemask, &attributes);		XSaveContext(dpy, tmp_win->icon_borders[i],			     MwmContext, (XPointer)tmp_win);	    }	}	else	{	    for (i = 0; i < 4; i++)		tmp_win->icon_borders[i] = None;	}	XMapWindow(dpy, tmp_win->icon_frame);	XMapSubwindows(dpy, tmp_win->icon_frame);	XRaiseWindow(dpy, tmp_win->icon_pixmap_w);#endif    }    else	tmp_win->icon_pixmap_w = None;    if (tmp_win->flags & SHAPED_ICON)    {	XShapeCombineMask(dpy, tmp_win->icon_pixmap_w, ShapeBounding, 2, 2,			  tmp_win->icon_mask_pixmap, ShapeSet);    }    if (tmp_win->icon_w != None)    {	XSaveContext(dpy, tmp_win->icon_w, MwmContext, (XPointer)tmp_win);	XDefineCursor(dpy, tmp_win->icon_w, scr->cursors[DEFAULT_CURS]);	grab_icon_buttons(scr, tmp_win, tmp_win->icon_w);	grab_icon_keys(scr, tmp_win, tmp_win->icon_w);    }    if (tmp_win->icon_pixmap_w != None)    {	XSaveContext(dpy, tmp_win->icon_pixmap_w, MwmContext, (XPointer)tmp_win);	XDefineCursor(dpy, tmp_win->icon_pixmap_w, scr->cursors[DEFAULT_CURS]);	grab_icon_buttons(scr, tmp_win, tmp_win->icon_pixmap_w);	grab_icon_keys(scr, tmp_win, tmp_win->icon_pixmap_w);    }}/* * Draws the icon window */voidICON_DrawWindow(ScreenInfo *scr, MwmWindow *tmp){    GC Shadow, Relief;    Pixel TextColor, BackColor;    int x;    char *label;    if (tmp->icon_w != None)	MISC_FlushExpose(tmp->icon_w);    if (tmp->icon_pixmap_w != None)	MISC_FlushExpose(tmp->icon_pixmap_w);    if (tmp == scr->mwm_highlight && (scr->icon_decoration & XmICON_ACTIVELABEL) && tmp->icon_active_label != NoName && tmp->icon_active_label != NULL      && tmp->icon_active_label[0] != '\0')	label = tmp->icon_active_label;    else	label = tmp->icon_label;    if (label == NULL)	label = "";    tmp->icon_t_width = XTextWidth(scr->components[MWM_ICON].font,				   label, strlen(label));    if (scr->mwm_highlight == tmp)    {	Relief = scr->components[MWM_ICON].active_top_GC;	Shadow = scr->components[MWM_ICON].active_bot_GC;	/* resize the icon name window */	if (tmp->icon_w != None)	{	    tmp->icon_w_width = tmp->icon_t_width + 6;	    if (tmp->icon_w_width < tmp->icon_p_width)		tmp->icon_w_width = tmp->icon_p_width;	    tmp->icon_xl_loc = tmp->icon_x_loc -		(tmp->icon_w_width - tmp->icon_p_width) / 2;	}	TextColor = scr->components[MWM_ICON].active_foreground;	BackColor = scr->components[MWM_ICON].active_background;    }    else    {	Relief = scr->components[MWM_ICON].top_GC;	Shadow = scr->components[MWM_ICON].bot_GC;	/* resize the icon name window */	if (tmp->icon_w != None)	{	    tmp->icon_w_width = tmp->icon_p_width;	    tmp->icon_xl_loc = tmp->icon_x_loc;	}	TextColor = scr->components[MWM_ICON].foreground;	BackColor = scr->components[MWM_ICON].background;    }#if 1    if ((tmp->flags & ICON_OURS) && (tmp->icon_pixmap_w != None))	XSetWindowBackground(dpy, tmp->icon_pixmap_w,			     BackColor);#else    if (!(tmp->flags & SHAPED_ICON))    {	int i;	XSetWindowAttributes attributes;	unsigned long valuemask;	for (i = 0; i < 4; i++)	{	    XWindowChanges xwc;	    unsigned int xwcm = CWWidth | CWHeight | CWX | CWY;	    if (i == 0)	    {		xwc.x = 0;		xwc.y = 0;		xwc.height = tmp->icon_border_width;		xwc.width = tmp->icon_p_width + 2 * tmp->icon_border_width;	    }	    else if (i == 1)	    {		xwc.x = tmp->icon_border_width + tmp->icon_p_width;		xwc.y = 0;		xwc.width = tmp->icon_border_width;		xwc.height = tmp->icon_p_height + 2 * tmp->icon_border_width;	    }	    else if (i == 2)	    {		xwc.x = 0;		xwc.y = tmp->icon_border_width + tmp->icon_p_height;		xwc.height = tmp->icon_border_width;		xwc.width = tmp->icon_p_width + 2 * tmp->icon_border_width;	    }	    else	    {		xwc.x = 0;		xwc.y = 0;		xwc.width = tmp->icon_border_width;		xwc.height = tmp->icon_p_height + 2 * tmp->icon_border_width;	    }	    XConfigureWindow(dpy, tmp->icon_borders[i], xwcm, &xwc);	}	valuemask = CWBackPixel;	if (scr->mwm_highlight == tmp)	    attributes.background_pixel = scr->components[MWM_ICON].active_background;	else	    attributes.background_pixel = scr->components[MWM_ICON].background;	for (i = 0; i < 4; i++)	{	    XChangeWindowAttributes(dpy, tmp->icon_borders[i],				    valuemask, &attributes);	    XClearWindow(dpy, tmp->icon_borders[i]);	    draw_icon_border(tmp, tmp->icon_borders[i], 0, 0,			     ((i % 2)			      ? tmp->icon_border_width			      : tmp->icon_p_width + 2 * tmp->icon_border_width),			     ((i % 2)			      ? tmp->icon_p_height + 2 * tmp->icon_border_width			      : tmp->icon_border_width),			     Relief, Shadow);	}	for (i = 0; i < 4; i++)	    if (tmp->icon_borders[i] != None)		MISC_FlushExpose(tmp->icon_borders[i]);    }#endif    if (tmp->icon_w != None)	XSetWindowBackground(dpy, tmp->icon_w, BackColor);    if (tmp->icon_pixmap_w != None)    {#if 0	XMoveWindow(dpy, tmp->icon_frame, tmp->icon_x_loc, tmp->icon_y_loc);#else	XMoveWindow(dpy, tmp->icon_pixmap_w, tmp->icon_x_loc,		    tmp->icon_y_loc);#endif    }    if (tmp->icon_w != None)

⌨️ 快捷键说明

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