?? pager.c
字號(hào):
/* $Id: pager.c,v 1.1 2004/08/28 19:25:46 dannybackx Exp $ *//**************************************************************************** * This module is all new * by Rob Nation ****************************************************************************//*********************************************************************** * The rest of it is all my fault -- MLM * mwm - "LessTif Window Manager" ***********************************************************************/#include <LTconfig.h>#include <string.h>#include <Xm/Xm.h>#include <Xm/MwmUtil.h>#include "mwm.h"Bool pagerOn = True;Bool EnablePagerRedraw = True;Bool DoHandlePageing = True;static char *pager_name = "Mwm Pager";static XClassHint classhints ={ "pager", "Mwm"};static XSizeHints sizehints ={ (PMinSize | PResizeInc | PBaseSize | PWinGravity), 0, 0, 100, 100, /* x, y, width and height */ 1, 1, /* Min width and height */ 0, 0, /* Max width and height */ 1, 1, /* Width and height increments */ {0, 0}, {0, 0}, /* Aspect ratio - not used */ 1, 1, /* base size */ (NorthWestGravity) /* gravity */};/* * draw the lines delimiting the virtual screens */static voiddraw_partitions(ScreenInfo *scr){ int y, y1, y2, x, x1, x2; int MaxW, MaxH, width, height; MaxW = scr->virt_x_max + scr->d_width; MaxH = scr->virt_y_max + scr->d_height; width = scr->mwm_pager->frame_width - 2 * scr->mwm_pager->boundary_width - 2 * scr->mwm_pager->matte_width; height = scr->mwm_pager->frame_height - scr->mwm_pager->title_height - 2 * scr->mwm_pager->boundary_width - 2 * scr->mwm_pager->matte_width; x = scr->d_width; y1 = 0; y2 = height; while (x < MaxW) { x1 = x * width / MaxW; XDrawLine(dpy, scr->pager_win, scr->components[MWM_PAGER].normal_GC, x1, y1, x1, y2); x += scr->d_width; } y = scr->d_height; x1 = 0; x2 = width; while (y < MaxH) { y1 = y * height / MaxH; XDrawLine(dpy, scr->pager_win, scr->components[MWM_PAGER].normal_GC, x1, y1, x2, y1); y += scr->d_height; }}/* * clear the pager area. This will cause the pager to be redrawn. */voidPAGER_Clear(ScreenInfo *scr){ if ((scr->mwm_pager) && (EnablePagerRedraw)) XClearArea(dpy, scr->pager_win, 0, 0, scr->mwm_pager->frame_width, scr->mwm_pager->frame_height, True);}/* * redraw the pager: we try to be clever - re-draw the pager by causing * an expose event, so that the redraw occurs when the expose arrives. * The advantage is that the number of re-draws will be minimized. */voidPAGER_Redraw(ScreenInfo *scr){ MwmWindow *t; if (!scr->mwm_pager) return; MISC_FlushExpose(scr->pager_win); MISC_FlushExpose(scr->pager_child_win); if (scr->components[MWM_PAGER].f_height > 0) { if (scr->mwm_highlight != NULL) { if (!(scr->mwm_highlight->flags & STICKY) && (scr->mwm_highlight->icon_label != NULL)) { MISC_FlushExpose(scr->mwm_highlight->pager_view); XDrawImageString(dpy, scr->mwm_highlight->pager_view, scr->components[MWM_PAGER].normal_GC, 2, scr->components[MWM_PAGER].f_y + 2, scr->mwm_highlight->icon_label, strlen(scr->mwm_highlight->icon_label)); } } for (t = scr->mwm_root.next; t != NULL; t = t->next) { if (t != scr->mwm_highlight) { if (!(t->flags & STICKY) && (t->icon_label != NULL)) { MISC_FlushExpose(t->pager_view); XDrawImageString(dpy, t->pager_view, scr->components[MWM_PAGER].normal_GC, 2, scr->components[MWM_PAGER].f_y + 2, t->icon_label, strlen(t->icon_label)); } } } } draw_partitions(scr);}/* * update the child. MLM -- I'm still not sure what this is. */voidPAGER_UpdateViewPort(ScreenInfo *scr){ int width, height, x1, x2, y1, y2; if ((scr->pager_child_win) && (scr->mwm_pager)) { width = scr->mwm_pager->frame_width - 2 * scr->mwm_pager->boundary_width - 2 * scr->mwm_pager->matte_width; height = scr->mwm_pager->frame_height - scr->mwm_pager->title_height - 2 * scr->mwm_pager->boundary_width - 2 * scr->mwm_pager->matte_width; x1 = scr->virt_x * width / (scr->virt_x_max + scr->d_width) + 1; y1 = scr->virt_y * height / (scr->virt_y_max + scr->d_height) + 1; x2 = (scr->d_width) * width / (scr->virt_x_max + scr->d_width) - 1; y2 = (scr->d_height) * height / (scr->virt_y_max + scr->d_height) - 1; if (x1 == 1) { x1--; x2++; } if (y1 == 1) { y1--; y2++; } XMoveResizeWindow(dpy, scr->pager_child_win, x1, y1, x2, y2); }}/* * update the pager view */voidPAGER_UpdateView(ScreenInfo *scr, MwmWindow *t){ unsigned int width, height; int ww, wh; int wx, wy; int MaxH, MaxW; if ((!scr->mwm_pager) || (!pagerOn)) return; width = scr->mwm_pager->frame_width - 2 * scr->mwm_pager->boundary_width - 2 * scr->mwm_pager->matte_width; height = scr->mwm_pager->frame_height - scr->mwm_pager->title_height - 2 * scr->mwm_pager->boundary_width - 2 * scr->mwm_pager->matte_width; MaxW = scr->virt_x_max + scr->d_width; MaxH = scr->virt_y_max + scr->d_height; if ((!(t->flags & STICKY)) && (!((t->flags & ICONIFIED) && (t->flags & ICON_UNMAPPED))) && (t->Desk == scr->current_desk)) { if (t->flags & ICONIFIED) { /* show the icon loc */ wx = (t->icon_x_loc + scr->virt_x) * (int)width / MaxW;; wy = (t->icon_y_loc + scr->virt_y) * (int)height / MaxH; ww = t->icon_w_width * (int)width / MaxW; wh = (t->icon_w_height + t->icon_p_height) * (int)height / MaxH; } else { /* show the actual window */ wx = (t->frame_x + scr->virt_x) * (int)width / MaxW; wy = (t->frame_y + scr->virt_y) * (int)height / MaxH; ww = t->frame_width * (int)width / MaxW; wh = t->frame_height * (int)height / MaxH; } if (ww < 2) ww = 2; if (wh < 2) wh = 2; XMoveResizeWindow(dpy, t->pager_view, wx, wy, ww, wh); } else { /* window is sticky - make sure that the pager_view window is not * visible */ XMoveResizeWindow(dpy, t->pager_view, -10, -10, 5, 5); } PAGER_Clear(scr);}/* * Moves the viewport within thwe virtual desktop */voidPAGER_MoveViewPort(ScreenInfo *scr, int newx, int newy, Boolean grab){ MwmWindow *t; int deltax, deltay; XEvent oevent; if (grab) XGrabServer(dpy); if (newx > scr->virt_x_max) newx = scr->virt_x_max; if (newy > scr->virt_y_max) newy = scr->virt_y_max; if (newx < 0) newx = 0; if (newy < 0) newy = 0; deltay = scr->virt_y - newy; deltax = scr->virt_x - newx; scr->virt_x = newx; scr->virt_y = newy; if ((deltax != 0) || (deltay != 0)) { for (t = scr->mwm_root.next; t != NULL; t = t->next) { /* If the window is iconified, and sticky Icons is set, * then the window should essentially be sticky */ if (!(t->flags & STICKY)) { t->icon_x_loc += deltax; t->icon_xl_loc += deltax; t->icon_y_loc += deltay; if (t->icon_pixmap_w != None) XMoveWindow(dpy, t->icon_pixmap_w, t->icon_x_loc, t->icon_y_loc); if (t->icon_w != None) XMoveWindow(dpy, t->icon_w, t->icon_x_loc, t->icon_y_loc + t->icon_p_height); DEC_ConfigureDecorations(scr, t, t->frame_x + deltax, t->frame_y + deltay, t->frame_width, t->frame_height, False); } } for (t = scr->mwm_root.next; t != NULL; t = t->next) { /* If its an icon, and its sticking, autoplace it so * that it doesn't wind up on top a a stationary * icon */ if ((t->flags & STICKY) && (t->flags & ICONIFIED) && (!(t->flags & ICON_MOVED)) && (!(t->flags & ICON_UNMAPPED))) ICON_AutoPlace(scr, t);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -