Skip to content

Commit

Permalink
JBR-5678: Refactor Wayland keyboard support
Browse files Browse the repository at this point in the history
  • Loading branch information
tsarn authored and jbrbot committed Nov 8, 2024
1 parent c0247ea commit 070ec5b
Show file tree
Hide file tree
Showing 17 changed files with 3,245 additions and 1,623 deletions.
12 changes: 12 additions & 0 deletions src/java.desktop/share/native/libwakefield/protocol/wakefield.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@
<arg name="amount" type="int" />
</request>

<request name="set_xkb_rule_names">
<description summary="facilitates switching keyboard layouts">
This requests the compositor to load the specified XKB layout and use it in all
further keyboard handling.
</description>
<arg name="rules" type="string" />
<arg name="model" type="string" />
<arg name="layout" type="string" />
<arg name="variant" type="string" />
<arg name="options" type="string" />
</request>

<enum name="error">
<entry name="no_error" value="0" summary="error code 0 reserved for the absence of error"/>
<entry name="invalid_coordinates" value="1" summary="supplied absolute coordinates point
Expand Down
157 changes: 89 additions & 68 deletions src/java.desktop/share/native/libwakefield/src/wakefield.c

Large diffs are not rendered by default.

23 changes: 8 additions & 15 deletions src/java.desktop/unix/classes/sun/awt/wl/WLInputState.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @param pointerButtonPressedEvent null or the latest PointerButtonEvent such that getIsButtonPressed() == true
* @param modifiers a bit set of modifiers reflecting currently pressed keys (@see WLInputState.getNewModifiers())
* @param surfaceForKeyboardInput represents 'struct wl_surface*' that keyboards events should go to
* @param lockingKeyState a bit set of locking modifiers currently active
*/
record WLInputState(WLPointerEvent eventWithSurface,
WLPointerEvent eventWithSerial,
Expand All @@ -47,8 +46,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
PointerButtonEvent pointerButtonPressedEvent,
int modifiers,
long surfaceForKeyboardInput,
boolean isPointerOverSurface,
int lockingKeyState) {
boolean isPointerOverSurface) {
/**
* Groups together information about a mouse pointer button event.
* @param surface 'struct wl_surface*' the button was pressed over
Expand All @@ -62,7 +60,7 @@ record PointerButtonEvent(long surface, long serial, long timestamp, int clickCo

static WLInputState initialState() {
return new WLInputState(null, null, null, null,
null, 0, 0, false, 0);
null, 0, 0, false);
}

/**
Expand Down Expand Up @@ -94,8 +92,7 @@ WLInputState update(WLPointerEvent pointerEvent) {
newPointerButtonEvent,
newModifiers,
surfaceForKeyboardInput,
newPointerOverSurface,
lockingKeyState);
newPointerOverSurface);
}

public WLInputState updatedFromKeyboardEnterEvent(long serial, long surfacePtr) {
Expand All @@ -108,11 +105,10 @@ public WLInputState updatedFromKeyboardEnterEvent(long serial, long surfacePtr)
pointerButtonPressedEvent,
modifiers,
surfacePtr,
isPointerOverSurface,
lockingKeyState);
isPointerOverSurface);
}

public WLInputState updatedFromKeyboardModifiersEvent(long serial, int keyboardModifiers, int newLockingKeyState) {
public WLInputState updatedFromKeyboardModifiersEvent(long serial, int keyboardModifiers) {
// "The compositor must send the wl_keyboard.modifiers event after this event".
final int oldPointerModifiers = modifiers & WLPointerEvent.PointerButtonCodes.combinedMask();
final int newModifiers = oldPointerModifiers | keyboardModifiers;
Expand All @@ -124,8 +120,7 @@ public WLInputState updatedFromKeyboardModifiersEvent(long serial, int keyboardM
pointerButtonPressedEvent,
newModifiers,
surfaceForKeyboardInput,
isPointerOverSurface,
newLockingKeyState);
isPointerOverSurface);
}

public WLInputState updatedFromKeyboardLeaveEvent(long serial, long surfacePtr) {
Expand All @@ -140,8 +135,7 @@ public WLInputState updatedFromKeyboardLeaveEvent(long serial, long surfacePtr)
pointerButtonPressedEvent,
newModifiers,
0,
isPointerOverSurface,
lockingKeyState);
isPointerOverSurface);
}

public WLInputState resetPointerState() {
Expand All @@ -153,8 +147,7 @@ public WLInputState resetPointerState() {
pointerButtonPressedEvent,
0,
surfaceForKeyboardInput,
false,
lockingKeyState);
false);
}

private PointerButtonEvent getNewPointerButtonEvent(WLPointerEvent pointerEvent,
Expand Down
Loading

0 comments on commit 070ec5b

Please sign in to comment.