PyObject* LMF_MouseReleased (PyObject *self, PyObject *args){ int iMouseButton; if (!PyArg_ParseTuple(args, "i", &iMouseButton)) { ParsePyTupleError( __func__, __LINE__ ); return nullptr; } int iMouseState = MouseReleased(iMouseButton); return Py_BuildValue("i", iMouseState); }
int CheckMouseRelease (int x1, int y1, int x2, int y2) { int i, wait = TRUE; while (wait) for (i = 0; i < 3; i++) if (MouseReleased(i)) wait = FALSE; return ReleasedInRange(x1, y1, x2, y2); }
static int FakeMousePress(struct Control* control) { int i, wait=TRUE, x, y, status; struct CommandButton* button = (struct CommandButton*)control->ControlData; ClearMouse(); DrawButton(control->posx+1, control->posy, button->len, control->forcolor, button->highcolor, button->caption, TRUE, FALSE); status = DOWN; while (wait) for (i = 0; i < GetNumSupportedButtons(); i++) if (MouseReleased(i)) wait = FALSE; else { WhereMouse(&x, &y); if ((x < control->posx) || (x > control->posx+button->len) || (y < control->posy) || (y > control->posy)) { if (status == DOWN) { status = UP; DrawButton(control->posx, control->posy, button->len, control->forcolor, button->highcolor, button->caption, TRUE, TRUE); } } else if (status == UP) { status = DOWN; DrawButton(control->posx+1, control->posy, button->len, control->forcolor, button->highcolor, button->caption, TRUE, FALSE); } } /* DrawButton(control->posx, control->posy, button->len, control->forcolor, button->highcolor, button->caption, TRUE, TRUE); */ return status == DOWN; }
int KW_ProcessEvents(KW_GUI * gui) { int i = 0; SDL_LockMutex(gui->evqueuelock); for (i = 0; i < gui->evqueuesize; i++) { SDL_Event * event = gui->evqueue + i; switch (event->type) { case SDL_MOUSEMOTION: MouseMoved(gui, event->motion.x, event->motion.y, event->motion.xrel, event->motion.yrel); break; case SDL_MOUSEBUTTONDOWN: MousePressed(gui, event->button.x, event->button.y, event->button.button); break; case SDL_MOUSEBUTTONUP: MouseReleased(gui, event->button.x, event->button.y, event->button.button); break; case SDL_TEXTINPUT: SDL_Log("Got a textready: %s\n", event->text.text); TextInputReady(gui, event->text.text); break; case SDL_TEXTEDITING: SDL_Log("Got a textediting: %d %d %d %s\n", event->edit.start, event->edit.length, event->edit.type, event->edit.text); break; case SDL_KEYDOWN: KeyDown(gui, event->key.keysym.sym, event->key.keysym.scancode); break; case SDL_KEYUP: KeyUp(gui, event->key.keysym.sym, event->key.keysym.scancode); break; default: break; } } gui->evqueuesize = 0; SDL_UnlockMutex(gui->evqueuelock); return 0; }
/***************************************************************************** * EventThread: Create video window & handle its messages ***************************************************************************** * This function creates a video window and then enters an infinite loop * that handles the messages sent to that window. * The main goal of this thread is to isolate the Win32 PeekMessage function * because this one can block for a long time. *****************************************************************************/ static void *EventThread( void *p_this ) { event_thread_t *p_event = (event_thread_t *)p_this; vout_display_t *vd = p_event->vd; MSG msg; POINT old_mouse_pos = {0,0}, mouse_pos; int canc = vlc_savecancel (); bool b_mouse_support = var_InheritBool( p_event->vd, "mouse-events" ); bool b_key_support = var_InheritBool( p_event->vd, "keyboard-events" ); vlc_mutex_lock( &p_event->lock ); /* Create a window for the video */ /* Creating a window under Windows also initializes the thread's event * message queue */ if( DirectXCreateWindow( p_event ) ) p_event->b_error = true; p_event->b_ready = true; vlc_cond_signal( &p_event->wait ); const bool b_error = p_event->b_error; vlc_mutex_unlock( &p_event->lock ); if( b_error ) { vlc_restorecancel( canc ); return NULL; } #ifndef UNDER_CE /* Prevent monitor from powering off */ SetThreadExecutionState( ES_DISPLAY_REQUIRED | ES_CONTINUOUS ); #endif /* Main loop */ /* GetMessage will sleep if there's no message in the queue */ for( ;; ) { vout_display_place_t place; video_format_t source; if( !GetMessage( &msg, 0, 0, 0 ) ) { vlc_mutex_lock( &p_event->lock ); p_event->b_done = true; vlc_mutex_unlock( &p_event->lock ); break; } /* Check if we are asked to exit */ vlc_mutex_lock( &p_event->lock ); const bool b_done = p_event->b_done; vlc_mutex_unlock( &p_event->lock ); if( b_done ) break; if( !b_mouse_support && isMouseEvent( msg.message ) ) continue; if( !b_key_support && isKeyEvent( msg.message ) ) continue; /* Handle mouse state */ if( msg.message == WM_MOUSEMOVE || msg.message == WM_NCMOUSEMOVE ) { GetCursorPos( &mouse_pos ); /* FIXME, why this >2 limits ? */ if( (abs(mouse_pos.x - old_mouse_pos.x) > 2 || (abs(mouse_pos.y - old_mouse_pos.y)) > 2 ) ) { old_mouse_pos = mouse_pos; UpdateCursor( p_event, true ); } } else if( isMouseEvent( msg.message ) ) { UpdateCursor( p_event, true ); } else if( msg.message == WM_VLC_HIDE_MOUSE ) { UpdateCursor( p_event, false ); } /* */ switch( msg.message ) { case WM_MOUSEMOVE: vlc_mutex_lock( &p_event->lock ); place = p_event->place; source = p_event->source; vlc_mutex_unlock( &p_event->lock ); if( place.width > 0 && place.height > 0 ) { if( msg.hwnd == p_event->hvideownd ) { /* Child window */ place.x = 0; place.y = 0; } const int x = source.i_x_offset + (int64_t)(GET_X_LPARAM(msg.lParam) - place.x) * source.i_width / place.width; const int y = source.i_y_offset + (int64_t)(GET_Y_LPARAM(msg.lParam) - place.y) * source.i_height / place.height; vout_display_SendEventMouseMoved(vd, x, y); } break; case WM_NCMOUSEMOVE: break; case WM_VLC_HIDE_MOUSE: break; case WM_LBUTTONDOWN: MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_LEFT ); break; case WM_LBUTTONUP: MouseReleased( p_event, MOUSE_BUTTON_LEFT ); break; case WM_LBUTTONDBLCLK: vout_display_SendEventMouseDoubleClick(vd); break; case WM_MBUTTONDOWN: MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_CENTER ); break; case WM_MBUTTONUP: MouseReleased( p_event, MOUSE_BUTTON_CENTER ); break; case WM_RBUTTONDOWN: MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_RIGHT ); break; case WM_RBUTTONUP: MouseReleased( p_event, MOUSE_BUTTON_RIGHT ); break; case WM_KEYDOWN: case WM_SYSKEYDOWN: { /* The key events are first processed here and not translated * into WM_CHAR events because we need to know the status of the * modifier keys. */ int i_key = DirectXConvertKey( msg.wParam ); if( !i_key ) { /* This appears to be a "normal" (ascii) key */ i_key = tolower( MapVirtualKey( msg.wParam, 2 ) ); } if( i_key ) { if( GetKeyState(VK_CONTROL) & 0x8000 ) { i_key |= KEY_MODIFIER_CTRL; } if( GetKeyState(VK_SHIFT) & 0x8000 ) { i_key |= KEY_MODIFIER_SHIFT; } if( GetKeyState(VK_MENU) & 0x8000 ) { i_key |= KEY_MODIFIER_ALT; } vout_display_SendEventKey(vd, i_key); } break; } case WM_MOUSEWHEEL: { int i_key; if( GET_WHEEL_DELTA_WPARAM( msg.wParam ) > 0 ) { i_key = KEY_MOUSEWHEELUP; } else { i_key = KEY_MOUSEWHEELDOWN; } if( i_key ) { if( GetKeyState(VK_CONTROL) & 0x8000 ) { i_key |= KEY_MODIFIER_CTRL; } if( GetKeyState(VK_SHIFT) & 0x8000 ) { i_key |= KEY_MODIFIER_SHIFT; } if( GetKeyState(VK_MENU) & 0x8000 ) { i_key |= KEY_MODIFIER_ALT; } vout_display_SendEventKey(vd, i_key); } break; } case WM_VLC_CHANGE_TEXT: { vlc_mutex_lock( &p_event->lock ); wchar_t *pwz_title = NULL; if( p_event->psz_title ) { const size_t i_length = strlen(p_event->psz_title); pwz_title = malloc( 2 * (i_length + 1) ); if( pwz_title ) { mbstowcs( pwz_title, p_event->psz_title, 2 * i_length ); pwz_title[i_length] = 0; } } vlc_mutex_unlock( &p_event->lock ); if( pwz_title ) { SetWindowTextW( p_event->hwnd, pwz_title ); if( p_event->hfswnd ) SetWindowTextW( p_event->hfswnd, pwz_title ); free( pwz_title ); } break; } default: /* Messages we don't handle directly are dispatched to the * window procedure */ TranslateMessage(&msg); DispatchMessage(&msg); break; } /* End Switch */ } /* End Main loop */ /* Check for WM_QUIT if we created the window */ if( !p_event->hparent && msg.message == WM_QUIT ) { msg_Warn( vd, "WM_QUIT... should not happen!!" ); p_event->hwnd = NULL; /* Window already destroyed */ } msg_Dbg( vd, "DirectXEventThread terminating" ); DirectXCloseWindow( p_event ); vlc_restorecancel(canc); return NULL; }
void ClickableLabel::mouseReleaseEvent ( QMouseEvent * event ) { emit MouseReleased(); // Erzeugt das Signal einer negativen Mausdruckflanke }
void C_Mod::loop() { continuer = true; click = keyboard = false; bool clickOnUI = false; sf::Clock camTimer; float previousX = 0, previousY = 0; sf::String str_fps; int compt_fps = 0; sf::Clock timer_fps; str_fps.SetScale(0.4f, 0.4f); str_fps.SetColor(sf::Color::White); str_fps.SetPosition(10, 10); _screen->PreserveOpenGLStates(true); while(continuer) { while(_screen->GetEvent(_event)) { ///EVENT if(_event.Type == sf::Event::Closed) continuer = false; else if(_event.Type == sf::Event::MouseButtonReleased && click) { click = false; float xxx = _screen->GetInput().GetMouseX(); float yyy = _screen->GetInput().GetMouseY(); for(unsigned int i=0;i<_widget.size();i++) _widget[i]->clicked(xxx, yyy); MouseReleased(); } else if(_event.Type == sf::Event::MouseButtonPressed) { click = true; clickOnUI = false; previousX = _screen->GetInput().GetMouseX(); previousY = _screen->GetInput().GetMouseY(); for(unsigned int i=0;i<_widget.size();i++) { if(_widget[i]->mouseOver(previousX, previousY)) { clickOnUI = true; break; } } if(!clickOnUI) _cam->SetMousePosition(previousX, previousY); MousePressed(); } else if(_event.Type == sf::Event::MouseMoved) { _cam->OnMouseMotion(_screen->GetInput().GetMouseX(), _screen->GetInput().GetMouseY()); _screen->SetCursorPosition(_screen->GetWidth()/2, _screen->GetHeight()/2); MouseMoved(); } else if(_event.Type == sf::Event::MouseWheelMoved) { MouseWheel(); _event.MouseWheel.Delta = 0; } else if(_event.Type == sf::Event::KeyPressed) { bool wigdetHasFocus = false; for(unsigned int i=0;i<_widget.size();i++) { if(_widget[i]->injectKey(_event.Key.Code, true)) { wigdetHasFocus = true; break; } } if(!wigdetHasFocus) { keyboard = true; _cam->OnKeyboard(_event); KeyPressed(); } } else if(_event.Type == sf::Event::KeyReleased) { for(unsigned int i=0;i<_widget.size();i++) _widget[i]->injectKey(_event.Key.Code, false); //if(keyboard) { keyboard = false; _cam->OnKeyboard(_event); KeyReleased(); } } } glDisable(GL_LIGHTING); _cam->animate(int(camTimer.GetElapsedTime()*10000)); camTimer.Reset(); TimerManagement(); ///DRAW _screen->SetActive(); if(click && !clickOnUI) _screen->SetCursorPosition(previousX, previousY); //_screen->GetWidth()/2, _screen->GetHeight()/2); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glViewport(0, 0, _screen->GetWidth(), _screen->GetHeight()); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(70, float(_screen->GetWidth()) / float(_screen->GetHeight()), 0.1f, 5000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); _skydome.Draw(); _cam->look(); glPushMatrix(); Draw(); glPopMatrix(); DrawUI(); if(timer_fps.GetElapsedTime() > 1.0f) { str_fps.SetText("FPS : "+IntToString(compt_fps)); compt_fps = 0; timer_fps.Reset(); } compt_fps++; _screen->Draw(str_fps); _screen->Display(); } }
static MRESULT EXPENTRY WndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { vout_display_t * vd = WinQueryWindowPtr( hwnd, 0 ); MRESULT result = ( MRESULT )TRUE; if ( !vd ) return WinDefWindowProc( hwnd, msg, mp1, mp2 ); vout_display_sys_t * sys = vd->sys; RECTL rcl; SWP swp; if ( sys->is_mouse_hidden && ((msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST) || (msg >= WM_EXTMOUSEFIRST && msg <= WM_EXTMOUSELAST) || msg == WM_MOUSELEAVE)) { WinShowPointer(HWND_DESKTOP, TRUE); sys->is_mouse_hidden = false; } switch( msg ) { /* the user wants to close the window */ case WM_CLOSE: vout_display_SendEventClose(vd); result = 0; break; case WM_MOUSEMOVE : { SHORT i_mouse_x = SHORT1FROMMP( mp1 ); SHORT i_mouse_y = SHORT2FROMMP( mp1 ); RECTL movie_rect; int i_movie_width, i_movie_height; int i_src_width, i_src_height; /* Get a current movie area */ kvaAdjustDstRect( &sys->kvas.rclSrcRect, &movie_rect ); i_movie_width = movie_rect.xRight - movie_rect.xLeft; i_movie_height = movie_rect.yTop - movie_rect.yBottom; i_src_width = sys->kvas.rclSrcRect.xRight - sys->kvas.rclSrcRect.xLeft; i_src_height = sys->kvas.rclSrcRect.yBottom - sys->kvas.rclSrcRect.yTop; int x = ( i_mouse_x - movie_rect.xLeft ) * i_src_width / i_movie_width + sys->kvas.rclSrcRect.xLeft; int y = ( i_mouse_y - movie_rect.yBottom ) * i_src_height / i_movie_height; /* Invert Y coordinate and add y offset */ y = ( i_src_height - y ) + sys->kvas.rclSrcRect.yTop;; vout_display_SendEventMouseMoved(vd, x, y); result = WinDefWindowProc( hwnd, msg, mp1,mp2 ); break; } case WM_BUTTON1DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_LEFT ); break; case WM_BUTTON2DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_RIGHT ); break; case WM_BUTTON3DOWN : MousePressed( vd, hwnd, MOUSE_BUTTON_CENTER ); break; case WM_BUTTON1UP : MouseReleased( vd, MOUSE_BUTTON_LEFT ); break; case WM_BUTTON2UP : MouseReleased( vd, MOUSE_BUTTON_RIGHT ); break; case WM_BUTTON3UP : MouseReleased( vd, MOUSE_BUTTON_CENTER ); break; case WM_BUTTON1DBLCLK : vout_display_SendEventMouseDoubleClick(vd); break; case WM_TRANSLATEACCEL : /* We have no accelerator table at all */ result = ( MRESULT )FALSE; break; case WM_CHAR : { USHORT i_flags = SHORT1FROMMP( mp1 ); USHORT i_ch = SHORT1FROMMP( mp2 ); USHORT i_vk = SHORT2FROMMP( mp2 ); int i_key = 0; /* If embedded window, let the parent process keys */ if( sys->parent_window ) { WinPostMsg( sys->parent, msg, mp1, mp2 ); break; } if( !( i_flags & KC_KEYUP )) { if( i_flags & KC_VIRTUALKEY ) /* convert the key if possible */ i_key = ConvertKey( i_vk ); else if(( i_flags & KC_CHAR ) && !HIBYTE( i_ch )) i_key = tolower( i_ch ); if( i_key ) { if( i_flags & KC_SHIFT ) i_key |= KEY_MODIFIER_SHIFT; if( i_flags & KC_CTRL ) i_key |= KEY_MODIFIER_CTRL; if( i_flags & KC_ALT ) i_key |= KEY_MODIFIER_ALT; vout_display_SendEventKey(vd, i_key); } } break; } /* Process Manage() call */ case WM_VLC_MANAGE : break; /* Fullscreen change */ case WM_VLC_FULLSCREEN_CHANGE : if( LONGFROMMP( mp1 )) { WinQueryWindowPos( sys->frame, &swp ); sys->client_rect.xLeft = swp.x; sys->client_rect.yBottom = swp.y; sys->client_rect.xRight = sys->client_rect.xLeft + swp.cx; sys->client_rect.yTop = sys->client_rect.yBottom + swp.cy; WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE ); rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = sys->i_screen_width; rcl.yTop = sys->i_screen_height; } else rcl = sys->client_rect; WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, HWND_TOP, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_MOVE | SWP_SIZE | SWP_ZORDER | SWP_SHOW | SWP_ACTIVATE ); break; /* Size change */ case WM_VLC_SIZE_CHANGE : rcl.xLeft = 0; rcl.yBottom = 0; rcl.xRight = LONGFROMMP( mp1 ); rcl.yTop = LONGFROMMP( mp2 ); WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, NULLHANDLE, 0, 0, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_SIZE ); WinQueryWindowPos( sys->frame, &swp ); sys->client_rect.xLeft = swp.x; sys->client_rect.yBottom = swp.y; sys->client_rect.xRight = sys->client_rect.xLeft + swp.cx; sys->client_rect.yTop = sys->client_rect.yBottom + swp.cy; WinCalcFrameRect( sys->frame, &sys->client_rect, TRUE ); break; default : return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } /* If embedded window, we need to change our window size according to a * parent window size */ if( sys->parent_window ) { WinQueryWindowRect( sys->parent, &rcl ); if( rcl.xLeft != sys->parent_rect.xLeft || rcl.yBottom != sys->parent_rect.yBottom || rcl.xRight != sys->parent_rect.xRight || rcl.yTop != sys->parent_rect.yTop) { sys->parent_rect = rcl; WinCalcFrameRect( sys->frame, &rcl, FALSE ); WinSetWindowPos( sys->frame, NULLHANDLE, rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft, rcl.yTop - rcl.yBottom, SWP_SIZE | SWP_MOVE ); } } return result; }
void GLScene::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) { emit MouseReleased(event); }