📄 screens.c
字号:
else { gcm = GCForeground | GCBackground; gcv.foreground = scr->components[MWM_MENU_B].active_top_shadow_color; gcv.background = scr->components[MWM_MENU_B].active_background; } gcm |= GCLineWidth | GCLineStyle | GCCapStyle | GCGraphicsExposures; gcv.line_width = 0; gcv.line_style = LineSolid; gcv.cap_style = CapButt; gcv.graphics_exposures = False; scr->components[MWM_MENU_B].active_top_GC = XCreateGC(dpy, scr->root_win, gcm, &gcv); if (scr->components[MWM_MENU_B].active_bottom_shadow_pixmap != None && scr->components[MWM_MENU_B].active_bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP) { gcm = GCTile | GCFillStyle; gcv.tile = scr->components[MWM_MENU_B].active_bottom_shadow_pixmap; gcv.fill_style = FillTiled; } else { gcm = GCForeground | GCBackground; gcv.foreground = scr->components[MWM_MENU_B].active_bottom_shadow_color; gcv.background = scr->components[MWM_MENU_B].active_background; } gcm |= GCLineWidth | GCLineStyle | GCCapStyle | GCGraphicsExposures; gcv.line_width = 0; gcv.line_style = LineSolid; gcv.cap_style = CapButt; gcv.graphics_exposures = False; scr->components[MWM_MENU_B].active_bot_GC = XCreateGC(dpy, scr->root_win, gcm, &gcv);}/* * open fonts and create all the needed GC's * */static voidcreate_GCs(ScreenInfo *scr){ XGCValues gcv; unsigned long gcm; /* create the decoration GC's */ create_menu_gcs(scr); create_feedback_gcs(scr); create_pager_gcs(scr); create_icon_gcs(scr); create_title_gcs(scr); create_resize_h_gcs(scr); create_border_gcs(scr); create_maximize_gcs(scr); create_minimize_gcs(scr); create_menu_b_gcs(scr); /* create the resize GC */ gcm = GCFunction | GCLineWidth | GCForeground | GCSubwindowMode; gcv.function = GXxor; gcv.line_width = 0; gcv.foreground = (((unsigned long)1) << scr->d_depth) - 1; gcv.subwindow_mode = IncludeInferiors; scr->resize_GC = XCreateGC(dpy, scr->root_win, gcm, &gcv); /* create the matte top shadow GC */ gcm = GCLineWidth | GCLineStyle | GCCapStyle | GCGraphicsExposures; gcv.line_width = 0; gcv.line_style = LineSolid; gcv.cap_style = CapButt; gcv.graphics_exposures = False; scr->matte_ts_GC = XCreateGC(dpy, scr->root_win, gcm, &gcv); scr->matte_bs_GC = XCreateGC(dpy, scr->root_win, gcm, &gcv);}/* * Find out what the Alt key is. This code came from libXm/VirtKeys. */static intget_modifier_mapping(Display *Dsp){ XModifierKeymap *mk; KeySym ModifierKeysym; int ModifierSet, SetIndex, SetSize; int AltMask = Mod1Mask; /* * Ask the server for the current modifier mapping and parse it for * the META and ALT keysyms. If one of them is bound to a modifier, * then remember the mask of that modifier. */ mk = XGetModifierMapping(Dsp); SetSize = mk->max_keypermod; for (ModifierSet = 0; ModifierSet < 8; ModifierSet++) { for (SetIndex = 0; SetIndex < SetSize; SetIndex++) { ModifierKeysym = XKeycodeToKeysym(Dsp, mk->modifiermap[SetIndex + ModifierSet * SetSize], 0); switch (ModifierKeysym) { /* * If we've found one of the well known modifier keysyms, * we'll remember the modifier - but only if we havn't yet * seen another one. */ case XK_Meta_L: case XK_Meta_R: AltMask = 1L << ModifierSet; goto bailout; case XK_Alt_L: case XK_Alt_R: AltMask = 1L << ModifierSet; goto bailout; } } } bailout: /* * And don't forget to clean up, we don't want to waste memory here -- * because we're not the Closed Software Foundation! And then a last * paranoic checking for missing ALT modifiers... */ XFreeModifiermap(mk); return AltMask;}/* * initialize one screen. returns a boolean indicating whether or not the * DESKTOP property was found */BooleanSCREEN_Initialize(ScreenInfo *scr){ XSetWindowAttributes attributes; unsigned long valuemask; Boolean restart = False; int ssw; PROP_SetPriorityColors(scr); RES_GetScreenDefaults(scr); RES_GetComponentDefaults(scr); MWM_SetErrorHandler(REDIRECT); XSelectInput(dpy, scr->root_win, LeaveWindowMask | EnterWindowMask | PropertyChangeMask | SubstructureRedirectMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask); XSync(dpy, 0); MWM_SetErrorHandler(GENERAL); scr->d_width = DisplayWidth(dpy, scr->screen); scr->d_height = DisplayHeight(dpy, scr->screen); scr->d_depth = DefaultDepth(dpy, scr->screen); CURS_Initialize(scr); valuemask = CWCursor | CWDontPropagate; attributes.cursor = scr->cursors[HOURGLASS_CURS]; attributes.do_not_propagate_mask = -1; scr->mwm_root.w = scr->root_win; scr->mwm_root.next = NULL; XGetWindowAttributes(dpy, scr->root_win, &scr->mwm_root.attr); scr->root_pushes = 0; scr->mwm_pushed = &scr->mwm_root; scr->mwm_root.number_cmap_windows = 0; scr->event_context = C_NO_CONTEXT; /* current button press context */ scr->mwm_highlight = NULL; scr->mwm_focus = NULL; scr->mwm_grabbing = NULL; scr->virt_scale = 32; scr->virt_x = scr->virt_y = 0; restart = PROP_CheckDesktop(scr); scr->ScrollResistance = scr->MoveResistance = 250; scr->OpaqueSize = 5; /* set major operating modes */ scr->flags = 0; scr->num_icon_boxes = 1; scr->icon_boxes[0][0] = 0; scr->icon_boxes[0][1] = scr->d_height - 75; scr->icon_boxes[0][2] = scr->d_width; scr->icon_boxes[0][3] = scr->d_height; scr->buttons2grab = 7; scr->mwm_pager = NULL; scr->pager_win = None; scr->pager_child_win = None; scr->pressed_win = None; scr->restart_win = None; scr->quit_win = None; scr->toggle_win = None; /* initialize some lists */ scr->buttons = NULL; scr->keys = NULL; scr->DefaultIcon = NULL; scr->IconPath = Mwm.bitmap_directory; scr->PixmapPath = Mwm.bitmap_directory; /* create graphics contexts */ create_GCs(scr); XSync(dpy, 0); /* find our alt key */ scr->alt_mask = get_modifier_mapping(dpy); PARSE_mwmrc(scr); MENU_LinkUp(scr); MENU_RealizeMenus(scr); if (Mwm.edge_scroll_x == XmUNSPECIFIED) scr->edge_scroll_x = scr->d_width; else scr->edge_scroll_x = Mwm.edge_scroll_x; if (Mwm.edge_scroll_y == XmUNSPECIFIED) scr->edge_scroll_y = scr->d_height; else scr->edge_scroll_x = Mwm.edge_scroll_x; if (Mwm.pager_x == XmUNSPECIFIED) scr->pager_x = 0; else scr->pager_x = Mwm.pager_x; if (Mwm.pager_y == XmUNSPECIFIED) Mwm.pager_y = 0; else scr->pager_y = Mwm.pager_y; scr->virt_x_max = Mwm.virtual_x * scr->d_width - scr->d_width; scr->virt_y_max = Mwm.virtual_y * scr->d_height - scr->d_height; if (scr->virt_x_max < 0) scr->virt_x_max = 0; if (scr->virt_y_max < 0) scr->virt_y_max = 0; if (Mwm.use_pager) PAGER_Initialize(scr, scr->pager_x, scr->pager_y); scr->smart_placement = Mwm.smart_placement; XSync(dpy, 0); XGrabServer(dpy); attributes.event_mask = KeyPressMask | ButtonPressMask; attributes.cursor = scr->cursors[HOURGLASS_CURS]; attributes.override_redirect = True; scr->shield_win = XCreateWindow(dpy, scr->root_win, 0, 0, scr->d_width, scr->d_height, 0, 0, InputOnly, CopyFromParent, CWEventMask | CWOverrideRedirect | CWCursor, &attributes); XMapRaised(dpy, scr->shield_win); /* create a window which will accept the keyboard focus when no other windows have it */ attributes.event_mask = KeyPressMask | FocusChangeMask; attributes.override_redirect = True; scr->no_focus_win = XCreateWindow(dpy, scr->root_win, -10, -10, 10, 10, 0, 0, InputOnly, CopyFromParent, CWEventMask | CWOverrideRedirect, &attributes); XStoreName(dpy, scr->no_focus_win, "NoFocusWin"); XMapWindow(dpy, scr->no_focus_win); XSetInputFocus(dpy, scr->no_focus_win, RevertToParent, CurrentTime); XSync(dpy, 0); if (debugging) XSynchronize(dpy, 1); ssw = XTextWidth(scr->components[MWM_FEEDBACK].font, " +8888 x +8888 ", 15); attributes.border_pixel = scr->components[MWM_FEEDBACK].foreground; attributes.background_pixel = scr->components[MWM_FEEDBACK].background; attributes.bit_gravity = NorthWestGravity; valuemask = (CWBorderPixel | CWBackPixel | CWBitGravity); scr->size_win = XCreateWindow(dpy, scr->root_win, (scr->d_width - (ssw + SIZE_HINDENT * 2)) / 2, (scr->d_height - (scr->components[MWM_FEEDBACK].f_height + SIZE_VINDENT * 2)) / 2, (unsigned int)(ssw + SIZE_HINDENT * 2), (unsigned int)(scr->components[MWM_FEEDBACK].f_height + SIZE_VINDENT * 2), (unsigned int)0, 0, (unsigned int)CopyFromParent, (Visual *)CopyFromParent, valuemask, &attributes); PAN_Initialize(scr); WIN_CaptureWindows(scr); MISC_FixupTransients(scr); PAN_CheckBounds(scr); XUnmapWindow(dpy, scr->shield_win); XUngrabServer(dpy); PAGER_UpdateViewPort(scr); valuemask = CWCursor; attributes.cursor = scr->cursors[SYS_MODAL_CURS]; XChangeWindowAttributes(dpy, scr->shield_win, valuemask, &attributes); return restart;}/* * from an event, figure out the screen structure */ScreenInfo *SCREEN_EventToStruct(XEvent *event){ XAnyEvent *ev = (XAnyEvent *)event; int i; for (i = 0; i < Mwm.number_of_screens; i++) { if (ev->window == Mwm.screen_info[i]->root_win) return Mwm.screen_info[i]; } XGetGeometry(dpy, ev->window, &JunkRoot, &JunkX, &JunkY, &JunkWidth, &JunkHeight, &JunkBW, &JunkDepth); for (i = 0; i < Mwm.number_of_screens; i++) { if (JunkRoot == Mwm.screen_info[i]->root_win) return Mwm.screen_info[i]; } fprintf(stderr, "Event has no screen!\n"); return NULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -