1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 namespace avmedia
{ namespace priv
{
30 // - MediaEventListenersImpl -
33 MediaEventListenersImpl::MediaEventListenersImpl( vcl::Window
& rEventWindow
) :
34 mpNotifyWindow( &rEventWindow
)
40 MediaEventListenersImpl::~MediaEventListenersImpl()
46 void MediaEventListenersImpl::cleanUp()
48 Application::RemoveMouseAndKeyEvents( reinterpret_cast< vcl::Window
* >( mpNotifyWindow
.get() ) );
49 mpNotifyWindow
= NULL
;
54 void SAL_CALL
MediaEventListenersImpl::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
55 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
61 void SAL_CALL
MediaEventListenersImpl::keyPressed( const ::com::sun::star::awt::KeyEvent
& e
)
62 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
64 const ::osl::MutexGuard
aGuard( maMutex
);
65 const SolarMutexGuard aAppGuard
;
69 vcl::KeyCode
aVCLKeyCode( e
.KeyCode
,
70 ( ( e
.Modifiers
& 1 ) ? KEY_SHIFT
: 0 ) |
71 ( ( e
.Modifiers
& 2 ) ? KEY_MOD1
: 0 ) |
72 ( ( e
.Modifiers
& 4 ) ? KEY_MOD2
: 0 ) );
73 KeyEvent
aVCLKeyEvt( e
.KeyChar
, aVCLKeyCode
);
75 Application::PostKeyEvent( VCLEVENT_WINDOW_KEYINPUT
, reinterpret_cast< vcl::Window
* >( mpNotifyWindow
.get() ), &aVCLKeyEvt
);
81 void SAL_CALL
MediaEventListenersImpl::keyReleased( const ::com::sun::star::awt::KeyEvent
& e
)
82 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
84 const ::osl::MutexGuard
aGuard( maMutex
);
85 const SolarMutexGuard aAppGuard
;
89 vcl::KeyCode
aVCLKeyCode( e
.KeyCode
,
90 ( ( e
.Modifiers
& 1 ) ? KEY_SHIFT
: 0 ) |
91 ( ( e
.Modifiers
& 2 ) ? KEY_MOD1
: 0 ) |
92 ( ( e
.Modifiers
& 4 ) ? KEY_MOD2
: 0 ) );
93 KeyEvent
aVCLKeyEvt( e
.KeyChar
, aVCLKeyCode
);
94 Application::PostKeyEvent( VCLEVENT_WINDOW_KEYUP
, reinterpret_cast< vcl::Window
* >( mpNotifyWindow
.get() ), &aVCLKeyEvt
);
100 void SAL_CALL
MediaEventListenersImpl::mousePressed( const ::com::sun::star::awt::MouseEvent
& e
)
101 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
103 const ::osl::MutexGuard
aGuard( maMutex
);
104 const SolarMutexGuard aAppGuard
;
108 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
),
109 sal::static_int_cast
< sal_uInt16
>(e
.ClickCount
),
110 MouseEventModifiers::NONE
,
111 ( ( e
.Buttons
& 1 ) ? MOUSE_LEFT
: 0 ) |
112 ( ( e
.Buttons
& 2 ) ? MOUSE_RIGHT
: 0 ) |
113 ( ( e
.Buttons
& 4 ) ? MOUSE_MIDDLE
: 0 ),
115 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONDOWN
, reinterpret_cast< vcl::Window
* >( mpNotifyWindow
.get() ), &aVCLMouseEvt
);
119 // ----------------------------------------------gvd-----------------------
121 void SAL_CALL
MediaEventListenersImpl::mouseReleased( const ::com::sun::star::awt::MouseEvent
& e
)
122 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
124 const ::osl::MutexGuard
aGuard( maMutex
);
125 const SolarMutexGuard aAppGuard
;
129 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
),
130 sal::static_int_cast
< sal_uInt16
>(e
.ClickCount
),
131 MouseEventModifiers::NONE
,
132 ( ( e
.Buttons
& 1 ) ? MOUSE_LEFT
: 0 ) |
133 ( ( e
.Buttons
& 2 ) ? MOUSE_RIGHT
: 0 ) |
134 ( ( e
.Buttons
& 4 ) ? MOUSE_MIDDLE
: 0 ),
136 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEBUTTONUP
, reinterpret_cast< vcl::Window
* >( mpNotifyWindow
.get() ), &aVCLMouseEvt
);
142 void SAL_CALL
MediaEventListenersImpl::mouseEntered( const ::com::sun::star::awt::MouseEvent
& /* e */ )
143 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
145 const ::osl::MutexGuard
aGuard( maMutex
);
146 const SolarMutexGuard aAppGuard
;
155 void SAL_CALL
MediaEventListenersImpl::mouseExited( const ::com::sun::star::awt::MouseEvent
& /* e */ )
156 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
158 const ::osl::MutexGuard
aGuard( maMutex
);
159 const SolarMutexGuard aAppGuard
;
168 void SAL_CALL
MediaEventListenersImpl::mouseDragged( const ::com::sun::star::awt::MouseEvent
& e
)
169 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
171 const ::osl::MutexGuard
aGuard( maMutex
);
172 const SolarMutexGuard aAppGuard
;
176 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
), 0, MouseEventModifiers::NONE
, e
.Buttons
, e
.Modifiers
);
177 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE
, reinterpret_cast< vcl::Window
* >( mpNotifyWindow
.get() ), &aVCLMouseEvt
);
183 void SAL_CALL
MediaEventListenersImpl::mouseMoved( const ::com::sun::star::awt::MouseEvent
& e
)
184 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
186 const ::osl::MutexGuard
aGuard( maMutex
);
187 const SolarMutexGuard aAppGuard
;
191 MouseEvent
aVCLMouseEvt( Point( e
.X
, e
.Y
), 0, MouseEventModifiers::NONE
, e
.Buttons
, e
.Modifiers
);
192 Application::PostMouseEvent( VCLEVENT_WINDOW_MOUSEMOVE
, reinterpret_cast< vcl::Window
* >( mpNotifyWindow
.get() ), &aVCLMouseEvt
);
198 void SAL_CALL
MediaEventListenersImpl::focusGained( const ::com::sun::star::awt::FocusEvent
& /* e */ )
199 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
205 void SAL_CALL
MediaEventListenersImpl::focusLost( const ::com::sun::star::awt::FocusEvent
& /* e */ )
206 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
211 } // namespace avemdia
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */