Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
static void
GrNewCursorWrapper(void *r)
{
	nxNewCursorReq *req = r;
	int		varlen;
	char *          bitmap;
	GR_CURSOR_ID	cursorid;

	varlen = GetReqVarLen(req);
	bitmap = GetReqData(req);

	cursorid = GrNewCursor(req->width, req->height,
		req->hotx, req->hoty, req->fgcolor, req->bgcolor,
		(GR_BITMAP *)bitmap, (GR_BITMAP *)(bitmap+varlen/2));

	GsWriteType(current_fd, GrNumNewCursor);
	GsWrite(current_fd, &cursorid, sizeof(cursorid));
}
Ejemplo n.º 3
0
/* Calculate the cursor from the given pixmap */
GR_CURSOR_ID
_nxCreateCursor(GR_WINDOW_ID cursor, GR_RECT * cbb,
		 GR_WINDOW_ID mask, GR_RECT * mbb,
		 int hotx, int hoty, GR_COLOR fg, GR_COLOR bg)
{
	int w, h;
	GR_BITMAP *bcursor, *bmask;
	GR_CURSOR_ID cursorid;

	/* force cursor size to max Microwindows size*/
	w = min(cbb->width, MWMAX_CURSOR_SIZE);
	h = min(cbb->height, MWMAX_CURSOR_SIZE);
	bcursor = GrNewBitmapFromPixmap(cursor, cbb->x, cbb->y, w, h);
	if (!bcursor)
		return 0;

	w = min(mbb->width, MWMAX_CURSOR_SIZE);
	h = min(mbb->height, MWMAX_CURSOR_SIZE);
	bmask = GrNewBitmapFromPixmap(mask, mbb->x, mbb->y, w, h);
	if (!bmask) {
		Xfree(bcursor);
		return 0;
	}

	if (cbb->width > w || cbb->height > h)
		printf("nxCreateCursor: truncating original cursor (%d x %d)\n",
		       cbb->width, cbb->height);

	/*
	 * Foreground/background reversed from nano-X !!!
	 */
	cursorid = GrNewCursor(w, h, hotx, hoty, bg, fg, bcursor, bmask);

	free(bcursor);
	free(bmask);

	return cursorid;
}
Ejemplo n.º 4
0
/*
 * 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;
}
Ejemplo n.º 5
0
Card::Card(Suit s, unsigned int v)
  : NSWindow(true, gameWindow, 0, 0, cardWidth, cardHeight, 1, XC_BLACK)
{
  if (!initialized) {
#ifdef SHAPE
    if (Option::roundCard()) {
     	    //Shape
	    boundingMask = XCreateBitmapFromData(dpy, root(),
				boundingMask_bits, boundingMask_width,
				boundingMask_height);
	    clipMask = XCreateBitmapFromData(dpy, root(), clipMask_bits,
				clipMask_width, clipMask_height);
    }
#endif

    //Cursor
    //XColor fore, back, xc;
    //gi_window_id_t p, mask;
    //Colormap cm = DefaultColormap(dpy, 0);
    //p =  XCreateBitmapFromData(dpy, gameWindow, (char*) cursor_bits, cursor_width, cursor_height);
    //mask = XCreateBitmapFromData(dpy, gameWindow, (char*) cursor_back_bits, cursor_back_width, cursor_back_height);
    //XAllocNamedColor(dpy, cm, "white", &fore, &xc);
    //XAllocNamedColor(dpy, cm, "black", &back, &xc);
    //cursor = XCreatePixmapCursor(dpy, p,mask, &fore, &back, 0, 0);

#ifdef GIXOK
    uint16_t *p = gi_create_bitmap_from_data(16, 16, cursor_width, cursor_height, cursor_bits,
    	TRUE,TRUE);
    uint16_t *mask =  gi_create_bitmap_from_data(16, 16, cursor_back_width, cursor_back_height,
    	cursor_back_bits, TRUE,TRUE);
    cursor = GrNewCursor(16, 16, 8, 0, XC_BLACK, XC_WHITE, p, mask);
    free(p);
    free(mask);
#endif

    initialized = true;
  }

  _parent = 0;
  _stack = 0;
  _suit = s;
  _value = v;
  _removed = false;
  makeBitmap(s, v, bitmap);

  // initialization on X things
  unsigned long fore, back, hilight;

  if (suitColor(s) == RedSuit)
    fore = getColor( XC_RED);
  else
    fore = getColor( XC_BLACK);
  back = XC_WHITE;
  hilight = getColor( XC_LIGHTSKYBLUE4);


  _usualPixmap = 
    gi_create_pixmap_from_bitmap( gameWindow, bitmap, cardWidth - 2,
	cardHeight - 2, fore, back, gi_screen_format() );
  _hilightedPixmap = 
    gi_create_pixmap_from_bitmap( gameWindow, bitmap, cardWidth - 2,
	cardHeight - 2, fore, hilight, gi_screen_format() );


  selectInput(GI_MASK_BUTTON_DOWN | GI_MASK_MOUSE_ENTER | GI_MASK_MOUSE_EXIT);
  backgroundPixmap(_usualPixmap);

#ifdef SHAPE
  if (Option::roundCard()) {
    XShapeCombineMask(dpy, window(), ShapeBounding, 0, 0, boundingMask, ShapeSet);
    XShapeCombineMask(dpy, window(), ShapeClip, 0, 0, clipMask, ShapeSet);
  }
#endif

  NSWindow::move(0, 0);

  map();
}