/* * 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; }
/* * 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, BUTTON newbuttons) { BUTTON changebuttons; /* buttons that have changed */ unsigned char ch; /* latest character */ MODIFIER modifiers; /* latest modifiers */ GdReadKeyboard(&ch, &modifiers); /* Read the modifiers */ /* * 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)) { GsMoveCursor(newx, newy); GsFlush(); 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) { 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) { GsDeliverButtonEvent(GR_EVENT_TYPE_BUTTON_DOWN, newbuttons, changebuttons, modifiers); } curbuttons = newbuttons; }