📄 decorate.c
字号:
{ t->functions = t->mwm_hints->functions; /* * functions affect the decorations! if the user says no iconify * function, then the iconify button doesn't show up. So do functions * first. */ 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 (t->flags & TRANSIENT) t->functions &= scr->transient_functions; else t->functions &= t->client_functions; } else if (t->flags & TRANSIENT) t->functions = scr->transient_functions; else t->functions = t->client_functions; if (t->mwm_hints && (t->mwm_hints->flags & MWM_HINTS_DECORATIONS)) { t->decorations = t->mwm_hints->decorations; /* * next, figure out the decorations */ if (t->decorations & MWM_DECOR_ALL) { /* If we get ALL + some other things, that means to use ALL except * the other things... */ t->decorations &= ~MWM_DECOR_ALL; t->decorations = (MWM_DECOR_BORDER | MWM_DECOR_RESIZEH | MWM_DECOR_TITLE | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE) & (~t->decorations); } if (t->flags & TRANSIENT) t->decorations &= scr->transient_decoration; else t->decorations &= t->client_decoration; } else if (t->flags & TRANSIENT) t->decorations = scr->transient_decoration; else t->decorations = t->client_decoration; /* * 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)) t->decorations &= ~MWM_DECOR_RESIZEH; /* MWM_FUNC_MOVE has no impact on decorations. */ if (!(t->functions & MWM_FUNC_MINIMIZE)) t->decorations &= ~MWM_DECOR_MINIMIZE; if (!(t->functions & MWM_FUNC_MAXIMIZE)) t->decorations &= ~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 (t->decorations & (MWM_DECOR_MENU | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE)) t->decorations |= MWM_DECOR_TITLE; if (t->decorations & (MWM_DECOR_TITLE | MWM_DECOR_RESIZEH)) t->decorations |= MWM_DECOR_BORDER; if (t->wShaped) t->decorations &= ~(MWM_DECOR_BORDER | MWM_DECOR_RESIZEH); /* * Assume no decorations, and build up */ t->boundary_width = 0; t->corner_width = 0; t->title_height = 0; valuemask = CWBorderPixel | CWCursor | CWEventMask | CWSaveUnder | CWBackingStore; attributes.backing_store = WhenMapped; 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; } attributes.event_mask = (ButtonPressMask | ButtonReleaseMask | ExposureMask | EnterWindowMask | LeaveWindowMask); if (t->decorations & MWM_DECOR_BORDER) { /* A narrow border is displayed (5 pixels - 2 relief, 1 top, 2 * shadow) */ t->boundary_width = border_width; if (t->sides[0] == None) { for (i = 0; i < 4; i++) { if (scr->resize_cursors) attributes.cursor = scr->cursors[TOP_CURS + i]; else attributes.cursor = scr->cursors[DEFAULT_CURS]; attributes.save_under = scr->components[MWM_BORDER].save_under; t->sides[i] = XCreateWindow(dpy, t->frame, 0, 0, t->boundary_width, t->boundary_width, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); XSaveContext(dpy, t->sides[i], MwmContext, (XPointer)t); } } for (i = 0; i < 4; i++) XRaiseWindow(dpy, t->sides[i]); } else if (t->sides[0] != None) { for (i = 0; i < 4; i++) { XDeleteContext(dpy, t->sides[i], MwmContext); XDestroyWindow(dpy, t->sides[i]); t->sides[i] = None; } } if (scr->components[MWM_RESIZE_H].background_pixmap != XmUNSPECIFIED_PIXMAP) { attributes.background_pixmap = scr->components[MWM_RESIZE_H].background_pixmap; valuemask &= ~CWBackPixel; valuemask |= CWBackPixmap; } else { attributes.background_pixel = scr->components[MWM_RESIZE_H].background; valuemask &= ~CWBackPixmap; valuemask |= CWBackPixel; } if (t->decorations & MWM_DECOR_RESIZEH) { /* A wide border, with corner tiles is desplayed (10 pixels - 2 * relief, 2 shadow) */ t->boundary_width = resize_width; t->corner_width = scr->components[MWM_TITLE_A].f_height + 3 + t->boundary_width; if (t->corners[0] == None) { attributes.event_mask = (ButtonPressMask | ButtonReleaseMask | ExposureMask | EnterWindowMask | LeaveWindowMask); /* * Just dump the windows any old place and let * DEC_ConfigureDecorations take care of the mess */ for (i = 0; i < 4; i++) { if (scr->resize_cursors) attributes.cursor = scr->cursors[TOP_LEFT_CURS + i]; else attributes.cursor = scr->cursors[DEFAULT_CURS]; attributes.save_under = scr->components[MWM_RESIZE_H].save_under; t->corners[i] = XCreateWindow(dpy, t->frame, 0, 0, t->corner_width, t->corner_width, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); XSaveContext(dpy, t->corners[i], MwmContext, (XPointer)t); } } for (i = 0; i < 4; i++) XRaiseWindow(dpy, t->corners[i]); } else if (t->corners[0] != None) { for (i = 0; i < 4; i++) { XDestroyWindow(dpy, t->corners[i]); XDeleteContext(dpy, t->corners[i], MwmContext); t->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 (t->decorations & MWM_DECOR_TITLE) { /* A title barm with no buttons in it - window gets a 1 pixel wide * black border. */ t->title_height = scr->components[MWM_TITLE_A].f_height + 3; if (t->title_height > 0) t->title_height += t->bw; t->title_x = t->title_y = 0; t->title_width = t->frame_width - 2 * t->corner_width - 3 + t->bw; if (t->title_width < 1) t->title_width = 1; if (t->title == None) { attributes.cursor = scr->cursors[TITLE_CURS]; attributes.save_under = scr->components[MWM_TITLE_A].save_under; t->title = XCreateWindow(dpy, t->frame, t->title_x, t->title_y, t->title_width, t->title_height, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); XSaveContext(dpy, t->title, MwmContext, (XPointer)t); } XRaiseWindow(dpy, t->title); } else if (t->title != None) { XDeleteContext(dpy, t->title, MwmContext); XDestroyWindow(dpy, t->title); t->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 (t->decorations & MWM_DECOR_MENU) { /* title-bar menu button window gets 1 pixel wide black border */ if (t->menub == None) { attributes.save_under = scr->components[MWM_MENU_B].save_under; t->menub = XCreateWindow(dpy, t->frame, t->title_height, 0, t->title_height, t->title_height, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); XSaveContext(dpy, t->menub, MwmContext, (XPointer)t); } XRaiseWindow(dpy, t->menub); } else if (t->menub != None) { XDeleteContext(dpy, t->menub, MwmContext); XDestroyWindow(dpy, t->menub); t->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 (t->decorations & MWM_DECOR_MINIMIZE) { /* title-bar + iconify button, no menu button. window gets 1 pixel * wide black border */ if (t->minimizeb == None) { attributes.save_under = scr->components[MWM_MINIMIZE_B].save_under; t->minimizeb = XCreateWindow(dpy, t->frame, t->title_width - t->title_height * 2, 0, t->title_height, t->title_height, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); XSaveContext(dpy, t->minimizeb, MwmContext, (XPointer)t); } XRaiseWindow(dpy, t->minimizeb); } else if (t->minimizeb != None) { XDeleteContext(dpy, t->minimizeb, MwmContext); XDestroyWindow(dpy, t->minimizeb); t->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 (t->decorations & MWM_DECOR_MAXIMIZE) { /* title-bar + maximize button, no menu button, no iconify. * window * has 1 pixel wide black border */ if (t->maximizeb == None) { attributes.save_under = scr->components[MWM_MINIMIZE_B].save_under; t->maximizeb = XCreateWindow(dpy, t->frame, t->title_width - t->title_height * 1, 0, t->title_height, t->title_height, 0, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); XSaveContext(dpy, t->maximizeb, MwmContext, (XPointer)t); } XRaiseWindow(dpy, t->maximizeb); } else if (t->maximizeb != None) { XDeleteContext(dpy, t->maximizeb, MwmContext); XDestroyWindow(dpy, t->maximizeb); t->maximizeb = None; } XMapSubwindows(dpy, t->frame); XLowerWindow(dpy, t->shield); XRaiseWindow(dpy, t->parent); t->bw = 0;}/* * create the decoration windows */voidDEC_CreateDecorations(ScreenInfo *scr, MwmWindow *tmp_win){ unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ int i; /* * create windows */ tmp_win->frame_x = tmp_win->attr.x + tmp_win->old_bw - tmp_win->bw; tmp_win->frame_y = tmp_win->attr.y + tmp_win->old_bw - tmp_win->bw; tmp_win->frame_width = tmp_win->attr.width + 2 * tmp_win->boundary_width + 2 * tmp_win->matte_width; tmp_win->frame_height = tmp_win->attr.height + tmp_win->title_height + 2 * tmp_win->matte_width + 2 * tmp_win->boundary_width; valuemask = CWBorderPixel | CWCursor | CWEventMask; 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; } attributes.border_pixel = scr->components[MWM_BORDER].bottom_shadow_color; attributes.cursor = scr->cursors[DEFAULT_CURS]; attributes.event_mask = (SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | ExposureMask); valuemask |= CWSaveUnder; attributes.save_under = True; /* What the heck, we'll always reparent everything from now on! */ tmp_win->frame = XCreateWindow(dpy, scr->root_win, tmp_win->frame_x, tmp_win->frame_y, tmp_win->frame_width, tmp_win->frame_height, tmp_win->bw, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); attributes.save_under = False; /* Thats not all, we'll double-reparent the window ! */ attributes.cursor = scr->cursors[DEFAULT_CURS]; attributes.background_pixel = tmp_win->matte_background; valuemask &= ~CWBackPixmap; valuemask |= CWBackPixel; tmp_win->parent = XCreateWindow(dpy, tmp_win->frame, tmp_win->boundary_width, tmp_win->boundary_width + tmp_win->title_height, (tmp_win->frame_width - 2 * tmp_win->boundary_width), (tmp_win->frame_height - 2 * tmp_win->boundary_width - tmp_win->title_height), tmp_win->bw, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); attributes.cursor = scr->cursors[SYS_MODAL_CURS]; attributes.override_redirect = True; attributes.event_mask = ButtonPressMask | ButtonPressMask; tmp_win->shield = XCreateWindow(dpy, tmp_win->frame, tmp_win->boundary_width, tmp_win->boundary_width + tmp_win->title_height, (tmp_win->frame_width - 2 * tmp_win->boundary_width), (tmp_win->frame_height - 2 * tmp_win->boundary_width - tmp_win->title_height), tmp_win->bw, 0, InputOnly, CopyFromParent, CWEventMask | CWCursor | CWOverrideRedirect, &attributes); valuemask |= CWBackingStore; attributes.backing_store = WhenMapped; attributes.event_mask = (SubstructureRedirectMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | ExposureMask); attributes.cursor = scr->cursors[DEFAULT_CURS]; if (scr->pager_win) { if (scr->components[MWM_PAGER].background_pixmap != XmUNSPECIFIED_PIXMAP) { attributes.background_pixmap = scr->components[MWM_PAGER].background_pixmap; valuemask |= CWBackPixmap; } else { attributes.background_pixel = scr->components[MWM_PAGER].background; valuemask |= CWBackPixel; } /* Create the pager_view window even if we're sticky, in case the * user unsticks the window */ attributes.event_mask = ExposureMask; tmp_win->pager_view = XCreateWindow(dpy, scr->pager_win, -10, -10, 2, 2, 1, CopyFromParent, InputOutput, CopyFromParent, valuemask, &attributes); XMapRaised(dpy, tmp_win->pager_view); } attributes.event_mask = (ButtonPressMask | ButtonReleaseMask | ExposureMask | EnterWindowMask | LeaveWindowMask); tmp_win->title_x = tmp_win->title_y = 0; tmp_win->title_width = tmp_win->frame_width - 2 * tmp_win->corner_width - 3 + tmp_win->bw; if (tmp_win->title_width < 1) tmp_win->title_width = 1; if (scr->components[MWM_RESIZE_H].background_pixmap != XmUNSPECIFIED_PIXMAP) { attributes.background_pixmap = scr->components[MWM_RESIZE_H].background_pixmap; valuemask &= ~CWBackPixel; valuemask |= CWBackPixmap; } else { attributes.background_pixel = scr->components[MWM_RESIZE_H].background; valuemask &= ~CWBackPixmap; valuemask |= CWBackPixel; } if (tmp_win->decorations & MWM_DECOR_RESIZEH)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -