static void GrSetWindowCursorWrapper(void *r) { nxSetWindowCursorReq *req = r; GrSetWindowCursor(req->windowid, req->cursorid); }
int XDefineCursor(Display *dpy, Window w, Cursor cursor) { // FIXME assumes Cursor is nano-X compatible GrSetWindowCursor(w, cursor); return 1; }
static void set_resize_cursor(int wid) { static int resize_cursor = 0; if (!resize_cursor) { GR_BITMAP resize_fg[16]; GR_BITMAP resize_bg[16]; resize_fg[0] = MASK(_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_); resize_fg[1] = MASK(_,X,X,X,X,X,_,_,_,_,_,_,_,_,_,_); resize_fg[2] = MASK(_,X,X,X,X,_,_,_,_,_,_,_,_,_,_,_); resize_fg[3] = MASK(_,X,X,X,_,_,_,_,_,_,_,_,_,_,_,_); resize_fg[4] = MASK(_,X,X,_,X,_,_,_,_,_,_,_,_,_,_,_); resize_fg[5] = MASK(_,X,_,_,_,X,_,_,_,_,_,_,_,_,_,_); resize_fg[6] = MASK(_,_,_,_,_,_,X,_,_,_,_,_,_,_,_,_); resize_fg[7] = MASK(_,_,_,_,_,_,_,X,_,_,_,_,_,_,_,_); resize_fg[8] = MASK(_,_,_,_,_,_,_,_,X,_,_,_,_,_,_,_); resize_fg[9] = MASK(_,_,_,_,_,_,_,_,_,X,_,_,_,_,_,_); resize_fg[10] = MASK(_,_,_,_,_,_,_,_,_,_,X,_,_,_,X,_); resize_fg[11] = MASK(_,_,_,_,_,_,_,_,_,_,_,X,_,X,X,_); resize_fg[12] = MASK(_,_,_,_,_,_,_,_,_,_,_,_,X,X,X,_); resize_fg[13] = MASK(_,_,_,_,_,_,_,_,_,_,_,X,X,X,X,_); resize_fg[14] = MASK(_,_,_,_,_,_,_,_,_,_,X,X,X,X,X,_); resize_fg[15] = MASK(_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_); resize_bg[0] = MASK(X,X,X,X,X,X,X,_,_,_,_,_,_,_,_,_); resize_bg[1] = MASK(X,X,X,X,X,X,X,_,_,_,_,_,_,_,_,_); resize_bg[2] = MASK(X,X,X,X,X,X,_,_,_,_,_,_,_,_,_,_); resize_bg[3] = MASK(X,X,X,X,X,_,_,_,_,_,_,_,_,_,_,_); resize_bg[4] = MASK(X,X,X,X,X,X,_,_,_,_,_,_,_,_,_,_); resize_bg[5] = MASK(X,X,X,_,X,X,X,_,_,_,_,_,_,_,_,_); resize_bg[6] = MASK(X,X,_,_,_,X,X,X,_,_,_,_,_,_,_,_); resize_bg[7] = MASK(_,_,_,_,_,_,X,X,X,_,_,_,_,_,_,_); resize_bg[8] = MASK(_,_,_,_,_,_,_,X,X,X,_,_,_,_,_,_); resize_bg[9] = MASK(_,_,_,_,_,_,_,_,X,X,X,_,_,_,X,X); resize_bg[10] = MASK(_,_,_,_,_,_,_,_,_,X,X,X,_,X,X,X); resize_bg[11] = MASK(_,_,_,_,_,_,_,_,_,_,X,X,X,X,X,X); resize_bg[12] = MASK(_,_,_,_,_,_,_,_,_,_,_,X,X,X,X,X); resize_bg[13] = MASK(_,_,_,_,_,_,_,_,_,_,X,X,X,X,X,X); resize_bg[14] = MASK(_,_,_,_,_,_,_,_,_,X,X,X,X,X,X,X); resize_bg[15] = MASK(_,_,_,_,_,_,_,_,_,X,X,X,X,X,X,X); resize_cursor = GrNewCursor(16, 16, 8, 8, WHITE, BLACK, (MWIMAGEBITS *)resize_fg, (MWIMAGEBITS *)resize_bg); } GrSetWindowCursor(wid, resize_cursor); }
void wm_container_buttondown(win *window, GR_EVENT_BUTTON *event) { struct pos_size *pos; GR_RECT r; GR_COORD cxborder = 0, cyborder = 0; GR_WINDOW_INFO info; GR_WINDOW_INFO cinfo; GR_GC_ID gc; Dprintf("wm_container_buttondown window %d\n", window->wid); if(window->active) return; GrGetWindowInfo(window->wid, &info); GrGetWindowInfo(window->clientid, &cinfo); /* calc border sizes*/ if (info.props & GR_WM_PROPS_BORDER) { cxborder = 1; cyborder = 1; } if (info.props & GR_WM_PROPS_APPFRAME) { cxborder = CXBORDER; cyborder = CYBORDER; } /* Check for close box press*/ if ((info.props & (GR_WM_PROPS_CAPTION|GR_WM_PROPS_CLOSEBOX)) == (GR_WM_PROPS_CAPTION|GR_WM_PROPS_CLOSEBOX)) { /* Get close box rect*/ r.x = info.width - CXCLOSEBOX - cxborder - 2; r.y = cyborder + 2; r.width = CXCLOSEBOX; r.height = CYCLOSEBOX; /* Check mousedn in close box*/ if (PtInRect(&r, event->x, event->y)) { /* close on button up*/ window->close = GR_TRUE; return; } } /* * Set focus to the window only if client * or the container itself is clicked. * if any of the children (of the client) * are clicked better not take the focus * away from them. They might require handling * the focus themself. * -- Amit Kulkarni */ if(window->wid==event->subwid) GrSetFocus(window->wid); /* check for corner resize */ r.x = info.width - 5; r.y = info.height - 5; r.width = 5; r.height = 5; if (PtInRect(&r,event->x, event->y) && !(info.props & GR_WM_PROPS_NORESIZE) && !(cinfo.props & GR_WM_PROPS_NORESIZE)) { #if !NO_CORNER_RESIZE struct pos_size * pos; if(!window->data) if(!(window->data = malloc(sizeof(struct pos_size)))) return; window->sizing = GR_TRUE; /* save off the width/height offset from the window manager */ GrGetWindowInfo(window->clientid,&info); pos = (struct pos_size*)window->data; pos->xoff = -info.width; pos->yoff = -info.height; GrGetWindowInfo(window->wid,&info); pos->xoff += info.width; pos->yoff += info.height; gc = GrNewGC(); GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN); GrRect(GR_ROOT_WINDOW_ID,gc,info.x, info.y, info.width, info.height); GrDestroyGC(gc); /* save this rectangle's width/height so we can erase it later */ pos->width = info.width; pos->height = info.height; pos->xorig = event->x; pos->yorig = event->y; /* * This window is being resized. * The client should have focus now. * -- Amit Kulkarni */ GrSetFocus(window->clientid); return; #endif /* !NO_CORNER_RESIZE*/ } else GrSetWindowCursor(window->wid, 0); /* if not in caption, return (FIXME, not calc'd exactly)*/ if (!(info.props & GR_WM_PROPS_CAPTION)) return; /* Get caption box rect*/ r.x = cxborder; r.y = cyborder; r.width = info.width - cxborder*2; r.height = CYCAPTION; /* Check for mousedn in caption box*/ if (!PtInRect(&r, event->x, event->y)) return; /* * Now we have a click on the caption. * So window is active. * Set focus to the client * --Amit Kulkarni */ GrSetFocus(window->clientid); /* Raise window if mouse down and allowed*/ if (!(info.props & GR_WM_PROPS_NORAISE) && !(cinfo.props & GR_WM_PROPS_NORAISE)) GrRaiseWindow(window->wid); /* Don't allow window move if NOMOVE property set*/ if ((info.props & GR_WM_PROPS_NOMOVE) || (cinfo.props & GR_WM_PROPS_NOMOVE)) return; if(!window->data) if(!(window->data = malloc(sizeof(struct pos_size)))) return; GrGetWindowInfo(window->wid,&info); pos = (struct pos_size *)window->data; pos->xoff = event->x; pos->yoff = event->y; #if OUTLINE_MOVE pos->xorig = info.x; pos->yorig = info.y; pos->width = info.width; pos->height = info.height; gc = GrNewGC(); GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN); GrRect(GR_ROOT_WINDOW_ID, gc,info.x, info.y, info.width, info.height); GrDestroyGC(gc); #endif window->active = GR_TRUE; }
void wm_container_mouse_exit(win *window, GR_EVENT_GENERAL *event) { if (!window->sizing) GrSetWindowCursor(window->wid, 0); }
void wm_container_mousemoved(win *window, GR_EVENT_MOUSE *event) { struct pos_size *pos; GR_GC_ID gc; GR_RECT r; GR_WINDOW_INFO info; Dprintf("wm_container_mousemoved window %d\n", window->wid); GrGetWindowInfo(window->wid, &info); if(window->sizing) { struct pos_size * pos = (struct pos_size*)window->data; /* erase old rectangle */ gc = GrNewGC(); GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN); GrRect(GR_ROOT_WINDOW_ID, gc, info.x, info.y, pos->width, pos->height); /* draw new one */ GrRect(GR_ROOT_WINDOW_ID,gc,info.x, info.y, event->rootx - info.x, event->rooty - info.y); GrDestroyGC(gc); /* save this new rectangle's width, height */ /* I know, this shouldn't be stored in x/y, but... */ pos->width = event->rootx - info.x; pos->height = event->rooty - info.y; return; } #if !NO_CORNER_RESIZE /* check corner resize cursor on/off*/ r.x = info.width - 5; r.y = info.height - 5; r.width = 5; r.height = 5; if (PtInRect(&r,event->x, event->y)) set_resize_cursor(window->wid); else GrSetWindowCursor(window->wid, 0); #endif if(!window->active) return; pos = (struct pos_size *)window->data; #if OUTLINE_MOVE gc = GrNewGC(); GrSetGCMode(gc, GR_MODE_XOR|GR_MODE_EXCLUDECHILDREN); GrRect(GR_ROOT_WINDOW_ID,gc,pos->xorig, pos->yorig, pos->width, pos->height); GrRect(GR_ROOT_WINDOW_ID,gc,event->rootx - pos->xoff, event->rooty - pos->yoff, pos->width, pos->height); pos->xorig = event->rootx - pos->xoff; pos->yorig = event->rooty - pos->yoff; GrDestroyGC(gc); #else GrMoveWindow(window->wid, event->rootx - pos->xoff, event->rooty - pos->yoff); #endif }
int XUndefineCursor(Display *dpy, Window w) { GrSetWindowCursor(w, 0); return 1; }
/* * Initialize the graphics and mouse devices at startup. * Returns nonzero with a message printed if the initialization failed. */ int GsInitialize(void) { GR_WINDOW *wp; /* root window */ PSD psd; GR_CURSOR_ID cid; static MWIMAGEBITS cursorbits[16] = { 0xe000, 0x9800, 0x8600, 0x4180, 0x4060, 0x2018, 0x2004, 0x107c, 0x1020, 0x0910, 0x0988, 0x0544, 0x0522, 0x0211, 0x000a, 0x0004 }; static MWIMAGEBITS cursormask[16] = { 0xe000, 0xf800, 0xfe00, 0x7f80, 0x7fe0, 0x3ff8, 0x3ffc, 0x1ffc, 0x1fe0, 0x0ff0, 0x0ff8, 0x077c, 0x073e, 0x021f, 0x000e, 0x0004 }; /* If needed, initialize the server mutex. */ SERVER_LOCK_INIT(); setbuf(stdout, NULL); setbuf(stderr, NULL); wp = (GR_WINDOW *) malloc(sizeof(GR_WINDOW)); if (wp == NULL) { EPRINTF("Cannot allocate root window\n"); return -1; } startTicks = GsGetTickCount(); #ifndef MW_NOSIGNALS /* catch terminate signal to restore tty state*/ signal(SIGTERM, (void *)GsTerminate); #endif #if MW_FEATURE_TIMERS screensaver_delay = 0; #endif screensaver_active = GR_FALSE; selection_owner.wid = 0; selection_owner.typelist = NULL; #if !NONETWORK #ifndef MW_NOSIGNALS /* ignore pipe signal, sent when clients exit*/ signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); #endif if (GsOpenSocket() < 0) { EPRINTF("Cannot bind to named socket\n"); free(wp); return -1; } #endif if ((keyb_fd = GdOpenKeyboard()) == -1) { EPRINTF("Cannot initialise keyboard\n"); /*GsCloseSocket();*/ free(wp); return -1; } #ifdef MW_FEATURE_TWO_KEYBOARDS if ((keyb2_fd = GdOpenKeyboard2()) == -1) { EPRINTF("Cannot initialise second keyboard\n"); /*GsCloseSocket();*/ free(wp); return -1; } #endif if ((psd = GdOpenScreen()) == NULL) { EPRINTF("Cannot initialise screen\n"); /*GsCloseSocket();*/ GdCloseKeyboard(); free(wp); return -1; } GdSetPortraitMode(psd, portraitmode); if ((mouse_fd = GdOpenMouse()) == -1) { EPRINTF("Cannot initialise mouse\n"); /*GsCloseSocket();*/ GdCloseScreen(psd); GdCloseKeyboard(); free(wp); return -1; } /* * Create std font. */ #if (HAVE_BIG5_SUPPORT | HAVE_GB2312_SUPPORT | HAVE_JISX0213_SUPPORT | HAVE_KSC5601_SUPPORT) /* system fixed font looks better when mixed with builtin fixed fonts*/ stdfont = GdCreateFont(psd, MWFONT_SYSTEM_FIXED, 0, NULL); #else stdfont = GdCreateFont(psd, MWFONT_SYSTEM_VAR, 0, NULL); #endif /* * Initialize the root window. */ wp->psd = psd; wp->id = GR_ROOT_WINDOW_ID; wp->parent = NULL; /* changed: was = NULL*/ wp->owner = NULL; wp->children = NULL; wp->siblings = NULL; wp->next = NULL; wp->x = 0; wp->y = 0; wp->width = psd->xvirtres; wp->height = psd->yvirtres; wp->bordersize = 0; wp->background = BLACK; wp->bordercolor = wp->background; wp->nopropmask = 0; wp->bgpixmap = NULL; wp->bgpixmapflags = GR_BACKGROUND_TILE; wp->eventclients = NULL; wp->cursorid = 0; wp->mapped = GR_TRUE; wp->realized = GR_TRUE; wp->output = GR_TRUE; wp->props = 0; wp->title = NULL; wp->clipregion = NULL; listpp = NULL; listwp = wp; rootwp = wp; focuswp = wp; mousewp = wp; focusfixed = GR_FALSE; /* * Initialize and position the default cursor. */ curcursor = NULL; cursorx = -1; cursory = -1; GdShowCursor(psd); GsMoveCursor(psd->xvirtres / 2, psd->yvirtres / 2); SERVER_UNLOCK(); cid = GrNewCursor(16, 16, 0, 0, WHITE, BLACK, cursorbits, cursormask); GrSetWindowCursor(GR_ROOT_WINDOW_ID, cid); SERVER_LOCK(); stdcursor = GsFindCursor(cid); #if VTSWITCH MwInitVt(); /* Check for VT change every 50 ms: */ GdAddTimer(50, CheckVtChange, NULL); #endif psd->FillRect(psd, 0, 0, psd->xvirtres-1, psd->yvirtres-1, GdFindColor(psd, wp->background)); /* * Tell the mouse driver some things. */ curbuttons = 0; GdRestrictMouse(0, 0, psd->xvirtres - 1, psd->yvirtres - 1); GdMoveMouse(psd->xvirtres / 2, psd->yvirtres / 2); /* Force root window screen paint*/ GsRedrawScreen(); /* * Force the cursor to appear on the screen at startup. * (not required with above GsRedrawScreen) GdHideCursor(psd); GdShowCursor(psd); */ /* * All done. */ connectcount = 0; return 0; }