Skip to content

Commit 3569d08

Browse files
committed
GPU Wayland Display: Fix handling of F keys
1 parent 33d7caf commit 3569d08

4 files changed

Lines changed: 44 additions & 23 deletions

File tree

‎GPU/GPUTracking/display/CMakeLists.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ if(GPUCA_EVENT_DISPLAY_WAYLAND)
167167
list(APPEND WAYLAND_PROTOCOL_SOURCES ${source})
168168
endforeach()
169169

170-
set_property(SOURCE frontend/GPUDisplayFrontendWayland.cxx ${WAYLAND_PROTOCOL_SOURCES} APPEND PROPERTY OBJECT_DEPENDS ${WAYLAND_PROTOCOL_HEADERS})
171-
set_property(SOURCE frontend/GPUDisplayFrontendWayland.cxx APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/)
170+
set_property(SOURCE frontend/GPUDisplayFrontendWayland.cxx frontend/GPUDisplayFrontendWaylandEv.cxx ${WAYLAND_PROTOCOL_SOURCES} APPEND PROPERTY OBJECT_DEPENDS ${WAYLAND_PROTOCOL_HEADERS})
171+
set_property(SOURCE frontend/GPUDisplayFrontendWayland.cxx frontend/GPUDisplayFrontendWaylandEv.cxx APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR}/xdg-gen/)
172172

173-
set(SRCS_NO_H ${SRCS_NO_H} frontend/GPUDisplayFrontendWayland.cxx ${WAYLAND_PROTOCOL_SOURCES})
173+
set(SRCS_NO_H ${SRCS_NO_H} frontend/GPUDisplayFrontendWayland.cxx frontend/GPUDisplayFrontendWaylandEv.cxx ${WAYLAND_PROTOCOL_SOURCES})
174174
endif()
175175

176176
if(X11_FOUND)

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.cxx‎

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "viewporter-client-protocol.h"
3939
#include "cursor-shape-client-protocol.h"
4040
#include <xkbcommon/xkbcommon.h>
41-
#include <linux/input-event-codes.h>
4241

4342
using namespace o2::gpu;
4443

@@ -95,7 +94,7 @@ int32_t GPUDisplayFrontendWayland::GetKey(uint32_t key, uint32_t state)
9594
return (KEY_HOME);
9695
} else if (sym == XKB_KEY_Insert) {
9796
return (KEY_INSERT);
98-
} else if (sym == XKB_KEY_F1) { // TODO: Fix F* keys not working
97+
} else if (sym == XKB_KEY_F1) {
9998
return (KEY_F1);
10099
} else if (sym == XKB_KEY_F2) {
101100
return (KEY_F2);
@@ -174,24 +173,8 @@ int32_t GPUDisplayFrontendWayland::FrontendMain()
174173
};
175174
auto pointer_button = [](void* data, wl_pointer* wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) {
176175
GPUDisplayFrontendWayland* me = (GPUDisplayFrontendWayland*)data;
177-
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
178-
if (button == BTN_RIGHT) {
179-
me->mMouseDnR = true;
180-
} else if (button == BTN_LEFT) {
181-
me->mMouseDn = true;
182-
} else if (button == BTN_MIDDLE) {
183-
me->mMouseDnM = true;
184-
}
185-
me->mMouseDnX = me->mMouseMvX;
186-
me->mMouseDnY = me->mMouseMvY;
187-
} else if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
188-
if (button == BTN_RIGHT) {
189-
me->mMouseDnR = false;
190-
} else if (button == BTN_LEFT) {
191-
me->mMouseDn = false;
192-
} else if (button == BTN_MIDDLE) {
193-
me->mMouseDnM = false;
194-
}
176+
if (state == WL_POINTER_BUTTON_STATE_PRESSED || state == WL_POINTER_BUTTON_STATE_RELEASED) {
177+
me->handlePointerButton(button, state == WL_POINTER_BUTTON_STATE_PRESSED);
195178
}
196179
};
197180
auto pointer_frame = [](void* data, wl_pointer* wl_pointer) { ((GPUDisplayFrontendWayland*)data)->applyScroll(); };

‎GPU/GPUTracking/display/frontend/GPUDisplayFrontendWayland.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class GPUDisplayFrontendWayland : public GPUDisplayFrontend
5252

5353
private:
5454
int32_t FrontendMain() override;
55+
void handlePointerButton(uint32_t button, bool pressed); // In GPUDisplayFrontendWaylandEv.cxx, which needs the evdev button codes
5556
int32_t GetKey(uint32_t key, uint32_t state);
5657
void updateScale(); // Scale from wp_fractional_scale_v1, else integer wl_surface.preferred_buffer_scale, or max scale of the outputs the surface is on (older compositors)
5758
void updateSize(); // Physical size = logical size * scale, resizes the scene if changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file GPUDisplayFrontendWaylandEv.cxx
13+
/// \author David Rohr
14+
15+
// Functions of the Wayland frontend that need the evdev codes from linux/input-event-codes.h.
16+
// That header defines macros KEY_UP, KEY_F1, ..., which replace GPUDisplayFrontend::KEY_* (e.g. KEY_F1 becomes 59 = ';'), so it must not be included in GPUDisplayFrontendWayland.cxx,
17+
// and here only after all other headers, and the functions in this file must not use GPUDisplayFrontend::KEY_*.
18+
19+
#include "GPUDisplayFrontendWayland.h"
20+
#include <linux/input-event-codes.h>
21+
22+
using namespace o2::gpu;
23+
24+
void GPUDisplayFrontendWayland::handlePointerButton(uint32_t button, bool pressed)
25+
{
26+
if (button == BTN_RIGHT) {
27+
mMouseDnR = pressed;
28+
} else if (button == BTN_LEFT) {
29+
mMouseDn = pressed;
30+
} else if (button == BTN_MIDDLE) {
31+
mMouseDnM = pressed;
32+
}
33+
if (pressed) {
34+
mMouseDnX = mMouseMvX;
35+
mMouseDnY = mMouseMvY;
36+
}
37+
}

0 commit comments

Comments
 (0)