?? windows.c
字號:
PAGER_Clear(scr); PAN_Raise(scr);}/* * lower a window */voidWIN_Lower(ScreenInfo *scr, MwmWindow *t){ if (t->child) lower_children(t->child); XLowerWindow(dpy, t->frame); MISC_SetTimer(0); if ((scr->pager_win) && !(t->flags & STICKY)) XLowerWindow(dpy, t->pager_view); if ((t->flags & ICONIFIED)) { XLowerWindow(dpy, t->icon_w); XLowerWindow(dpy, t->icon_pixmap_w); } scr->mwm_last_raised = (MwmWindow *)0; if (scr->pager_child_win) XLowerWindow(dpy, scr->pager_child_win); PAGER_Clear(scr);}/* * adjust the given width and height to account for the constraints imposed * by size hints * The general algorithm, especially the aspect ratio stuff, is borrowed from * uwm's CheckConsistency routine. */voidWIN_ConstrainWindow(ScreenInfo *scr, MwmWindow *tmp_win, int *widthp, int *heightp){ int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta; int baseWidth, baseHeight; int dwidth = *widthp, dheight = *heightp; dwidth -= (2 * tmp_win->boundary_width + 2 * tmp_win->matte_width); dheight -= (tmp_win->title_height + 2 * tmp_win->boundary_width + 2 * tmp_win->matte_width); minWidth = tmp_win->hints.min_width; minHeight = tmp_win->hints.min_height; baseWidth = tmp_win->hints.base_width; baseHeight = tmp_win->hints.base_height; maxWidth = tmp_win->hints.max_width; maxHeight = tmp_win->hints.max_height;/* maxWidth = scr->virt_x_max + scr->d_width; maxHeight = scr->virt_y_max + scr->d_height; */ xinc = tmp_win->hints.width_inc; yinc = tmp_win->hints.height_inc; /* * First, clamp to min and max values */ if (dwidth < minWidth) dwidth = minWidth; if (dheight < minHeight) dheight = minHeight; if (dwidth > maxWidth) dwidth = maxWidth; if (dheight > maxHeight) dheight = maxHeight; /* * Second, fit to base + N * inc */ dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth; dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight; /* * Third, adjust for aspect ratio * The math looks like this: * * minAspectX dwidth maxAspectX * ---------- <= ------- <= ---------- * minAspectY dheight maxAspectY * * If that is multiplied out, then the width and height are * invalid in the following situations: * * minAspectX * dheight > minAspectY * dwidth * maxAspectX * dheight < maxAspectY * dwidth * */ if (tmp_win->hints.flags & PAspect) { if (MinAspectX(tmp_win) * dheight > MinAspectY(tmp_win) * dwidth) { delta = makemult(MinAspectX(tmp_win) * dheight / MinAspectY(tmp_win) - dwidth, xinc); if (dwidth + delta <= maxWidth) dwidth += delta; else { delta = makemult(dheight - dwidth * MinAspectY(tmp_win) / MinAspectX(tmp_win), yinc); if (dheight - delta >= minHeight) dheight -= delta; } } if (MaxAspectX(tmp_win) * dheight < MaxAspectY(tmp_win) * dwidth) { delta = makemult(dwidth * MaxAspectY(tmp_win) / MaxAspectX(tmp_win) - dheight, yinc); if (dheight + delta <= maxHeight) dheight += delta; else { delta = makemult(dwidth - MaxAspectX(tmp_win) * dheight / MaxAspectY(tmp_win), xinc); if (dwidth - delta >= minWidth) dwidth -= delta; } } } /* * Fourth, account for border width and title height */ *widthp = dwidth + 2 * tmp_win->boundary_width + 2 * tmp_win->matte_width; *heightp = dheight + tmp_win->title_height + 2 * tmp_win->boundary_width + 2 * tmp_win->matte_width;}/* * move/draw a window outline */voidWIN_DrawOutline(ScreenInfo *scr, Window root, int x, int y, int width, int height){ static int lastx = 0; static int lasty = 0; static int lastWidth = 0; static int lastHeight = 0; XRectangle rects[5]; if (x == lastx && y == lasty && width == lastWidth && height == lastHeight) return; /* undraw the old one, if any */ if (lastWidth || lastHeight) { rects[0].x = lastx; rects[0].y = lasty; rects[0].width = lastWidth; rects[0].height = lastHeight; rects[1].x = lastx + 1; rects[1].y = lasty + 1; rects[1].width = lastWidth - 2; rects[1].height = lastHeight - 2; rects[2].x = lastx + 2; rects[2].y = lasty + 2; rects[2].width = lastWidth - 4; rects[2].height = lastHeight - 4; rects[3].x = lastx + 3; rects[3].y = lasty + 3 + (lastHeight - 6) / 3; rects[3].width = lastWidth - 6; rects[3].height = (lastHeight - 6) / 3; rects[4].x = lastx + 3 + (lastWidth - 6) / 3; rects[4].y = lasty + 3; rects[4].width = (lastWidth - 6) / 3; rects[4].height = (lastHeight - 6); XDrawRectangles(dpy, scr->root_win, scr->resize_GC, rects, 5); } lastx = x; lasty = y; lastWidth = width; lastHeight = height; /* draw the new one, if any */ if (lastWidth || lastHeight) { rects[0].x = lastx; rects[0].y = lasty; rects[0].width = lastWidth; rects[0].height = lastHeight; rects[1].x = lastx + 1; rects[1].y = lasty + 1; rects[1].width = lastWidth - 2; rects[1].height = lastHeight - 2; rects[2].x = lastx + 2; rects[2].y = lasty + 2; rects[2].width = lastWidth - 4; rects[2].height = lastHeight - 4; rects[3].x = lastx + 3; rects[3].y = lasty + 3 + (lastHeight - 6) / 3; rects[3].width = lastWidth - 6; rects[3].height = (lastHeight - 6) / 3; rects[4].x = lastx + 3 + (lastWidth - 6) / 3; rects[4].y = lasty + 3; rects[4].width = (lastWidth - 6) / 3; rects[4].height = (lastHeight - 6); XDrawRectangles(dpy, scr->root_win, scr->resize_GC, rects, 5); }}/* * Releases dynamically allocated space used to store window/icon names */voidWIN_FreeNames(MwmWindow *tmp, Bool nukename, Bool nukeicon){ if (!tmp) return; if (nukename && nukeicon) { if (tmp->name == tmp->icon_active_label) { if (tmp->name != NoName) XFree(tmp->name); tmp->name = NULL; tmp->icon_active_label = NULL; } else { if (tmp->name != NoName) XFree(tmp->name); tmp->name = NULL; if (tmp->icon_active_label != NoName) XFree(tmp->icon_active_label); tmp->icon_active_label = NULL; } } else if (nukename) { if (tmp->name != tmp->icon_active_label && tmp->name != NoName) XFree(tmp->name); tmp->name = NULL; } else { /* if (nukeicon) */ if (tmp->icon_active_label != tmp->name && tmp->icon_active_label != NoName) XFree(tmp->icon_active_label); tmp->icon_active_label = NULL; }}/* * map a window */voidWIN_MapWindow(ScreenInfo *scr, Window win){ MwmWindow *tmp; if (XFindContext(dpy, win, MwmContext, (XPointer *)&tmp) == XCNOENT) tmp = NULL; XFlush(dpy); /* If the window has never been mapped before ... */ if (!tmp) { /* Add decorations. */ tmp = add_window(scr, win); if (tmp == NULL) return; } /* If it's not merely iconified, and we have hints, use them. */ if (!(tmp->flags & ICONIFIED)) { int state; if (tmp->wmhints && (tmp->wmhints->flags & StateHint)) state = tmp->wmhints->initial_state; else state = NormalState; if (tmp->flags & STARTICONIC) state = IconicState; if (isIconicState != DontCareState) state = isIconicState; XGrabServer(dpy); switch (state) { case DontCareState: case NormalState: case InactiveState: default: if (tmp->Desk == scr->current_desk) { XMapWindow(dpy, tmp->w); XMapWindow(dpy, tmp->frame); tmp->flags |= MAP_PENDING; PROP_SetState(tmp, NormalState); if (Mwm.keyboard_focus_policy == XmEXPLICIT && Mwm.startup_key_focus) { WIN_SetFocusInTree(tmp); WIN_SetFocus(scr, tmp->w, tmp); MISC_SetFocusSequence(scr); } } else { XMapWindow(dpy, tmp->w); PROP_SetState(tmp, NormalState); } break; case IconicState: ICON_Iconify(scr, tmp, 0, 0); break; } XSync(dpy, 0); XUngrabServer(dpy); } /* If no hints, or currently an icon, just "deiconify" */ else ICON_DeIconify(scr, tmp);}/* * Handles destruction of a window */voidWIN_DestroyWindow(ScreenInfo *scr, MwmWindow *tmp){ int i; /* * Warning, this is also called by HandleUnmapNotify; if it ever needs to * look at the event, HandleUnmapNotify will have to mash the UnmapNotify * into a DestroyNotify. */ if (!tmp) return; MISC_DestroyChildren(scr, tmp); MENU_DestroyWindowMenu(scr, tmp); XUnmapWindow(dpy, tmp->frame); XSync(dpy, 0); if (tmp == scr->mwm_highlight) { scr->mwm_highlight = NULL; } if (scr->mwm_last_focus == tmp) { scr->mwm_last_focus = NULL; } if (scr->mwm_event == tmp) { scr->mwm_event = NULL; } if (tmp == scr->mwm_focus && Mwm.keyboard_focus_policy == XmEXPLICIT && Mwm.auto_key_focus) { if (tmp->next != NULL) { WIN_SetFocusInTree(tmp->next); WIN_SetFocus(scr, tmp->next->w, tmp->next); } else if (tmp->ancestor) { WIN_SetFocusInTree(tmp->ancestor); WIN_SetFocus(scr, tmp->ancestor->w, tmp->ancestor); } else { WIN_SetFocus(scr, scr->no_focus_win, NULL); } } MISC_RemoveFromTree(scr, tmp); if (scr->mwm_focus == tmp) { WIN_SetFocus(scr, scr->no_focus_win, NULL); } MISC_SetFocusSequence(scr); if (tmp == scr->mwm_pushed) scr->mwm_pushed = NULL; if (tmp == scr->mwm_colormap) scr->mwm_colormap = NULL; XDestroyWindow(dpy, tmp->frame); XDeleteContext(dpy, tmp->frame, MwmContext); XDestroyWindow(dpy, tmp->parent); XDeleteContext(dpy, tmp->parent, MwmContext); XDeleteContext(dpy, tmp->w, MwmContext); if ((tmp->icon_w) && (tmp->flags & PIXMAP_OURS)) XFreePixmap(dpy, tmp->icon_pixmap); if ((scr->pager_win) && !(tmp->flags & STICKY)) XDestroyWindow(dpy, tmp->pager_view); if (tmp->icon_w) { XDestroyWindow(dpy, tmp->icon_w); XDeleteContext(dpy, tmp->icon_w, MwmContext); } if ((tmp->flags & ICON_OURS) && (tmp->icon_pixmap_w != None)) XDestroyWindow(dpy, tmp->icon_pixmap_w); if (tmp->icon_pixmap_w != None) XDeleteContext(dpy, tmp->icon_pixmap_w, MwmContext); for (i = 0; i < 4; i++) { if (tmp->icon_borders[i] != None) { XDestroyWindow(dpy, tmp->icon_borders[i]); XDeleteContext(dpy, tmp->icon_borders[i], MwmContext); } } if (tmp->decorations & MWM_DECOR_TITLE) { XDeleteContext(dpy, tmp->title, MwmContext); if (tmp->menub != None) XDeleteContext(dpy, tmp->menub, MwmContext); if (tmp->menub != None) XDeleteContext(dpy, tmp->menub, MwmContext); } if (tmp->decorations & MWM_DECOR_BORDER) { for (i = 0; i < 4; i++) XDeleteContext(dpy, tmp->sides[i], MwmContext); } if (tmp->decorations & MWM_DECOR_RESIZEH) { for (i = 0; i < 4; i++) XDeleteContext(dpy, tmp->corners[i], MwmContext); } WIN_FreeNames(tmp, True, True); if (tmp->wmhints) XFree((char *)tmp->wmhints); if (tmp->classhint.res_name && tmp->classhint.res_name != NoName) XFree((char *)tmp->classhint.res_name); if (tmp->classhint.res_class && tmp->classhint.res_class != NoName) XFree((char *)tmp->classhint.res_class); if (tmp->mwm_hints) XFree((char *)tmp->mwm_hints); if (tmp->mwm_menu) XFree((char *)tmp->mwm_menu); if (tmp->mwm_messages) XFree((char *)tmp->mwm_messages); if (tmp->cmap_windows != (Window *)NULL) XFree((void *)tmp->cmap_windows); XtFree((char *)tmp); PAGER_Clear(scr); XSync(dpy, 0);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -