1*f39251c4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f39251c4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f39251c4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f39251c4SAndrew Rist * distributed with this work for additional information 6*f39251c4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f39251c4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f39251c4SAndrew Rist * "License"); you may not use this file except in compliance 9*f39251c4SAndrew Rist * with the License. You may obtain a copy of the License at 10*f39251c4SAndrew Rist * 11*f39251c4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f39251c4SAndrew Rist * 13*f39251c4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f39251c4SAndrew Rist * software distributed under the License is distributed on an 15*f39251c4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f39251c4SAndrew Rist * KIND, either express or implied. See the License for the 17*f39251c4SAndrew Rist * specific language governing permissions and limitations 18*f39251c4SAndrew Rist * under the License. 19*f39251c4SAndrew Rist * 20*f39251c4SAndrew Rist *************************************************************/ 21*f39251c4SAndrew Rist 22*f39251c4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "mediaevent_impl.hxx" 25cdf0e10cSrcweir #include "mediawindow_impl.hxx" 26cdf0e10cSrcweir #include <osl/mutex.hxx> 27cdf0e10cSrcweir #include <vos/mutex.hxx> 28cdf0e10cSrcweir #include <vcl/svapp.hxx> 29cdf0e10cSrcweir #include <vcl/event.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir using namespace ::com::sun::star; 32cdf0e10cSrcweir 33cdf0e10cSrcweir /* Definition of MediaWindowImpl class */ 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace avmedia { namespace priv { 36cdf0e10cSrcweir // --------------------------- 37cdf0e10cSrcweir // - MediaEventListenersImpl - 38cdf0e10cSrcweir // --------------------------- 39cdf0e10cSrcweir 40cdf0e10cSrcweir MediaEventListenersImpl::MediaEventListenersImpl( Window& rEventWindow ) : 41cdf0e10cSrcweir mpNotifyWindow( &rEventWindow ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir } 44cdf0e10cSrcweir 45cdf0e10cSrcweir // --------------------------------------------------------------------- 46cdf0e10cSrcweir 47cdf0e10cSrcweir MediaEventListenersImpl::~MediaEventListenersImpl() 48cdf0e10cSrcweir { 49cdf0e10cSrcweir } 50cdf0e10cSrcweir 51cdf0e10cSrcweir // --------------------------------------------------------------------- 52cdf0e10cSrcweir 53cdf0e10cSrcweir void MediaEventListenersImpl::cleanUp() 54cdf0e10cSrcweir { 55cdf0e10cSrcweir Application::RemoveMouseAndKeyEvents( reinterpret_cast< ::Window* >( mpNotifyWindow ) ); 56cdf0e10cSrcweir mpNotifyWindow = NULL; 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir // --------------------------------------------------------------------- 60cdf0e10cSrcweir 61cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject& /* Source */ ) 62cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir // --------------------------------------------------------------------- 67cdf0e10cSrcweir 68cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent& e ) 69cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 72cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir if( mpNotifyWindow ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir KeyCode aVCLKeyCode( e.KeyCode, 77cdf0e10cSrcweir ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | 78cdf0e10cSrcweir ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | 79cdf0e10cSrcweir ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); 80cdf0e10cSrcweir KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir // --------------------------------------------------------------------- 87cdf0e10cSrcweir 88cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent& e ) 89cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 92cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir if( mpNotifyWindow ) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir KeyCode aVCLKeyCode( e.KeyCode, 97cdf0e10cSrcweir ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | 98cdf0e10cSrcweir ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | 99cdf0e10cSrcweir ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); 100cdf0e10cSrcweir KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); 101cdf0e10cSrcweir Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir // --------------------------------------------------------------------- 106cdf0e10cSrcweir 107cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent& e ) 108cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 111cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 112cdf0e10cSrcweir 113cdf0e10cSrcweir if( mpNotifyWindow ) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 116cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(e.ClickCount), 117cdf0e10cSrcweir 0, 118cdf0e10cSrcweir ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | 119cdf0e10cSrcweir ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | 120cdf0e10cSrcweir ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), 121cdf0e10cSrcweir e.Modifiers ); 122cdf0e10cSrcweir Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); 123cdf0e10cSrcweir } 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir // ----------------------------------------------gvd----------------------- 127cdf0e10cSrcweir 128cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent& e ) 129cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 132cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 133cdf0e10cSrcweir 134cdf0e10cSrcweir if( mpNotifyWindow ) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 137cdf0e10cSrcweir sal::static_int_cast< sal_uInt16 >(e.ClickCount), 138cdf0e10cSrcweir 0, 139cdf0e10cSrcweir ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | 140cdf0e10cSrcweir ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | 141cdf0e10cSrcweir ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), 142cdf0e10cSrcweir e.Modifiers ); 143cdf0e10cSrcweir Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir // --------------------------------------------------------------------- 148cdf0e10cSrcweir 149cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent& /* e */ ) 150cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 153cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir if( mpNotifyWindow ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir } 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir // --------------------------------------------------------------------- 161cdf0e10cSrcweir 162cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent& /* e */ ) 163cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 166cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 167cdf0e10cSrcweir 168cdf0e10cSrcweir if( mpNotifyWindow ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir } 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir // --------------------------------------------------------------------- 174cdf0e10cSrcweir 175cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent& e ) 176cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 179cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir if( mpNotifyWindow ) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers ); 184cdf0e10cSrcweir Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir } 187cdf0e10cSrcweir 188cdf0e10cSrcweir // --------------------------------------------------------------------- 189cdf0e10cSrcweir 190cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent& e ) 191cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir const ::osl::MutexGuard aGuard( maMutex ); 194cdf0e10cSrcweir const ::vos::OGuard aAppGuard( Application::GetSolarMutex() ); 195cdf0e10cSrcweir 196cdf0e10cSrcweir if( mpNotifyWindow ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers ); 199cdf0e10cSrcweir Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt ); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir // --------------------------------------------------------------------- 204cdf0e10cSrcweir 205cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent& /* e */ ) 206cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir // --------------------------------------------------------------------- 211cdf0e10cSrcweir 212cdf0e10cSrcweir void SAL_CALL MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent& /* e */ ) 213cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir } // namespace priv 218cdf0e10cSrcweir } // namespace avemdia 219cdf0e10cSrcweir 220