/src/libreoffice/avmedia/source/viewer/mediaevent_impl.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include "mediaevent_impl.hxx" |
21 | | #include <vcl/svapp.hxx> |
22 | | #include <vcl/event.hxx> |
23 | | #include <vcl/vclevent.hxx> |
24 | | #include <vcl/window.hxx> |
25 | | |
26 | | using namespace ::com::sun::star; |
27 | | |
28 | | namespace avmedia::priv { |
29 | | |
30 | | MediaEventListenersImpl::MediaEventListenersImpl( vcl::Window& rEventWindow ) : |
31 | 0 | mpNotifyWindow( &rEventWindow ) |
32 | 0 | { |
33 | 0 | } |
34 | | |
35 | | |
36 | | MediaEventListenersImpl::~MediaEventListenersImpl() |
37 | 0 | { |
38 | 0 | } |
39 | | |
40 | | |
41 | | void MediaEventListenersImpl::cleanUp() |
42 | 0 | { |
43 | 0 | Application::RemoveMouseAndKeyEvents( mpNotifyWindow.get() ); |
44 | 0 | mpNotifyWindow = nullptr; |
45 | 0 | } |
46 | | |
47 | | |
48 | | void SAL_CALL MediaEventListenersImpl::disposing( const css::lang::EventObject& ) |
49 | 0 | { |
50 | 0 | } |
51 | | |
52 | | |
53 | | void SAL_CALL MediaEventListenersImpl::keyPressed( const css::awt::KeyEvent& e ) |
54 | 0 | { |
55 | 0 | const std::unique_lock aGuard( maMutex ); |
56 | |
|
57 | 0 | if( mpNotifyWindow ) |
58 | 0 | { |
59 | 0 | vcl::KeyCode aVCLKeyCode( e.KeyCode, |
60 | 0 | ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | |
61 | 0 | ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | |
62 | 0 | ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); |
63 | 0 | KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); |
64 | |
|
65 | 0 | Application::PostKeyEvent( VclEventId::WindowKeyInput, mpNotifyWindow.get(), &aVCLKeyEvt ); |
66 | 0 | } |
67 | 0 | } |
68 | | |
69 | | |
70 | | void SAL_CALL MediaEventListenersImpl::keyReleased( const css::awt::KeyEvent& e ) |
71 | 0 | { |
72 | 0 | const std::unique_lock aGuard( maMutex ); |
73 | |
|
74 | 0 | if( mpNotifyWindow ) |
75 | 0 | { |
76 | 0 | vcl::KeyCode aVCLKeyCode( e.KeyCode, |
77 | 0 | ( ( e.Modifiers & 1 ) ? KEY_SHIFT : 0 ) | |
78 | 0 | ( ( e.Modifiers & 2 ) ? KEY_MOD1 : 0 ) | |
79 | 0 | ( ( e.Modifiers & 4 ) ? KEY_MOD2 : 0 ) ); |
80 | 0 | KeyEvent aVCLKeyEvt( e.KeyChar, aVCLKeyCode ); |
81 | 0 | Application::PostKeyEvent( VclEventId::WindowKeyUp, mpNotifyWindow.get(), &aVCLKeyEvt ); |
82 | 0 | } |
83 | 0 | } |
84 | | |
85 | | |
86 | | void SAL_CALL MediaEventListenersImpl::mousePressed( const css::awt::MouseEvent& e ) |
87 | 0 | { |
88 | 0 | const std::unique_lock aGuard( maMutex ); |
89 | |
|
90 | 0 | if( mpNotifyWindow ) |
91 | 0 | { |
92 | 0 | MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), |
93 | 0 | sal::static_int_cast< sal_uInt16 >(e.ClickCount), |
94 | 0 | MouseEventModifiers::NONE, |
95 | 0 | ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | |
96 | 0 | ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | |
97 | 0 | ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), |
98 | 0 | e.Modifiers ); |
99 | 0 | Application::PostMouseEvent( VclEventId::WindowMouseButtonDown, mpNotifyWindow.get(), &aVCLMouseEvt ); |
100 | 0 | } |
101 | 0 | } |
102 | | |
103 | | |
104 | | void SAL_CALL MediaEventListenersImpl::mouseReleased( const css::awt::MouseEvent& e ) |
105 | 0 | { |
106 | 0 | const std::unique_lock aGuard( maMutex ); |
107 | 0 | const SolarMutexGuard aAppGuard; |
108 | |
|
109 | 0 | if( mpNotifyWindow ) |
110 | 0 | { |
111 | 0 | MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), |
112 | 0 | sal::static_int_cast< sal_uInt16 >(e.ClickCount), |
113 | 0 | MouseEventModifiers::NONE, |
114 | 0 | ( ( e.Buttons & 1 ) ? MOUSE_LEFT : 0 ) | |
115 | 0 | ( ( e.Buttons & 2 ) ? MOUSE_RIGHT : 0 ) | |
116 | 0 | ( ( e.Buttons & 4 ) ? MOUSE_MIDDLE : 0 ), |
117 | 0 | e.Modifiers ); |
118 | 0 | Application::PostMouseEvent( VclEventId::WindowMouseButtonUp, mpNotifyWindow.get(), &aVCLMouseEvt ); |
119 | 0 | } |
120 | 0 | } |
121 | | |
122 | | |
123 | | void SAL_CALL MediaEventListenersImpl::mouseEntered( const css::awt::MouseEvent& ) |
124 | 0 | { |
125 | 0 | } |
126 | | |
127 | | |
128 | | void SAL_CALL MediaEventListenersImpl::mouseExited( const css::awt::MouseEvent& ) |
129 | 0 | { |
130 | 0 | } |
131 | | |
132 | | |
133 | | void SAL_CALL MediaEventListenersImpl::mouseDragged( const css::awt::MouseEvent& e ) |
134 | 0 | { |
135 | 0 | const std::unique_lock aGuard( maMutex ); |
136 | |
|
137 | 0 | if( mpNotifyWindow ) |
138 | 0 | { |
139 | 0 | MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, MouseEventModifiers::NONE, e.Buttons, e.Modifiers ); |
140 | 0 | Application::PostMouseEvent( VclEventId::WindowMouseMove, mpNotifyWindow.get(), &aVCLMouseEvt ); |
141 | 0 | } |
142 | 0 | } |
143 | | |
144 | | |
145 | | void SAL_CALL MediaEventListenersImpl::mouseMoved( const css::awt::MouseEvent& e ) |
146 | 0 | { |
147 | 0 | const std::unique_lock aGuard( maMutex ); |
148 | |
|
149 | 0 | if( mpNotifyWindow ) |
150 | 0 | { |
151 | 0 | MouseEvent aVCLMouseEvt( Point( e.X, e.Y ), 0, MouseEventModifiers::NONE, e.Buttons, e.Modifiers ); |
152 | 0 | Application::PostMouseEvent( VclEventId::WindowMouseMove, mpNotifyWindow.get(), &aVCLMouseEvt ); |
153 | 0 | } |
154 | 0 | } |
155 | | |
156 | | |
157 | | void SAL_CALL MediaEventListenersImpl::focusGained( const css::awt::FocusEvent& ) |
158 | 0 | { |
159 | 0 | } |
160 | | |
161 | | |
162 | | void SAL_CALL MediaEventListenersImpl::focusLost( const css::awt::FocusEvent& ) |
163 | 0 | { |
164 | 0 | } |
165 | | |
166 | | |
167 | | } // namespace |
168 | | |
169 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |