mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-5861 Wayland: minimum necessary stubs to run IDEA
(cherry picked from commit d8dbfd7249)
This commit is contained in:
@@ -45,7 +45,8 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
WLPointerEvent eventWithCoordinates,
|
||||
PointerButtonEvent pointerButtonPressedEvent,
|
||||
int modifiers,
|
||||
long surfaceForKeyboardInput) {
|
||||
long surfaceForKeyboardInput,
|
||||
boolean isPointerOverSurface) {
|
||||
/**
|
||||
* Groups together information about a mouse pointer button event.
|
||||
* @param surface 'struct wl_surface*' the button was pressed over
|
||||
@@ -59,7 +60,7 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
|
||||
static WLInputState initialState() {
|
||||
return new WLInputState(null, null, null, null,
|
||||
null, 0, 0);
|
||||
null, 0, 0, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,6 +81,9 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
newEventWithTimestamp);
|
||||
final int newModifiers = getNewModifiers(pointerEvent);
|
||||
|
||||
boolean newPointerOverSurface = (pointerEvent.hasEnterEvent() || isPointerOverSurface)
|
||||
&& !pointerEvent.hasLeaveEvent();
|
||||
|
||||
return new WLInputState(
|
||||
newEventWithSurface,
|
||||
newEventWithSerial,
|
||||
@@ -87,7 +91,8 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
newEventWithCoordinates,
|
||||
newPointerButtonEvent,
|
||||
newModifiers,
|
||||
surfaceForKeyboardInput);
|
||||
surfaceForKeyboardInput,
|
||||
newPointerOverSurface);
|
||||
}
|
||||
|
||||
public WLInputState updatedFromKeyboardEnterEvent(long serial, long surfacePtr) {
|
||||
@@ -99,7 +104,8 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
eventWithCoordinates,
|
||||
pointerButtonPressedEvent,
|
||||
modifiers,
|
||||
surfacePtr);
|
||||
surfacePtr,
|
||||
isPointerOverSurface);
|
||||
}
|
||||
|
||||
public WLInputState updatedFromKeyboardModifiersEvent(long serial, int keyboardModifiers) {
|
||||
@@ -113,7 +119,8 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
eventWithCoordinates,
|
||||
pointerButtonPressedEvent,
|
||||
newModifiers,
|
||||
surfaceForKeyboardInput);
|
||||
surfaceForKeyboardInput,
|
||||
isPointerOverSurface);
|
||||
}
|
||||
|
||||
public WLInputState updatedFromKeyboardLeaveEvent(long serial, long surfacePtr) {
|
||||
@@ -127,7 +134,8 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
eventWithCoordinates,
|
||||
pointerButtonPressedEvent,
|
||||
newModifiers,
|
||||
0);
|
||||
0,
|
||||
isPointerOverSurface);
|
||||
}
|
||||
|
||||
public WLInputState resetPointerState() {
|
||||
@@ -138,7 +146,8 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
eventWithCoordinates,
|
||||
pointerButtonPressedEvent,
|
||||
0,
|
||||
surfaceForKeyboardInput);
|
||||
surfaceForKeyboardInput,
|
||||
false);
|
||||
}
|
||||
|
||||
private PointerButtonEvent getNewPointerButtonEvent(WLPointerEvent pointerEvent,
|
||||
@@ -219,6 +228,24 @@ record WLInputState(WLPointerEvent eventWithSurface,
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if pointer has entered the associated peer and has not left its bounds.
|
||||
*/
|
||||
public boolean isPointerOverPeer() {
|
||||
if (isPointerOverSurface && eventWithCoordinates != null) {
|
||||
int x = eventWithCoordinates.getSurfaceX();
|
||||
int y = eventWithCoordinates.getSurfaceY();
|
||||
WLComponentPeer peer = getPeer();
|
||||
if (peer != null) {
|
||||
return x >= 0
|
||||
&& x < peer.getWidth()
|
||||
&& y >= 0
|
||||
&& y < peer.getHeight();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return eventWithTimestamp != null ? eventWithTimestamp.getTimestamp() : 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2023 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.awt.wl;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Window;
|
||||
import java.awt.peer.MouseInfoPeer;
|
||||
|
||||
public class WLMouseInfoPeer implements MouseInfoPeer {
|
||||
|
||||
@Override
|
||||
public int fillPointWithCoords(Point point) {
|
||||
WLInputState inputState = WLToolkit.getInputState();
|
||||
// NB: these are surface-local coordinates
|
||||
point.setLocation(inputState.getPointerX(), inputState.getPointerY());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindowUnderMouse(Window w) {
|
||||
WLInputState inputState = WLToolkit.getInputState();
|
||||
WLComponentPeer peerUnderMouse = inputState.getPeer();
|
||||
return peerUnderMouse != null
|
||||
&& peerUnderMouse.getTarget() == w
|
||||
&& inputState.isPointerOverPeer();
|
||||
}
|
||||
|
||||
private static class HOLDER {
|
||||
static WLMouseInfoPeer instance = new WLMouseInfoPeer();
|
||||
}
|
||||
|
||||
static WLMouseInfoPeer getInstance() {
|
||||
return HOLDER.instance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -696,8 +696,7 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
|
||||
|
||||
@Override
|
||||
public synchronized MouseInfoPeer getMouseInfoPeer() {
|
||||
log.info("Not implemented: WLToolkit.getMouseInfoPeer()");
|
||||
return null;
|
||||
return WLMouseInfoPeer.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -970,6 +969,11 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNativeGTKAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync() {
|
||||
flushImpl();
|
||||
|
||||
Reference in New Issue
Block a user