fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / avmedia / source / viewer / mediaevent_impl.cxx
blob3bc52470afcc7ea252eb1160d37c104e6d989111
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "mediaevent_impl.hxx"
21 #include "mediawindow_impl.hxx"
22 #include <osl/mutex.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/event.hxx>
26 using namespace ::com::sun::star;
28 /* Definition of MediaWindowImpl class */
30 namespace avmedia { namespace priv {
31 // ---------------------------
32 // - MediaEventListenersImpl -
33 // ---------------------------
35 MediaEventListenersImpl::MediaEventListenersImpl( Window& rEventWindow ) :
36 mpNotifyWindow( &rEventWindow )
40 // ---------------------------------------------------------------------
42 MediaEventListenersImpl::~MediaEventListenersImpl()
46 // ---------------------------------------------------------------------
48 void MediaEventListenersImpl::cleanUp()
50 Application::RemoveMouseAndKeyEvents( reinterpret_cast< ::Window* >( mpNotifyWindow ) );
51 mpNotifyWindow = NULL;
54 // ---------------------------------------------------------------------
56 void SAL_CALL MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
57 throw (::com::sun::star::uno::RuntimeException)
61 // ---------------------------------------------------------------------
63 void SAL_CALL MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent& e )
64 throw (::com::sun::star::uno::RuntimeException)
66 const ::osl::MutexGuard aGuard( maMutex );
67 const SolarMutexGuard aAppGuard;
69 if( mpNotifyWindow )
71 KeyCode aVCLKeyCode( e.KeyCode,
72 ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) |
73 ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) |
74 ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) );
75 KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode );
77 Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt );
81 // ---------------------------------------------------------------------
83 void SAL_CALL MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent& e )
84 throw (::com::sun::star::uno::RuntimeException)
86 const ::osl::MutexGuard aGuard( maMutex );
87 const SolarMutexGuard aAppGuard;
89 if( mpNotifyWindow )
91 KeyCode aVCLKeyCode( e.KeyCode,
92 ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) |
93 ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) |
94 ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) );
95 KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode );
96 Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLKeyEvt );
100 // ---------------------------------------------------------------------
102 void SAL_CALL MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent& e )
103 throw (::com::sun::star::uno::RuntimeException)
105 const ::osl::MutexGuard aGuard( maMutex );
106 const SolarMutexGuard aAppGuard;
108 if( mpNotifyWindow )
110 MouseEvent aVCLMouseEvt( Point( e.X, e.Y ),
111 sal::static_int_cast< sal_uInt16 >(e.ClickCount),
113 ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) |
114 ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) |
115 ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ),
116 e.Modifiers );
117 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt );
121 // ----------------------------------------------gvd-----------------------
123 void SAL_CALL MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent& e )
124 throw (::com::sun::star::uno::RuntimeException)
126 const ::osl::MutexGuard aGuard( maMutex );
127 const SolarMutexGuard aAppGuard;
129 if( mpNotifyWindow )
131 MouseEvent aVCLMouseEvt( Point( e.X, e.Y ),
132 sal::static_int_cast< sal_uInt16 >(e.ClickCount),
134 ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) |
135 ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) |
136 ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ),
137 e.Modifiers );
138 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt );
142 // ---------------------------------------------------------------------
144 void SAL_CALL MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent& /* e */ )
145 throw (::com::sun::star::uno::RuntimeException)
147 const ::osl::MutexGuard aGuard( maMutex );
148 const SolarMutexGuard aAppGuard;
150 if( mpNotifyWindow )
155 // ---------------------------------------------------------------------
157 void SAL_CALL MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent& /* e */ )
158 throw (::com::sun::star::uno::RuntimeException)
160 const ::osl::MutexGuard aGuard( maMutex );
161 const SolarMutexGuard aAppGuard;
163 if( mpNotifyWindow )
168 // ---------------------------------------------------------------------
170 void SAL_CALL MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent& e )
171 throw (::com::sun::star::uno::RuntimeException)
173 const ::osl::MutexGuard aGuard( maMutex );
174 const SolarMutexGuard aAppGuard;
176 if( mpNotifyWindow )
178 MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers );
179 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt );
183 // ---------------------------------------------------------------------
185 void SAL_CALL MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent& e )
186 throw (::com::sun::star::uno::RuntimeException)
188 const ::osl::MutexGuard aGuard( maMutex );
189 const SolarMutexGuard aAppGuard;
191 if( mpNotifyWindow )
193 MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, 0, e.Buttons, e.Modifiers );
194 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE, reinterpret_cast< ::Window* >( mpNotifyWindow ), &aVCLMouseEvt );
198 // ---------------------------------------------------------------------
200 void SAL_CALL MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent& /* e */ )
201 throw (::com::sun::star::uno::RuntimeException)
205 // ---------------------------------------------------------------------
207 void SAL_CALL MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent& /* e */ )
208 throw (::com::sun::star::uno::RuntimeException)
212 } // namespace priv
213 } // namespace avemdia
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */