bump product version to 6.3.0.0.beta1
[LibreOffice.git] / avmedia / source / viewer / mediaevent_impl.cxx
blob100bb0d834666a7e531be61201795ce758b1bbb4
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 namespace avmedia { namespace priv {
30 MediaEventListenersImpl::MediaEventListenersImpl( vcl::Window& rEventWindow ) :
31 mpNotifyWindow( &rEventWindow )
36 MediaEventListenersImpl::~MediaEventListenersImpl()
41 void MediaEventListenersImpl::cleanUp()
43 Application::RemoveMouseAndKeyEvents( reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ) );
44 mpNotifyWindow = nullptr;
48 void SAL_CALL MediaEventListenersImpl::disposing( const css::lang::EventObject& )
53 void SAL_CALL MediaEventListenersImpl::keyPressed( const css::awt::KeyEvent& e )
55 const ::osl::MutexGuard aGuard( maMutex );
56 const SolarMutexGuard aAppGuard;
58 if( mpNotifyWindow )
60 vcl::KeyCode aVCLKeyCode( e.KeyCode,
61 ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) |
62 ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) |
63 ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) );
64 KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode );
66 Application::PostKeyEvent( VclEventId::WindowKeyInput, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLKeyEvt );
71 void SAL_CALL MediaEventListenersImpl::keyReleased( const css::awt::KeyEvent& e )
73 const ::osl::MutexGuard aGuard( maMutex );
74 const SolarMutexGuard aAppGuard;
76 if( mpNotifyWindow )
78 vcl::KeyCode aVCLKeyCode( e.KeyCode,
79 ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) |
80 ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) |
81 ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) );
82 KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode );
83 Application::PostKeyEvent( VclEventId::WindowKeyUp, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLKeyEvt );
88 void SAL_CALL MediaEventListenersImpl::mousePressed( const css::awt::MouseEvent& e )
90 const ::osl::MutexGuard aGuard( maMutex );
91 const SolarMutexGuard aAppGuard;
93 if( mpNotifyWindow )
95 MouseEvent aVCLMouseEvt( Point( e.X, e.Y ),
96 sal::static_int_cast< sal_uInt16 >(e.ClickCount),
97 MouseEventModifiers::NONE,
98 ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) |
99 ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) |
100 ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ),
101 e.Modifiers );
102 Application::PostMouseEvent( VclEventId::WindowMouseButtonDown, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLMouseEvt );
107 void SAL_CALL MediaEventListenersImpl::mouseReleased( const css::awt::MouseEvent& e )
109 const ::osl::MutexGuard aGuard( maMutex );
110 const SolarMutexGuard aAppGuard;
112 if( mpNotifyWindow )
114 MouseEvent aVCLMouseEvt( Point( e.X, e.Y ),
115 sal::static_int_cast< sal_uInt16 >(e.ClickCount),
116 MouseEventModifiers::NONE,
117 ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) |
118 ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) |
119 ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ),
120 e.Modifiers );
121 Application::PostMouseEvent( VclEventId::WindowMouseButtonUp, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLMouseEvt );
126 void SAL_CALL MediaEventListenersImpl::mouseEntered( const css::awt::MouseEvent& )
131 void SAL_CALL MediaEventListenersImpl::mouseExited( const css::awt::MouseEvent& )
136 void SAL_CALL MediaEventListenersImpl::mouseDragged( const css::awt::MouseEvent& e )
138 const ::osl::MutexGuard aGuard( maMutex );
139 const SolarMutexGuard aAppGuard;
141 if( mpNotifyWindow )
143 MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, MouseEventModifiers::NONE, e.Buttons, e.Modifiers );
144 Application::PostMouseEvent( VclEventId::WindowMouseMove, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLMouseEvt );
149 void SAL_CALL MediaEventListenersImpl::mouseMoved( const css::awt::MouseEvent& e )
151 const ::osl::MutexGuard aGuard( maMutex );
152 const SolarMutexGuard aAppGuard;
154 if( mpNotifyWindow )
156 MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, MouseEventModifiers::NONE, e.Buttons, e.Modifiers );
157 Application::PostMouseEvent( VclEventId::WindowMouseMove, reinterpret_cast< vcl::Window* >( mpNotifyWindow.get() ), &aVCLMouseEvt );
162 void SAL_CALL MediaEventListenersImpl::focusGained( const css::awt::FocusEvent& )
167 void SAL_CALL MediaEventListenersImpl::focusLost( const css::awt::FocusEvent& )
172 } // namespace priv
173 } // namespace avmedia
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */