📄 decorate.c
字号:
{ /* Just dump the windows any old place and let * DEC_ConfigureDecorations take care of the mess */ attributes.save_under = scr->components[MWM_RESIZE_H].save_under; for (i = 0; i < 4; i++) { attributes.cursor = scr->cursors[TOP_LEFT_CURS + i]; tmp_win->corners[i] = XCreateWindow(dpy, tmp_win->frame, 0, 0, tmp_win->corner_width, tmp_win->corner_width, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); } } else { for (i = 0; i < 4; i++) tmp_win->corners[i] = None; } if (scr->components[MWM_TITLE_A].background_pixmap != XmUNSPECIFIED_PIXMAP) { attributes.background_pixmap = scr->components[MWM_TITLE_A].background_pixmap; valuemask &= ~CWBackPixel; valuemask |= CWBackPixmap; } else { attributes.background_pixel = scr->components[MWM_TITLE_A].background; valuemask &= ~CWBackPixmap; valuemask |= CWBackPixel; } if (tmp_win->decorations & MWM_DECOR_TITLE) { tmp_win->title_x = tmp_win->boundary_width + tmp_win->title_height + 1; tmp_win->title_y = tmp_win->boundary_width; attributes.cursor = scr->cursors[TITLE_CURS]; attributes.save_under = scr->components[MWM_TITLE_A].save_under; tmp_win->title = XCreateWindow(dpy, tmp_win->frame, tmp_win->title_x, tmp_win->title_y, tmp_win->title_width, tmp_win->title_height, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); } else tmp_win->title = None; if (scr->components[MWM_MENU_B].background_pixmap != XmUNSPECIFIED_PIXMAP) { attributes.background_pixmap = scr->components[MWM_MENU_B].background_pixmap; valuemask &= ~CWBackPixel; valuemask |= CWBackPixmap; } else { attributes.background_pixel = scr->components[MWM_MENU_B].background; valuemask &= ~CWBackPixmap; valuemask |= CWBackPixel; } if (tmp_win->decorations & MWM_DECOR_MENU) { attributes.cursor = scr->cursors[SYS_CURS]; attributes.save_under = scr->components[MWM_MENU_B].save_under; tmp_win->menub = XCreateWindow(dpy, tmp_win->frame, tmp_win->title_height, 0, tmp_win->title_height, tmp_win->title_height, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); } else tmp_win->menub = None; if (scr->components[MWM_MINIMIZE_B].background_pixmap != XmUNSPECIFIED_PIXMAP) { attributes.background_pixmap = scr->components[MWM_MINIMIZE_B].background_pixmap; valuemask &= ~CWBackPixel; valuemask |= CWBackPixmap; } else { attributes.background_pixel = scr->components[MWM_MINIMIZE_B].background; valuemask &= ~CWBackPixmap; valuemask |= CWBackPixel; } if (tmp_win->decorations & MWM_DECOR_MINIMIZE) { attributes.save_under = scr->components[MWM_MINIMIZE_B].save_under; tmp_win->minimizeb = XCreateWindow(dpy, tmp_win->frame, tmp_win->title_width - tmp_win->title_height * 2, 0, tmp_win->title_height, tmp_win->title_height, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); } else tmp_win->minimizeb = None; if (scr->components[MWM_MAXIMIZE_B].background_pixmap != XmUNSPECIFIED_PIXMAP) { attributes.background_pixmap = scr->components[MWM_MAXIMIZE_B].background_pixmap; valuemask &= ~CWBackPixel; valuemask |= CWBackPixmap; } else { attributes.background_pixel = scr->components[MWM_MAXIMIZE_B].background; valuemask &= ~CWBackPixmap; valuemask |= CWBackPixel; } if (tmp_win->decorations & MWM_DECOR_MAXIMIZE) { attributes.save_under = scr->components[MWM_MAXIMIZE_B].save_under; tmp_win->maximizeb = XCreateWindow(dpy, tmp_win->frame, tmp_win->title_width - tmp_win->title_height * 1, 0, tmp_win->title_height, tmp_win->title_height, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); } else tmp_win->maximizeb = None; if (scr->components[MWM_BORDER].background_pixmap != XmUNSPECIFIED_PIXMAP) { attributes.background_pixmap = scr->components[MWM_BORDER].background_pixmap; valuemask &= ~CWBackPixel; valuemask |= CWBackPixmap; } else { attributes.background_pixel = scr->components[MWM_BORDER].background; valuemask &= ~CWBackPixmap; valuemask |= CWBackPixel; } if (tmp_win->decorations & MWM_DECOR_BORDER) { attributes.save_under = scr->components[MWM_BORDER].save_under; for (i = 0; i < 4; i++) { attributes.cursor = scr->cursors[TOP_CURS + i]; tmp_win->sides[i] = XCreateWindow(dpy, tmp_win->frame, 0, 0, tmp_win->boundary_width, tmp_win->boundary_width, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); } } else { for (i = 0; i < 4; i++) tmp_win->sides[i] = None; } XMapSubwindows(dpy, tmp_win->frame); XLowerWindow(dpy, tmp_win->shield); XRaiseWindow(dpy, tmp_win->parent); XReparentWindow(dpy, tmp_win->w, tmp_win->parent, tmp_win->matte_width, tmp_win->matte_width); valuemask = (CWEventMask | CWDontPropagate); attributes.event_mask = (StructureNotifyMask | PropertyChangeMask | VisibilityChangeMask | EnterWindowMask | LeaveWindowMask | ColormapChangeMask | FocusChangeMask); if (tmp_win->w == scr->pager_win) { scr->mwm_pager = tmp_win; tmp_win->flags |= STICKY; attributes.event_mask |= ButtonPressMask | ButtonReleaseMask | ExposureMask | ButtonMotionMask; attributes.do_not_propagate_mask = ButtonPressMask; } else attributes.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask; valuemask |= CWBackingStore; attributes.backing_store = WhenMapped; XChangeWindowAttributes(dpy, tmp_win->w, valuemask, &attributes);}/* * Inputs: * tmp_win - the MwmWindow pointer * x - the x coordinate of the upper-left outer corner of the frame * y - the y coordinate of the upper-left outer corner of the frame * w - the width of the frame window w/o border * h - the height of the frame window w/o border * * Special Considerations: * This routine will check to make sure the window is not completely * off the display, if it is, it'll bring some of it back on. * * The tmp_win->frame_XXX variables should NOT be updated with the * values of x,y,w,h prior to calling this routine, since the new * values are compared against the old to see whether a synthetic * ConfigureNotify event should be sent. (It should be sent if the * window was moved but not resized.) * */voidDEC_ConfigureDecorations(ScreenInfo *scr, MwmWindow *tmp_win, int x, int y, int w, int h, Boolean sendEvent){ XEvent client_event; XWindowChanges frame_wc, xwc; unsigned long frame_mask, xwcm; int cx, cy, i; Bool Resized = False; MwmWindow *t; int xwidth, ywidth; /* if windows is not being maximized, save size in case of maximization */ if (!(tmp_win->flags & MAXIMIZED)) { tmp_win->orig_x = x; tmp_win->orig_y = y; tmp_win->orig_wd = w; tmp_win->orig_ht = h; } /* make sure we stay on the screen -- used to be DontMoveOff */ if (x + scr->virt_x + w < 16) x = 16 - scr->virt_x - w; if (y + scr->virt_y + h < 16) y = 16 - scr->virt_y - h; if (x >= scr->d_width + scr->virt_x_max - scr->virt_x - 16) x = scr->d_width + scr->virt_x_max - scr->virt_x - 16; if (y >= scr->d_height + scr->virt_y_max - scr->virt_y - 16) y = scr->d_height + scr->virt_y_max - scr->virt_y - 16; /* * According to the July 27, 1988 ICCCM draft, we should send a * "synthetic" ConfigureNotify event to the client if the window * was moved but not resized. */ if ((x != tmp_win->frame_x || y != tmp_win->frame_y) && (w == tmp_win->frame_width && h == tmp_win->frame_height)) sendEvent = True; if ((w != tmp_win->frame_width) || (h != tmp_win->frame_height)) Resized = True; if (Resized) { if (tmp_win->menub != None && tmp_win->minimizeb != None && tmp_win->maximizeb != None) { tmp_win->title_width = w - 3 * tmp_win->title_height - 2 * tmp_win->boundary_width + tmp_win->bw; } else if ((tmp_win->menub != None && tmp_win->minimizeb != None) || (tmp_win->menub != None && tmp_win->maximizeb != None) || (tmp_win->menub != None && tmp_win->minimizeb != None)) { tmp_win->title_width = w - 2 * tmp_win->title_height - 2 * tmp_win->boundary_width + tmp_win->bw; } else if ((tmp_win->menub != None) || (tmp_win->minimizeb != None) || (tmp_win->maximizeb != None)) { tmp_win->title_width = w - 1 * tmp_win->title_height - 2 * tmp_win->boundary_width + tmp_win->bw; } else { tmp_win->title_width = w - 2 * tmp_win->boundary_width + tmp_win->bw; } if (tmp_win->title_width < 1) tmp_win->title_width = 1; if (tmp_win->decorations & MWM_DECOR_TITLE) { xwcm = CWWidth | CWX | CWY; if (tmp_win->menub != None) tmp_win->title_x = tmp_win->boundary_width + (1) * tmp_win->title_height; else tmp_win->title_x = tmp_win->boundary_width; if (tmp_win->title_x >= w - tmp_win->boundary_width) tmp_win->title_x = -10; tmp_win->title_y = tmp_win->boundary_width; xwc.width = tmp_win->title_width; xwc.x = tmp_win->title_x; xwc.y = tmp_win->title_y; XConfigureWindow(dpy, tmp_win->title, xwcm, &xwc); } if (tmp_win->decorations & MWM_DECOR_MENU) { xwcm = CWX | CWY; xwc.x = tmp_win->boundary_width; xwc.y = tmp_win->boundary_width; if (tmp_win->menub != None) { if (xwc.x + tmp_win->title_height < w - tmp_win->boundary_width) XConfigureWindow(dpy, tmp_win->menub, xwcm, &xwc); else { xwc.x = -tmp_win->title_height; XConfigureWindow(dpy, tmp_win->menub, xwcm, &xwc); } xwc.x += tmp_win->title_height; } } /* Note that we set X here. That's because MINIMIZE will use what's * computed by maximize (if it's around) to adjust it's right margin */ xwc.x = w - tmp_win->boundary_width + tmp_win->bw; if (tmp_win->decorations & MWM_DECOR_MAXIMIZE) { xwcm = CWX | CWY; xwc.y = tmp_win->boundary_width; if (tmp_win->maximizeb != None) { xwc.x -= tmp_win->title_height; if (xwc.x > tmp_win->boundary_width) XConfigureWindow(dpy, tmp_win->maximizeb, xwcm, &xwc); else { xwc.x = -tmp_win->title_height; XConfigureWindow(dpy, tmp_win->maximizeb, xwcm, &xwc); } } } if (tmp_win->decorations & MWM_DECOR_MINIMIZE) { xwcm = CWX | CWY; /* note that X doesn't appear here. See comment in paragraph * above */ xwc.y = tmp_win->boundary_width; if (tmp_win->minimizeb != None) { xwc.x -= tmp_win->title_height; if (xwc.x > tmp_win->boundary_width) XConfigureWindow(dpy, tmp_win->minimizeb, xwcm, &xwc); else { xwc.x = -tmp_win->title_height; XConfigureWindow(dpy, tmp_win->minimizeb, xwcm, &xwc); } } } if (tmp_win->decorations & MWM_DECOR_BORDER) { xwcm = CWWidth | CWHeight | CWX | CWY; xwidth = w - 2 * tmp_win->corner_width + tmp_win->bw; ywidth = h - 2 * tmp_win->corner_width; if (xwidth < 2) xwidth = 2; if (ywidth < 2) ywidth = 2; for (i = 0; i < 4; i++) { if (i == 0) { xwc.x = tmp_win->corner_width; xwc.y = 0; xwc.height = tmp_win->boundary_width; xwc.width = xwidth; } else if (i == 1) { xwc.x = w - tmp_win->boundary_width + tmp_win->bw; xwc.y = tmp_win->corner_width; xwc.width = tmp_win->boundary_width; xwc.height = ywidth; } else if (i == 2) { xwc.x = tmp_win->corner_width; xwc.y = h - tmp_win->boundary_width + tmp_win->bw; xwc.height = tmp_win->boundary_width + tmp_win->bw; xwc.width = xwidth; } else { xwc.x = 0; xwc.y = tmp_win->corner_width; xwc.width = tmp_win->boundary_width; xwc.height = ywidth; } XConfigureWindow(dpy, tmp_win->sides[i], xwcm, &xwc); } } if (tmp_win->decorations & MWM_DECOR_RESIZEH) { xwcm = CWX | CWY; for (i = 0; i < 4; i++) { if (i % 2) xwc.x = w - tmp_win->corner_width + tmp_win->bw; else xwc.x = 0; if (i / 2) xwc.y = h - tmp_win->corner_width; else xwc.y = 0; XConfigureWindow(dpy, tmp_win->corners[i], xwcm, &xwc); } } } tmp_win->attr.width = w - 2 * tmp_win->boundary_width - 2 * tmp_win->matte_width; tmp_win->attr.height = h - tmp_win->title_height - 2 * tmp_win->boundary_width - 2 * tmp_win->matte_width; /* may need to omit the -1 for shaped windows, next two lines */ cx = tmp_win->boundary_width - tmp_win->bw; cy = tmp_win->title_height + tmp_win->boundary_width - tmp_win->bw; XMoveResizeWindow(dpy, tmp_win->w, tmp_win->matte_width, tmp_win->matte_width, tmp_win->attr.width, tmp_win->attr.height); XMoveResizeWindow(dpy, tmp_win->parent, cx, cy, tmp_win->attr.width + 2 * tmp_win->matte_width, tmp_win->attr.height + 2 * tmp_win->matte_width); XMoveResizeWindow(dpy, tmp_win->shield, cx, cy, tmp_win->attr.width + 2 * tmp_win->matte_width, tmp_win->attr.height + 2 * tmp_win->matte_width); /* * fix up frame and assign size/location values in tmp_win */ frame_wc.x = tmp_win->frame_x = x; frame_wc.y = tmp_win->frame_y = y; frame_wc.width = tmp_win->frame_width = w; frame_wc.height = tmp_win->frame_height = h; frame_mask = (CWX | CWY | CWWidth | CWHeight); XConfigureWindow(dpy, tmp_win->frame, frame_mask, &frame_wc); if ((Resized) && (tmp_win->wShaped)) { DEC_SetShape(tmp_win, w); } XSync(dpy, 0); if (sendEvent) { client_event.type = ConfigureNotify; client_event.xconfigure.display = dpy; client_event.xconfigure.event = tmp_win->w; client_event.xconfigure.window = tmp_win->w; client_event.xconfigure.x = x + tmp_win->boundary_width + tmp_win->matte_width; client_event.xconfigure.y = y + tmp_win->title_height + tmp_win->boundary_width + tmp_win->matte_width; client_event.xconfigure.width = w - 2 * tmp_win->boundary_width - 2 * tmp_win->matte_width; client_event.xconfigure.height = h - tmp_win->title_height - 2 * tmp_win->boundary_width - 2 * tmp_win->matte_width; client_event.xconfigure.border_width = tmp_win->bw; /* Real ConfigureNotify events say we're above title window, so ... */ /* what if we don't have a title ????? */ client_event.xconfigure.above = tmp_win->frame; client_event.xconfigure.override_redirect = False; XSendEvent(dpy, tmp_win->w, False, StructureNotifyMask, &client_event); } if (tmp_win == scr->mwm_pager) { PAGER_UpdateViewPort(scr); for (t = scr->mwm_root.next; t != NULL; t = t->next) { PAGER_UpdateView(scr, t); } } else PAGER_UpdateView(scr, tmp_win);}/* * draws the title bar */voidDEC_DrawTitleBar(ScreenInfo *scr, MwmWindow *t, Bool onoroff, Bool NewTitle){ int hor_off, w; GC ReliefGC, ShadowGC; Pixel Forecolor, BackColor; if (!t) return; if (!(t->decorations & MWM_DECOR_TITLE)) return; if (onoroff) { Forecolor = scr->components[MWM_TITLE_A].active_foreground; BackColor = scr->components[MWM_TITLE_A].active_background; ReliefGC = scr->pressed_win == t->title ? scr->components[MWM_TITLE_A].active_bot_GC : scr->components[MWM_TITLE_A].active_top_GC; ShadowGC = scr->pressed_win == t->title ? scr->components[MWM_TITLE_A].active_top_GC : scr->components[MWM_TITLE_A].active_bot_GC; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -