📄 icons.c
字号:
{ XMoveResizeWindow(dpy, tmp->icon_w, tmp->icon_xl_loc, tmp->icon_y_loc + tmp->icon_p_height, tmp->icon_w_width, scr->components[MWM_ICON].f_height + 6); XClearWindow(dpy, tmp->icon_w); } if ((tmp->icon_pixmap != None) && (!(tmp->flags & SHAPED_ICON))) DEC_DrawShadows(tmp, tmp->icon_pixmap_w, 0, 0, tmp->icon_p_width, tmp->icon_p_height, Relief, Shadow); /* need to locate the icon pixmap */ if (tmp->icon_pixmap != None) { if (tmp->icon_depth == scr->d_depth) { XCopyArea(dpy, tmp->icon_pixmap, tmp->icon_pixmap_w, (scr->mwm_highlight == tmp) ? scr->components[MWM_ICON].active_GC : scr->components[MWM_ICON].normal_GC, 0, 0, tmp->icon_p_width - 4, tmp->icon_p_height - 4, 2, 2); } else XCopyPlane(dpy, tmp->icon_pixmap, tmp->icon_pixmap_w, (scr->mwm_highlight == tmp) ? scr->components[MWM_ICON].active_GC : scr->components[MWM_ICON].normal_GC, 0, 0, tmp->icon_p_width - 4, tmp->icon_p_height - 4, 2, 2, 1); } if (tmp->icon_w != None) { char *label; 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 = ""; /* text position */ x = (tmp->icon_w_width - tmp->icon_t_width) / 2; if (x < 3) x = 3; XDrawString(dpy, tmp->icon_w, (scr->mwm_highlight == tmp) ? scr->components[MWM_ICON].active_GC : scr->components[MWM_ICON].normal_GC, x, tmp->icon_w_height - scr->components[MWM_ICON].f_height + scr->components[MWM_ICON].f_y - 3, label, strlen(label)); DEC_DrawShadows(tmp, tmp->icon_w, 0, 0, tmp->icon_w_width, scr->components[MWM_ICON].f_height + 6, Relief, Shadow); }}/* * procedure to re-position the icon window and name */voidICON_UpdateWindow(ScreenInfo *scr, MwmWindow *tmp, Boolean force){ char *label; if (scr->components[MWM_PAGER].f_height > 0) { XClearWindow(dpy, tmp->pager_view); PAGER_Clear(scr); } if (tmp->icon_w == None && tmp->icon_pixmap_w == None) return; if ((force || (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)); /* clear the icon window, and trigger a re-draw via an expose event */ if (tmp->flags & ICONIFIED) XClearArea(dpy, tmp->icon_w, 0, 0, 0, 0, True);}/* * Find a home for an icon */voidICON_AutoPlace(ScreenInfo *scr, MwmWindow *t){ int test_x = 0, test_y = 0, tw, th, tx, ty, i, temp_h, temp_w; int base_x, base_y; int width, height; MwmWindow *test_window; Bool loc_ok; int real_x = 10, real_y = 10; /* New! Put icon in same page as the center of the window */ if ((t->flags & STICKY)) { base_x = 0; base_y = 0; } else { base_x = ((t->frame_x + scr->virt_x + (t->frame_width >> 1)) / scr->d_width) * scr->d_width - scr->virt_x; base_y = ((t->frame_y + scr->virt_y + (t->frame_height >> 1)) / scr->d_height) * scr->d_height - scr->virt_y; } if (t->flags & ICON_MOVED) { /* just make sure the icon is on this screen */ t->icon_x_loc = t->icon_x_loc % scr->d_width + base_x; t->icon_y_loc = t->icon_y_loc % scr->d_height + base_y; if (t->icon_x_loc < 0) t->icon_x_loc += scr->d_width; if (t->icon_y_loc < 0) t->icon_y_loc += scr->d_height; } else if (t->wmhints && t->wmhints->flags & IconPositionHint) { t->icon_x_loc = t->wmhints->icon_x; t->icon_y_loc = t->wmhints->icon_y; } else { width = t->icon_p_width; height = t->icon_w_height + t->icon_p_height; loc_ok = False; /* check all boxes in order */ i = 0; while ((i < scr->num_icon_boxes) && (!loc_ok)) { /* In each IconBox, start at the upper left, travel right, then * down */ test_y = scr->icon_boxes[i][1] + base_y; temp_h = height; temp_w = width; /* OK second try at this. * If the window is taller than the icon box, ignore the icon height * when figuring where to put it. Same goes for the width */ /* This should permit reasonably graceful handling of big icons. */ if (width >= (scr->icon_boxes[i][2] - scr->icon_boxes[i][0])) temp_w = 0; if (height >= (scr->icon_boxes[i][3] - scr->icon_boxes[i][1])) temp_h = 0; while (((test_y + temp_h) < (scr->icon_boxes[i][3] + base_y)) && (!loc_ok)) { test_x = scr->icon_boxes[i][0] + base_x; while (((test_x + temp_w) < (scr->icon_boxes[i][2] + base_x)) && (!loc_ok)) { real_x = test_x; real_y = test_y; if (test_x + width > (scr->d_width - 2 + base_x)) real_x = scr->d_width - width - 2 + base_x; if (test_y + height > (scr->d_height - 2 + base_y)) real_y = scr->d_height - height - 2 + base_y; if (test_x < base_x) real_x = base_x; if (test_y < base_y) real_y = base_y; loc_ok = True; test_window = scr->mwm_root.next; while ((test_window != (MwmWindow *)0) && (loc_ok == True)) { if (test_window->Desk == t->Desk) { if ((test_window->flags & ICONIFIED) && (test_window->icon_w || test_window->icon_pixmap_w) && (test_window != t)) { tw = test_window->icon_p_width; th = test_window->icon_p_height + test_window->icon_w_height; tx = test_window->icon_x_loc; ty = test_window->icon_y_loc; if ((tx < (real_x + width + 3)) && ((tx + tw + 3) > real_x) && (ty < (real_y + height + 3)) && ((ty + th + 3) > real_y)) { loc_ok = False; } } if (scr->flags & StubbornIconPlacement) { if (!(test_window->flags & ICONIFIED) && (test_window != t)) { tw = test_window->frame_width; th = test_window->frame_height; tx = test_window->frame_x; ty = test_window->frame_y; if ((tx < (real_x + width + 3)) && ((tx + tw + 3) > real_x) && (ty < (real_y + height + 3)) && ((ty + th + 3) > real_y)) { loc_ok = False; } } } } test_window = test_window->next; } test_x += 3; } test_y += 3; } i++; } if (loc_ok == False) return; t->icon_x_loc = real_x; t->icon_y_loc = real_y; } if (t->icon_pixmap_w) XMoveWindow(dpy, t->icon_pixmap_w, t->icon_x_loc, t->icon_y_loc); t->icon_w_width = t->icon_p_width; t->icon_xl_loc = t->icon_x_loc; if (t->icon_w != None) XMoveResizeWindow(dpy, t->icon_w, t->icon_xl_loc, t->icon_y_loc + t->icon_p_height, t->icon_w_width, scr->components[MWM_ICON].f_height + 6);}/* * Iconifies the selected window */voidICON_Iconify(ScreenInfo *scr, MwmWindow *tmp_win, int def_x, int def_y){ MwmWindow *t; XWindowAttributes winattrs; unsigned long eventMask; XGetWindowAttributes(dpy, tmp_win->w, &winattrs); eventMask = winattrs.your_event_mask; if ((tmp_win) && (tmp_win == scr->mwm_highlight) && (Mwm.keyboard_focus_policy == XmEXPLICIT) && (tmp_win->next)) { WIN_SetFocusInTree(tmp_win->next); WIN_SetFocus(scr, tmp_win->next->w, tmp_win->next); MISC_SetFocusSequence(scr); } /* iconify transients first */ for (t = scr->mwm_root.next; t != NULL; t = t->next) { if ((t == tmp_win) || ((t->flags & TRANSIENT) && (t->transientfor == tmp_win->w))) { /* * Prevent the receipt of an UnmapNotify, since that would * cause a transition to the Withdrawn state. */ t->flags &= ~MAPPED; XSelectInput(dpy, t->w, eventMask & ~StructureNotifyMask); XUnmapWindow(dpy, t->w); XSelectInput(dpy, t->w, eventMask); XUnmapWindow(dpy, t->frame); t->DeIconifyDesk = t->Desk; if (t->icon_w) XUnmapWindow(dpy, t->icon_w); if (t->icon_pixmap_w) XUnmapWindow(dpy, t->icon_pixmap_w); PROP_SetState(t, IconicState); DEC_DrawDecorations(scr, t, False, False, False, None); if (t != tmp_win) t->flags |= ICONIFIED | ICON_UNMAPPED; if (t != tmp_win) PAGER_UpdateView(scr, t); } } if (tmp_win->icon_w == None) { if (tmp_win->flags & ICON_MOVED) ICON_CreateWindow(scr, tmp_win, tmp_win->icon_x_loc, tmp_win->icon_y_loc); else ICON_CreateWindow(scr, tmp_win, def_x, def_y); } if (Mwm.icon_auto_place) ICON_AutoPlace(scr, tmp_win); tmp_win->flags |= ICONIFIED; tmp_win->flags &= ~ICON_UNMAPPED; WIN_Lower(scr, tmp_win); if (tmp_win->Desk == scr->current_desk) { if (tmp_win->icon_w != None) XMapWindow(dpy, tmp_win->icon_w); if (tmp_win->icon_pixmap_w != None) XMapWindow(dpy, tmp_win->icon_pixmap_w); PAGER_UpdateView(scr, tmp_win); } if ((Mwm.keyboard_focus_policy == XmEXPLICIT) || (Mwm.keyboard_focus_policy == XmPOINTER)) { if ((tmp_win) && (tmp_win == scr->mwm_focus)) { if (scr->mwm_last_focus == scr->mwm_focus) scr->mwm_last_focus = NULL; if ((Mwm.keyboard_focus_policy == XmEXPLICIT) && (tmp_win->next)) { WIN_SetFocusInTree(tmp_win->next); WIN_SetFocus(scr, tmp_win->next->w, tmp_win->next); } else WIN_SetFocus(scr, scr->no_focus_win, NULL); MISC_SetFocusSequence(scr); } } if (Mwm.lower_on_iconify) WIN_Lower(scr, tmp_win);}/* * DeIconify a window */voidICON_DeIconify(ScreenInfo *scr, MwmWindow *tmp_win){ MwmWindow *t, *tmp; int new_x, new_y, w2, h2; /* now de-iconify transients */ for (t = scr->mwm_root.next; t != NULL; t = t->next) { if ((t == tmp_win) || ((t->flags & TRANSIENT) && (t->transientfor == tmp_win->w))) { t->flags |= MAPPED; if (scr->mwm_highlight == t) DEC_DrawDecorations(scr, t, False, True, True, None); /* make sure that the window is on this screen */ if ((t->frame_x < 0) || (t->frame_y < 0) || (t->frame_x >= scr->d_width) || (t->frame_y >= scr->d_height)) { /* try to put at least half the window * in the current screen, if the current desktop * is the windows desktop */ if (scr->flags & StubbornIcons) t->Desk = t->DeIconifyDesk; else t->Desk = scr->current_desk; if (t->Desk == scr->current_desk) { new_x = t->frame_x; new_y = t->frame_y; w2 = (t->frame_width >> 1); h2 = (t->frame_height >> 1); if (!(scr->flags & StubbornIcons)) { if ((new_x < -w2) || (new_x > (scr->d_width - w2))) { new_x = new_x % scr->d_width; if (new_x < -w2) new_x += scr->d_width; } if ((new_y < -h2) || (new_y > (scr->d_height - h2))) { new_y = new_y % scr->d_height; if (new_y < -h2) new_y += scr->d_height; } } DEC_ConfigureDecorations(scr, t, new_x, new_y, t->frame_width, t->frame_height, False); } } XMapWindow(dpy, t->w); if (t->Desk == scr->current_desk) { XMapWindow(dpy, t->frame); t->flags |= MAP_PENDING; } XMapWindow(dpy, t->parent); PROP_SetState(t, NormalState); t->flags &= ~ICONIFIED; t->flags &= ~ICON_UNMAPPED; /* Need to make sure the border is colored correctly, * in case it was stuck or unstuck while iconified. */ tmp = scr->mwm_highlight; scr->mwm_highlight = t; DEC_DrawDecorations(scr, t, False, True, True, None); scr->mwm_highlight = tmp; XRaiseWindow(dpy, t->w); if (t->icon_w) XUnmapWindow(dpy, t->icon_w); if (t->icon_pixmap_w) XUnmapWindow(dpy, t->icon_pixmap_w); } } WIN_Raise(scr, tmp_win); if ((scr->flags & StubbornIcons) || (Mwm.keyboard_focus_policy == XmEXPLICIT && Mwm.deiconify_key_focus)) WIN_ChangeFocus(scr, tmp_win, 1); PAGER_UpdateView(scr, tmp_win);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -