Exemplo n.º 1
0
//
// Update keyboard status and issue events on it if necessary.
// This function doesn't block, but is normally only called when
// there is known to be some data waiting to be read from the keyboard.
//
BOOL GsCheckKeyboardEvent(void)
{
	MWKEY		ch;		// latest character
	MWKEYMOD	modifiers;	// latest modifiers 
	MWSCANCODE	scancode;	// latest modifiers 
	int		keystatus;	// latest keyboard status 

	// Read the latest keyboard status: 
display_puts("key read\n");
	keystatus = GdReadKeyboard(&ch, &modifiers, &scancode);
	if(keystatus < 0) {
		if(keystatus == -2)	// special case for ESC pressed
			GsTerminate();
		display_puts("Kbd error\n");
		return FALSE;
	} else if(keystatus) { // Deliver events as appropriate: 
		byte2hex(modifiers,s);
		display_puts("kbd '");
		display_putc(ch);
		display_puts("',");
		display_puts(s);
		display_puts("\n");
		return TRUE;
	}
	return FALSE;
}
Exemplo n.º 2
0
/*
 * Drop a specific server connection.
 */
void
GsClose(int fd)
{
	GsDropClient(fd);
	if(!persistent_mode && connectcount == 0)
		GsTerminate();
}
Exemplo n.º 3
0
/*
 * Close the connection to the server.
 */
void
GsClose(void)
{
#if !NONETWORK
	GsDropClient(current_fd);
#endif
        if(--connectcount == 0)
		GsTerminate();
}
Exemplo n.º 4
0
/*
 * Handle all mouse events.  These are mouse enter, mouse exit, mouse
 * motion, mouse position, button down, and button up.  This also moves
 * the cursor to the new mouse position and changes it shape if needed.
 */
void GsHandleMouseStatus(GR_COORD newx, GR_COORD newy, int newbuttons)
{
	int	 changebuttons;	/* buttons that have changed */
	MWKEYMOD modifiers;	/* latest modifiers */
	
	GdGetModifierInfo(NULL, &modifiers); /* Read kbd modifiers */

	/* If we are currently in raw mode, then just deliver the raw event */
	if (mousedev.flags & MOUSE_RAW) { 
		GsDeliverRawMouseEvent(newx, newy, newbuttons, modifiers);
		return;
	}

	/*
	 * First, if the mouse has moved, then position the cursor to the
	 * new location, which will send mouse enter, mouse exit, focus in,
	 * and focus out events if needed.  Check here for mouse motion and
	 * mouse position events.  Flush the device queue to make sure the
	 * new cursor location is quickly seen by the user.
	 */
	if ((newx != cursorx) || (newy != cursory)) {
		GsResetScreenSaver();
		GrMoveCursor(newx, newy);

		GsDeliverMotionEvent(GR_EVENT_TYPE_MOUSE_MOTION,
			newbuttons, modifiers);
		GsDeliverMotionEvent(GR_EVENT_TYPE_MOUSE_POSITION,
			newbuttons, modifiers);
	}

	/*
	 * Next, generate a button up event if any buttons have been released.
	 */
	changebuttons = (curbuttons & ~newbuttons);
	if (changebuttons) {

	  GsResetScreenSaver();
	  GsDeliverButtonEvent(GR_EVENT_TYPE_BUTTON_UP,
			       newbuttons, changebuttons, modifiers);
	}

	/*
	 * Finally, generate a button down event if any buttons have been
	 * pressed.
	 */
	changebuttons = (~curbuttons & newbuttons);
	if (changebuttons) {
if ((newbuttons&(GR_BUTTON_L|GR_BUTTON_R)) == (GR_BUTTON_L|GR_BUTTON_R))
GsTerminate();
		GsResetScreenSaver();
		GsDeliverButtonEvent(GR_EVENT_TYPE_BUTTON_DOWN,
			newbuttons, changebuttons, modifiers);
	}

	curbuttons = newbuttons;
}
Exemplo n.º 5
0
/*
 * Update keyboard status and issue events on it if necessary.
 * This function doesn't block, but is normally only called when
 * there is known to be some data waiting to be read from the keyboard.
 */
GR_BOOL GsCheckKeyboardEvent(void)
{
	MWKEY	 	mwkey;		/* latest character */
	MWKEYMOD 	modifiers;	/* latest modifiers */
	MWSCANCODE	scancode;
	int	 	keystatus;	/* latest keyboard status */

	/* Read the latest keyboard status: */
	keystatus = GdReadKeyboard(&mwkey, &modifiers, &scancode);

	if(keystatus < 0) {
		if(keystatus == -2)	/* special case return code*/
			GsTerminate();
		GsError(GR_ERROR_KEYBOARD_ERROR, 0);
		return FALSE;
	} else if(keystatus) {		/* Deliver events as appropriate: */	
		switch (mwkey) {
		case MWKEY_QUIT:
			GsTerminate();
			/* no return*/
		case MWKEY_REDRAW:
			GsRedrawScreen();
			break;
		case MWKEY_PRINT:
			if (keystatus == 1)
				GdCaptureScreen("screen.bmp");
			break;
		}
				
		GsDeliverKeyboardEvent(0,
			(keystatus==1?
			GR_EVENT_TYPE_KEY_DOWN: GR_EVENT_TYPE_KEY_UP),
			mwkey, modifiers, scancode);
		return TRUE;
	}
	return FALSE;
}
Exemplo n.º 6
0
/*
 * Update keyboard status and issue events on it if necessary.
 * This function doesn't block, but is normally only called when
 * there is known to be some data waiting to be read from the keyboard.
 */
void GsCheckKeyboardEvent(void)
{
	unsigned char	ch;		/* latest character */
	MODIFIER	modifiers;	/* latest modifiers */
	int		keystatus;	/* latest keyboard status */

	/* Read the latest keyboard status: */
	keystatus = GdReadKeyboard(&ch, &modifiers);
	if(keystatus < 0) {
		if(keystatus == -2)	/* special case for ESC pressed*/
			GsTerminate();
		GsError(GR_ERROR_KEYBOARD_ERROR, 0);
		return;
	} else if(keystatus) /* Deliver events as appropriate: */	
		GsDeliverKeyboardEvent(GR_EVENT_TYPE_KEY_DOWN, ch, modifiers);
}
Exemplo n.º 7
0
/*
 * Update keyboard status and issue events on it if necessary.
 * This function doesn't block, but is normally only called when
 * there is known to be some data waiting to be read from the keyboard.
 */
BOOL GsCheckKeyboardEvent(void)
{
	unsigned char	ch;		/* latest character */
	MODIFIER	modifiers;	/* latest modifiers */
	int		keystatus;	/* latest keyboard status */

	/* Read the latest keyboard status: */
	keystatus = GdReadKeyboard(&ch, &modifiers);
	if(keystatus < 0) {
		if(keystatus == -2)	/* special case for ESC pressed*/
			GsTerminate();
		printf("Kbd error\n");
		return FALSE;
	} else if(keystatus) { /* Deliver events as appropriate: */	
		printf("kbd '%c',%d\n", ch, modifiers);
      return TRUE;
   }
   return FALSE;
}