mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-08 09:31:42 +01:00
Compare commits
4 Commits
jbr21.1275
...
mkartash/J
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92e528cbb0 | ||
|
|
980633a3f6 | ||
|
|
141047fb00 | ||
|
|
3aec478bd6 |
@@ -121,7 +121,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
private final Object dataLock = new Object();
|
||||
int width; // protected by dataLock
|
||||
int height; // protected by dataLock
|
||||
int wlBufferScale; // protected by dataLock
|
||||
double wlScale; // protected by dataLock
|
||||
double effectiveScale; // protected by dataLock
|
||||
|
||||
static {
|
||||
@@ -138,7 +138,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
final WLGraphicsConfig config = (WLGraphicsConfig)target.getGraphicsConfiguration();
|
||||
wlBufferScale = config.getWlScale();
|
||||
wlScale = config.getWlScale();
|
||||
effectiveScale = config.getEffectiveScale();
|
||||
surfaceData = config.createSurfaceData(this);
|
||||
nativePtr = nativeCreateFrame();
|
||||
@@ -306,6 +306,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
nativeCreateWLPopup(nativePtr, getParentNativePtr(target),
|
||||
thisWidth, thisHeight,
|
||||
parentX + offsetX, parentY + offsetY);
|
||||
nativeSetSize(nativePtr, thisWidth, thisHeight);
|
||||
} else {
|
||||
int xNative = javaUnitsToSurfaceUnits(target.getX());
|
||||
int yNative = javaUnitsToSurfaceUnits(target.getY());
|
||||
@@ -314,6 +315,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
xNative, yNative,
|
||||
isModal, isMaximized, isMinimized,
|
||||
title, WLToolkit.getApplicationID());
|
||||
nativeSetSize(nativePtr, thisWidth, thisHeight);
|
||||
}
|
||||
final long wlSurfacePtr = getWLSurface(nativePtr);
|
||||
WLToolkit.registerWLSurface(wlSurfacePtr, this);
|
||||
@@ -352,14 +354,15 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
}
|
||||
|
||||
void updateSurfaceData() {
|
||||
// TODO: remove scale from here?
|
||||
SurfaceData.convertTo(WLSurfaceDataExt.class, surfaceData).revalidate(
|
||||
getBufferWidth(), getBufferHeight(), getBufferScale());
|
||||
getBufferWidth(), getBufferHeight(), (int)getBufferScale());
|
||||
updateWindowGeometry();
|
||||
}
|
||||
|
||||
void configureWLSurface() {
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(String.format("%s is configured to %dx%d with %dx scale", this, getBufferWidth(), getBufferHeight(), getBufferScale()));
|
||||
log.fine(String.format("%s is configured to %dx%d with %fx scale", this, getBufferWidth(), getBufferHeight(), getBufferScale()));
|
||||
}
|
||||
updateSurfaceData();
|
||||
}
|
||||
@@ -469,7 +472,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
if (sizeChanged) {
|
||||
setSizeTo(newSize.width, newSize.height);
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(String.format("%s is resizing its buffer to %dx%d with %dx scale",
|
||||
log.fine(String.format("%s is resizing its buffer to %dx%d with %fx scale",
|
||||
this, getBufferWidth(), getBufferHeight(), getBufferScale()));
|
||||
}
|
||||
updateSurfaceData();
|
||||
@@ -483,6 +486,9 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
|
||||
private void setSizeTo(int newWidth, int newHeight) {
|
||||
Dimension newSize = constrainSize(newWidth, newHeight);
|
||||
performLocked(() -> {
|
||||
nativeSetSize(nativePtr, javaUnitsToSurfaceUnits(newSize.width), javaUnitsToSurfaceUnits(newSize.height));
|
||||
});
|
||||
synchronized (dataLock) {
|
||||
this.width = newSize.width;
|
||||
this.height = newSize.height;
|
||||
@@ -522,16 +528,9 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scale of wl_buffer attached to this component's wl_surface.
|
||||
* Buffer coordinate space is linearly scaled wrt the component (or surface)
|
||||
* coordinate space, so component's coordinates have to be translated
|
||||
* to buffers' whenever Wayland protocol requires "buffer-local" coordinates.
|
||||
* See wl_surface.set_buffer_scale in wayland.xml for more details.
|
||||
*/
|
||||
int getBufferScale() {
|
||||
double getBufferScale() {
|
||||
synchronized(dataLock) {
|
||||
return wlBufferScale;
|
||||
return wlScale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -827,7 +826,11 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
WLComponentPeer peer = inputState.getPeer();
|
||||
if (peer == null) return;
|
||||
Cursor cursor = peer.getCursor(inputState.getPointerX(), inputState.getPointerY());
|
||||
setCursor(cursor, getGraphicsDevice() != null ? getGraphicsDevice().getWlScale() : 1);
|
||||
|
||||
double deviceScale = (getGraphicsDevice() != null ? (getGraphicsDevice().getWlScale() + 0.5) : 1.0);
|
||||
int scale = (int)deviceScale;
|
||||
// TODO: make cursor support fractional scale
|
||||
setCursor(cursor, scale);
|
||||
}
|
||||
|
||||
Cursor getCursor(int x, int y) {
|
||||
@@ -938,16 +941,17 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
|
||||
@Override
|
||||
public boolean updateGraphicsData(GraphicsConfiguration gc) {
|
||||
final int newWlScale = ((WLGraphicsConfig)gc).getWlScale();
|
||||
double newWlScale = ((WLGraphicsConfig)gc).getWlScale();
|
||||
double newEffectiveScale = ((WLGraphicsConfig)gc).getEffectiveScale();
|
||||
|
||||
WLGraphicsDevice gd = ((WLGraphicsConfig) gc).getDevice();
|
||||
gd.addWindow(this);
|
||||
synchronized (dataLock) {
|
||||
if (newWlScale != wlBufferScale) {
|
||||
wlBufferScale = newWlScale;
|
||||
effectiveScale = ((WLGraphicsConfig)gc).getEffectiveScale();
|
||||
if (newWlScale != wlScale) {
|
||||
wlScale = newWlScale;
|
||||
effectiveScale = newEffectiveScale;
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(String.format("%s is updating buffer to %dx%d with %dx scale", this, getBufferWidth(), getBufferHeight(), wlBufferScale));
|
||||
log.fine(String.format("%s is updating buffer to %dx%d with %fx scale", this, getBufferWidth(), getBufferHeight(), wlScale));
|
||||
}
|
||||
updateSurfaceData();
|
||||
postPaintEvent();
|
||||
@@ -1023,6 +1027,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
private native void nativeRequestFullScreen(long ptr, int wlID);
|
||||
private native void nativeRequestUnsetFullScreen(long ptr);
|
||||
|
||||
private native void nativeSetSize(long ptr, int width, int height);
|
||||
private native void nativeSetWindowGeometry(long ptr, int x, int y, int width, int height);
|
||||
private native void nativeSetMinimumSize(long ptr, int width, int height);
|
||||
private native void nativeSetMaximumSize(long ptr, int width, int height);
|
||||
@@ -1180,7 +1185,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
return value;
|
||||
} else {
|
||||
synchronized (dataLock) {
|
||||
return (int)(value * wlBufferScale / effectiveScale);
|
||||
return (int)(value * wlScale / effectiveScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1194,7 +1199,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
return value;
|
||||
} else {
|
||||
synchronized (dataLock) {
|
||||
return (int)(value * effectiveScale / wlBufferScale);
|
||||
return (int)(value * effectiveScale / wlScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1237,6 +1242,24 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
}
|
||||
}
|
||||
|
||||
void notifyScaleChanged(int numerator) {
|
||||
// Called from the native code
|
||||
|
||||
// NB: this scale is not really usable for us because it must be in perfect sync with
|
||||
// GraphicsConfiguration.getDefaultTransform(), which is an attribute of the graphics device,
|
||||
// not of the window.
|
||||
|
||||
/*
|
||||
double newScale = numerator / 120.0;
|
||||
synchronized (dataLock) {
|
||||
wlBufferScale = newScale;
|
||||
effectiveScale = WLGraphicsEnvironment.effectiveScaleFrom(newScale);
|
||||
updateSurfaceData();
|
||||
postPaintEvent(); // not sure if this is necessary
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void notifyEnteredOutput(int wlOutputID) {
|
||||
// NB: May also be called from native code whenever the corresponding wl_surface enters a new output
|
||||
synchronized (devices) {
|
||||
@@ -1281,7 +1304,7 @@ public class WLComponentPeer implements ComponentPeer {
|
||||
}
|
||||
|
||||
private WLGraphicsDevice getGraphicsDevice() {
|
||||
int scale = 0;
|
||||
double scale = 0;
|
||||
WLGraphicsDevice theDevice = null;
|
||||
// AFAIK there's no way of knowing which WLGraphicsDevice is displaying
|
||||
// the largest portion of this component, so choose the first in the ordered list
|
||||
|
||||
@@ -47,6 +47,7 @@ public abstract class WLDecoratedPeer extends WLWindowPeer {
|
||||
public abstract boolean isResizable();
|
||||
public abstract boolean isInteractivelyResizable();
|
||||
|
||||
public abstract boolean isFrameStateSupported(int state);
|
||||
public abstract void setState(int newState);
|
||||
public abstract int getState();
|
||||
public abstract void setExtendedState(int newState);
|
||||
|
||||
@@ -59,9 +59,14 @@ public class WLDialogPeer extends WLDecoratedPeer implements DialogPeer {
|
||||
return ((Dialog)target).getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrameStateSupported(int state) {
|
||||
return state == Frame.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(int newState) {
|
||||
throw new UnsupportedOperationException();
|
||||
// Ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,6 +76,6 @@ public class WLDialogPeer extends WLDecoratedPeer implements DialogPeer {
|
||||
|
||||
@Override
|
||||
public void setExtendedState(int newState) {
|
||||
throw new UnsupportedOperationException();
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ public class WLFrameDecoration {
|
||||
} else if (e.getID() == MouseEvent.MOUSE_DRAGGED && pressedInDragStartArea() && isSignificantDrag(point)) {
|
||||
peer.startDrag();
|
||||
} else if (e.getID() == MouseEvent.MOUSE_CLICKED && e.getClickCount() == 2 && pressedInDragStartArea()
|
||||
&& peer.isResizable()) {
|
||||
&& peer.isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
|
||||
toggleMaximizedState();
|
||||
} else if (e.getID() == MouseEvent.MOUSE_MOVED && !pointerInside) {
|
||||
peer.updateCursorImmediately();
|
||||
|
||||
@@ -83,6 +83,15 @@ public class WLFramePeer extends WLDecoratedPeer implements FramePeer {
|
||||
return getFrame().getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrameStateSupported(int state) {
|
||||
return switch (state) {
|
||||
case Frame.NORMAL, Frame.ICONIFIED, Frame.MAXIMIZED_BOTH, Frame.MAXIMIZED_HORIZ, Frame.MAXIMIZED_VERT ->
|
||||
true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(int newState) {
|
||||
if (!isVisible()) return;
|
||||
|
||||
@@ -39,10 +39,10 @@ public abstract class WLGraphicsConfig extends GraphicsConfiguration {
|
||||
private final WLGraphicsDevice device;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final int wlScale; // as reported by Wayland
|
||||
private final double wlScale; // as derived from Wayland
|
||||
private final double effectiveScale; // as enforced by Java
|
||||
|
||||
protected WLGraphicsConfig(WLGraphicsDevice device, int width, int height, int wlScale) {
|
||||
protected WLGraphicsConfig(WLGraphicsDevice device, int width, int height, double wlScale) {
|
||||
this.device = device;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
@@ -50,7 +50,7 @@ public abstract class WLGraphicsConfig extends GraphicsConfiguration {
|
||||
this.effectiveScale = WLGraphicsEnvironment.effectiveScaleFrom(wlScale);
|
||||
}
|
||||
|
||||
boolean differsFrom(int width, int height, int scale) {
|
||||
boolean differsFrom(int width, int height, double scale) {
|
||||
return width != this.width || height != this.height || scale != this.wlScale;
|
||||
}
|
||||
|
||||
@@ -89,9 +89,9 @@ public abstract class WLGraphicsConfig extends GraphicsConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred Wayland buffer scale for this display configuration.
|
||||
* Returns the preferred ratio of logical to physical hardware window size for this display configuration.
|
||||
*/
|
||||
public int getWlScale() {
|
||||
public double getWlScale() {
|
||||
return wlScale;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,6 @@ public abstract class WLGraphicsConfig extends GraphicsConfiguration {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%dx%d %dx scale", width, height, wlScale);
|
||||
return String.format("%dx%d %fx scale", width, height, wlScale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class WLGraphicsDevice extends GraphicsDevice {
|
||||
return wlID;
|
||||
}
|
||||
|
||||
void updateConfiguration(String name, int width, int height, int scale) {
|
||||
void updateConfiguration(String name, int width, int height, double scale) {
|
||||
this.name = name;
|
||||
|
||||
WLGraphicsConfig config = defaultConfig;
|
||||
@@ -100,7 +100,7 @@ public class WLGraphicsDevice extends GraphicsDevice {
|
||||
// It is necessary to create a new object whenever config changes as its
|
||||
// identity is used to detect changes in scale, among other things.
|
||||
if (WLGraphicsEnvironment.isVulkanEnabled()) {
|
||||
newDefaultConfig = WLVKGraphicsConfig.getConfig(this, width, height, scale);
|
||||
newDefaultConfig = WLVKGraphicsConfig.getConfig(this, width, height, (int)scale);
|
||||
newConfigs = new GraphicsConfiguration[1];
|
||||
newConfigs[0] = newDefaultConfig;
|
||||
} else {
|
||||
@@ -145,7 +145,7 @@ public class WLGraphicsDevice extends GraphicsDevice {
|
||||
this.x = similarDevice.x;
|
||||
this.y = similarDevice.y;
|
||||
|
||||
int newScale = similarDevice.getWlScale();
|
||||
double newScale = similarDevice.getWlScale();
|
||||
Rectangle newBounds = similarDevice.defaultConfig.getBounds();
|
||||
updateConfiguration(similarDevice.name, newBounds.width, newBounds.height, newScale);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class WLGraphicsDevice extends GraphicsDevice {
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
int widthMm, int heightMm,
|
||||
int scale) {
|
||||
double scale) {
|
||||
WLGraphicsDevice device = new WLGraphicsDevice(id, x, y, widthMm, heightMm);
|
||||
device.updateConfiguration(name, width, height, scale);
|
||||
return device;
|
||||
@@ -207,7 +207,7 @@ public class WLGraphicsDevice extends GraphicsDevice {
|
||||
return defaultConfig;
|
||||
}
|
||||
|
||||
int getWlScale() {
|
||||
double getWlScale() {
|
||||
return defaultConfig.getWlScale();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,18 @@ public class WLGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
private static boolean vulkanRequested = false;
|
||||
private static int vulkanRequestedDeviceNumber = -1;
|
||||
private static final boolean debugScaleEnabled;
|
||||
|
||||
|
||||
public static final int WL_OUTPUT_TRANSFORM_NORMAL = 0;
|
||||
public static final int WL_OUTPUT_TRANSFORM_90 = 1;
|
||||
public static final int WL_OUTPUT_TRANSFORM_180 = 2;
|
||||
public static final int WL_OUTPUT_TRANSFORM_270 = 3;
|
||||
public static final int WL_OUTPUT_TRANSFORM_FLIPPED = 4;
|
||||
public static final int WL_OUTPUT_TRANSFORM_FLIPPED_90 = 5;
|
||||
public static final int WL_OUTPUT_TRANSFORM_FLIPPED_180 = 6;
|
||||
public static final int WL_OUTPUT_TRANSFORM_FLIPPED_270 = 7;
|
||||
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static String vulkanOption =
|
||||
AccessController.doPrivileged(
|
||||
@@ -127,12 +139,31 @@ public class WLGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
private final List<WLGraphicsDevice> devices = new ArrayList<>(5);
|
||||
|
||||
private void notifyOutputConfigured(String name, String make, String model, int wlID,
|
||||
int x, int y, int width, int height, int widthMm, int heightMm,
|
||||
int x, int y,
|
||||
int width, int height,
|
||||
int widthLogical, int heightLogical,
|
||||
int widthMm, int heightMm,
|
||||
int subpixel, int transform, int scale) {
|
||||
// Called from native code whenever a new output appears or an existing one changes its properties
|
||||
// NB: initially called during WLToolkit.initIDs() on the main thread; later on EDT.
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine(String.format("Output configured id=%d at (%d, %d) %dx%d %dx scale", wlID, x, y, width, height, scale));
|
||||
log.fine(String.format("Output configured id=%d at (%d, %d) %dx%d (%dx%d logical) %dx scale",
|
||||
wlID, x, y, width, height, widthLogical, heightLogical, scale));
|
||||
}
|
||||
|
||||
double realScale = scale;
|
||||
if (widthLogical != 0 && heightLogical != 0) {
|
||||
switch (transform) {
|
||||
case WL_OUTPUT_TRANSFORM_NORMAL,
|
||||
WL_OUTPUT_TRANSFORM_180,
|
||||
WL_OUTPUT_TRANSFORM_FLIPPED,
|
||||
WL_OUTPUT_TRANSFORM_FLIPPED_180
|
||||
-> realScale = (double) width / widthLogical;
|
||||
default
|
||||
-> realScale = (double) height / widthLogical;
|
||||
}
|
||||
realScale = ((int)(realScale * 100)) / 100.0;
|
||||
System.out.printf("real scale %f\n", realScale);
|
||||
}
|
||||
|
||||
String humanID =
|
||||
@@ -147,10 +178,10 @@ public class WLGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
newOutput = false;
|
||||
if (gd.isSameDeviceAs(wlID, x, y)) {
|
||||
// These coordinates and the size are not scaled.
|
||||
gd.updateConfiguration(humanID, width, height, scale);
|
||||
gd.updateConfiguration(humanID, width, height, realScale);
|
||||
} else {
|
||||
final WLGraphicsDevice updatedDevice = WLGraphicsDevice.createWithConfiguration(wlID, humanID,
|
||||
x, y, width, height, widthMm, heightMm, scale);
|
||||
x, y, width, height, widthMm, heightMm, realScale);
|
||||
devices.set(i, updatedDevice);
|
||||
gd.invalidate(updatedDevice);
|
||||
}
|
||||
@@ -159,7 +190,7 @@ public class WLGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
}
|
||||
if (newOutput) {
|
||||
final WLGraphicsDevice gd = WLGraphicsDevice.createWithConfiguration(wlID, humanID, x, y,
|
||||
width, height, widthMm, heightMm, scale);
|
||||
width, height, widthMm, heightMm, realScale);
|
||||
devices.add(gd);
|
||||
}
|
||||
}
|
||||
@@ -253,7 +284,7 @@ public class WLGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
}
|
||||
}
|
||||
|
||||
static double effectiveScaleFrom(int displayScale) {
|
||||
static double effectiveScaleFrom(double displayScale) {
|
||||
return debugScaleEnabled ? SunGraphicsEnvironment.getDebugScale() : displayScale;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class WLSMGraphicsConfig extends WLGraphicsConfig {
|
||||
private WLSMGraphicsConfig(WLGraphicsDevice device,
|
||||
int width,
|
||||
int height,
|
||||
int scale,
|
||||
double scale,
|
||||
boolean translucencyCapable) {
|
||||
super(device, width, height, scale);
|
||||
this.translucencyCapable = translucencyCapable;
|
||||
@@ -67,7 +67,7 @@ public class WLSMGraphicsConfig extends WLGraphicsConfig {
|
||||
public static WLSMGraphicsConfig getConfig(WLGraphicsDevice device,
|
||||
int width,
|
||||
int height,
|
||||
int scale,
|
||||
double scale,
|
||||
boolean translucencyCapable) {
|
||||
var newConfig = new WLSMGraphicsConfig(device, width, height, scale, translucencyCapable);
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
|
||||
@@ -74,7 +74,7 @@ public final class WLVKGraphicsConfig extends WLGraphicsConfig
|
||||
|
||||
private static native long getVKConfigInfo();
|
||||
|
||||
public WLVKGraphicsConfig(WLGraphicsDevice device, int width, int height, int scale, ContextCapabilities vkCaps) {
|
||||
public WLVKGraphicsConfig(WLGraphicsDevice device, int width, int height, double scale, ContextCapabilities vkCaps) {
|
||||
super(device, width, height, scale);
|
||||
this.vkCaps = vkCaps;
|
||||
context = new VKContext(VKRenderQueue.getInstance());
|
||||
@@ -85,7 +85,7 @@ public final class WLVKGraphicsConfig extends WLGraphicsConfig
|
||||
return this;
|
||||
}
|
||||
|
||||
public static WLVKGraphicsConfig getConfig(WLGraphicsDevice device, int width, int height, int scale)
|
||||
public static WLVKGraphicsConfig getConfig(WLGraphicsDevice device, int width, int height, double scale)
|
||||
{
|
||||
ContextCapabilities caps = new VKContext.VKContextCaps(
|
||||
CAPS_PS30 | CAPS_PS20 | CAPS_RT_TEXTURE_ALPHA |
|
||||
|
||||
@@ -60,7 +60,8 @@ public abstract class WLVKSurfaceData extends VKSurfaceData implements WLSurface
|
||||
final int backgroundRGB = peer.getBackground() != null
|
||||
? peer.getBackground().getRGB()
|
||||
: 0;
|
||||
int scale = ((WLGraphicsConfig)peer.getGraphicsConfiguration()).getWlScale();
|
||||
// TODO: support fractional scaling
|
||||
int scale = (int)(((WLGraphicsConfig)peer.getGraphicsConfiguration()).getWlScale());
|
||||
initOps(peer.getBufferWidth(), peer.getBufferHeight(), scale, backgroundRGB);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ public class WLSMSurfaceData extends SurfaceData implements WLSurfaceDataExt {
|
||||
|
||||
public native void assignSurface(long surfacePtr);
|
||||
|
||||
private native void initOps(int width, int height, int scale, int backgroundRGB, int wlShmFormat);
|
||||
private native void initOps(int width, int height, int backgroundRGB, int wlShmFormat);
|
||||
|
||||
private WLSMSurfaceData(WLComponentPeer peer, SurfaceType surfaceType, ColorModel colorModel, int scale, int wlShmFormat) {
|
||||
private WLSMSurfaceData(WLComponentPeer peer, SurfaceType surfaceType, ColorModel colorModel, int wlShmFormat) {
|
||||
super(surfaceType, colorModel);
|
||||
this.peer = peer;
|
||||
|
||||
@@ -60,10 +60,10 @@ public class WLSMSurfaceData extends SurfaceData implements WLSurfaceDataExt {
|
||||
int height = peer.getBufferHeight();
|
||||
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
log.fine(String.format("Shared memory surface data %dx%d x%d scale, format %d", width, height, scale, wlShmFormat));
|
||||
log.fine(String.format("Shared memory surface data %dx%d x%d scale, format %d", width, height, wlShmFormat));
|
||||
}
|
||||
|
||||
initOps(width, height, scale, backgroundPixel, wlShmFormat);
|
||||
initOps(width, height, backgroundPixel, wlShmFormat);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ public class WLSMSurfaceData extends SurfaceData implements WLSurfaceDataExt {
|
||||
}
|
||||
ColorModel cm = graphicsConfig.getColorModel();
|
||||
SurfaceType surfaceType = graphicsConfig.getSurfaceType();
|
||||
return new WLSMSurfaceData(peer, surfaceType, cm, graphicsConfig.getWlScale(), graphicsConfig.getWlShmFormat());
|
||||
return new WLSMSurfaceData(peer, surfaceType, cm, graphicsConfig.getWlShmFormat());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -271,9 +271,6 @@ struct WLSurfaceBufferManager {
|
||||
/// Does not exceed MAX_BUFFERS_IN_USE elements.
|
||||
WLSurfaceBuffer * buffersInUse; // only accessed under showLock
|
||||
|
||||
/// The scale of wl_surface (see Wayland docs for more info on that).
|
||||
jint scale; // only accessed under showLock
|
||||
|
||||
pthread_mutex_t drawLock;
|
||||
|
||||
/**
|
||||
@@ -517,6 +514,7 @@ SurfaceBufferResize(WLSurfaceBufferManager * manager, WLSurfaceBuffer* buffer)
|
||||
buffer->bytesAllocated = requiredSize;
|
||||
}
|
||||
|
||||
printf("SurfaceBufferResize -> %dx%d\n", buffer->width, buffer->height);
|
||||
const int32_t stride = (int32_t) (buffer->width * sizeof(pixel_t));
|
||||
buffer->wlBuffer = wl_shm_pool_create_buffer(buffer->wlPool, 0,
|
||||
buffer->width,
|
||||
@@ -771,7 +769,7 @@ SendShowBufferToWayland(WLSurfaceBufferManager * manager)
|
||||
|
||||
// wl_buffer_listener will release bufferForShow when Wayland's done with it
|
||||
wl_surface_attach(manager->wlSurface, buffer->wlBuffer, 0, 0);
|
||||
wl_surface_set_buffer_scale(manager->wlSurface, manager->scale);
|
||||
//wl_surface_set_buffer_scale(manager->wlSurface, 1); // we scale with a viewport
|
||||
|
||||
// Better wait for the frame event so as not to overwhelm Wayland with
|
||||
// frequent surface updates that it cannot deliver to the screen anyway.
|
||||
@@ -941,7 +939,7 @@ HaveEnoughMemoryForWindow(jint width, jint height)
|
||||
}
|
||||
|
||||
WLSurfaceBufferManager *
|
||||
WLSBM_Create(jint width, jint height, jint scale, jint bgPixel, jint wlShmFormat)
|
||||
WLSBM_Create(jint width, jint height, jint bgPixel, jint wlShmFormat)
|
||||
{
|
||||
traceEnabled = getenv("J2D_STATS");
|
||||
traceFPSEnabled = getenv("J2D_FPS");
|
||||
@@ -957,7 +955,6 @@ WLSBM_Create(jint width, jint height, jint scale, jint bgPixel, jint wlShmFormat
|
||||
|
||||
manager->bufferForDraw.width = width;
|
||||
manager->bufferForDraw.height = height;
|
||||
manager->scale = scale;
|
||||
manager->bgPixel = bgPixel;
|
||||
manager->format = wlShmFormat;
|
||||
|
||||
@@ -1112,7 +1109,7 @@ WLSB_DataGet(WLDrawBuffer * buffer)
|
||||
}
|
||||
|
||||
void
|
||||
WLSBM_SizeChangeTo(WLSurfaceBufferManager * manager, jint width, jint height, jint scale)
|
||||
WLSBM_SizeChangeTo(WLSurfaceBufferManager * manager, jint width, jint height)
|
||||
{
|
||||
if (!HaveEnoughMemoryForWindow(width, height)) {
|
||||
JNU_ThrowOutOfMemoryError(getEnv(), "Wayland surface buffer too large");
|
||||
@@ -1123,9 +1120,7 @@ WLSBM_SizeChangeTo(WLSurfaceBufferManager * manager, jint width, jint height, ji
|
||||
MUTEX_LOCK(manager->showLock);
|
||||
const bool change_needed =
|
||||
manager->bufferForDraw.width != width
|
||||
|| manager->bufferForDraw.height != height
|
||||
|| manager->scale != scale;
|
||||
manager->scale = scale;
|
||||
|| manager->bufferForDraw.height != height;
|
||||
|
||||
if (change_needed) {
|
||||
manager->bufferForDraw.width = width;
|
||||
|
||||
@@ -61,7 +61,7 @@ typedef uint32_t pixel_t;
|
||||
* the drawing to displaying buffer, synchronization, and sending
|
||||
* the appropriate notifications to Wayland.
|
||||
*/
|
||||
WLSurfaceBufferManager * WLSBM_Create(jint width, jint height, jint scale, jint bgPixel, jint wlShmFormat);
|
||||
WLSurfaceBufferManager * WLSBM_Create(jint width, jint height, jint bgPixel, jint wlShmFormat);
|
||||
|
||||
/**
|
||||
* Free all resources allocated for the WayLand Surface Buffer Manager,
|
||||
@@ -108,7 +108,7 @@ jint WLSBM_HeightGet(WLSurfaceBufferManager *);
|
||||
* displays things will change later, but before the changes in drawing buffer
|
||||
* are propagated to the display buffer.
|
||||
*/
|
||||
void WLSBM_SizeChangeTo(WLSurfaceBufferManager *, jint width, jint height, jint scale);
|
||||
void WLSBM_SizeChangeTo(WLSurfaceBufferManager *, jint width, jint height);
|
||||
|
||||
/**
|
||||
* Returns a buffer managed by the WayLand Surface Buffer Manager
|
||||
|
||||
@@ -117,7 +117,7 @@ Java_sun_java2d_wl_WLSMSurfaceData_revalidate(JNIEnv *env, jobject wsd,
|
||||
return;
|
||||
}
|
||||
|
||||
WLSBM_SizeChangeTo(wsdo->bufferManager, width, height, scale);
|
||||
WLSBM_SizeChangeTo(wsdo->bufferManager, width, height);
|
||||
#endif /* !HEADLESS */
|
||||
}
|
||||
|
||||
@@ -322,7 +322,6 @@ JNIEXPORT void JNICALL
|
||||
Java_sun_java2d_wl_WLSMSurfaceData_initOps(JNIEnv *env, jobject wsd,
|
||||
jint width,
|
||||
jint height,
|
||||
jint scale,
|
||||
jint backgroundRGB,
|
||||
jint wlShmFormat)
|
||||
{
|
||||
@@ -347,7 +346,7 @@ Java_sun_java2d_wl_WLSMSurfaceData_initOps(JNIEnv *env, jobject wsd,
|
||||
wsdo->sdOps.Unlock = WLSD_Unlock;
|
||||
wsdo->sdOps.GetRasInfo = WLSD_GetRasInfo;
|
||||
wsdo->sdOps.Dispose = WLSD_Dispose;
|
||||
wsdo->bufferManager = WLSBM_Create(width, height, scale, backgroundRGB, wlShmFormat);
|
||||
wsdo->bufferManager = WLSBM_Create(width, height, backgroundRGB, wlShmFormat);
|
||||
if (wsdo->bufferManager == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, "Failed to create Wayland surface buffer manager");
|
||||
return;
|
||||
|
||||
@@ -44,6 +44,7 @@ static jmethodID notifyConfiguredMID;
|
||||
static jmethodID notifyEnteredOutputMID;
|
||||
static jmethodID notifyLeftOutputMID;
|
||||
static jmethodID notifyPopupDoneMID;
|
||||
static jmethodID notifyScaleChangedMID;
|
||||
|
||||
struct activation_token_list_item {
|
||||
struct xdg_activation_token_v1 *token;
|
||||
@@ -90,10 +91,12 @@ static void delete_all_tokens(struct activation_token_list_item *list) {
|
||||
struct WLFrame {
|
||||
jobject nativeFramePeer; // weak reference
|
||||
struct wl_surface *wl_surface;
|
||||
struct wp_viewport *wp_viewport;
|
||||
struct xdg_surface *xdg_surface;
|
||||
struct gtk_surface1 *gtk_surface;
|
||||
struct WLFrame *parent;
|
||||
struct xdg_positioner *xdg_positioner;
|
||||
struct wp_fractional_scale_v1 *wp_fractional_scale;
|
||||
struct activation_token_list_item *activation_token_list;
|
||||
jboolean toplevel;
|
||||
union {
|
||||
@@ -174,6 +177,20 @@ wl_surface_left_output(void *data,
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
preferred_scale(void *data, struct wp_fractional_scale_v1 * wp_fractional_scale, uint32_t scaleNumerator)
|
||||
{
|
||||
struct WLFrame *wlFrame = (struct WLFrame*) data;
|
||||
|
||||
JNIEnv *env = getEnv();
|
||||
const jobject nativeFramePeer = (*env)->NewLocalRef(env, wlFrame->nativeFramePeer);
|
||||
if (nativeFramePeer) {
|
||||
(*env)->CallVoidMethod(env, nativeFramePeer, notifyScaleChangedMID, scaleNumerator);
|
||||
(*env)->DeleteLocalRef(env, nativeFramePeer);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
.configure = xdg_surface_configure,
|
||||
};
|
||||
@@ -183,6 +200,10 @@ static const struct wl_surface_listener wl_surface_listener = {
|
||||
.leave = wl_surface_left_output
|
||||
};
|
||||
|
||||
static const struct wp_fractional_scale_v1_listener wp_fractional_scale_listener = {
|
||||
.preferred_scale = preferred_scale
|
||||
};
|
||||
|
||||
static void
|
||||
xdg_toplevel_configure(void *data,
|
||||
struct xdg_toplevel *xdg_toplevel,
|
||||
@@ -323,6 +344,9 @@ Java_sun_awt_wl_WLComponentPeer_initIDs
|
||||
CHECK_NULL_THROW_IE(env,
|
||||
notifyPopupDoneMID = (*env)->GetMethodID(env, clazz, "notifyPopupDone", "()V"),
|
||||
"Failed to find method WLComponentPeer.notifyPopupDone");
|
||||
CHECK_NULL_THROW_IE(env,
|
||||
notifyScaleChangedMID = (*env)->GetMethodID(env, clazz, "notifyScaleChanged", "(I)V"),
|
||||
"Failed to find method WLComponentPeer.notifyScaleChanged");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
@@ -451,13 +475,19 @@ Java_sun_awt_wl_WLComponentPeer_nativeCreateWLSurface
|
||||
if (frame->wl_surface) return;
|
||||
frame->wl_surface = wl_compositor_create_surface(wl_compositor);
|
||||
CHECK_NULL(frame->wl_surface);
|
||||
frame->wp_viewport = wp_viewporter_get_viewport(wp_viewporter, frame->wl_surface);
|
||||
CHECK_NULL(frame->wp_viewport);
|
||||
frame->xdg_surface = xdg_wm_base_get_xdg_surface(xdg_wm_base, frame->wl_surface);
|
||||
CHECK_NULL(frame->xdg_surface);
|
||||
if (gtk_shell1 != NULL) {
|
||||
frame->gtk_surface = gtk_shell1_get_gtk_surface(gtk_shell1, frame->wl_surface);
|
||||
CHECK_NULL(frame->gtk_surface);
|
||||
}
|
||||
|
||||
if (wp_fractional_scale_manager != NULL) {
|
||||
frame->wp_fractional_scale = wp_fractional_scale_manager_v1_get_fractional_scale(wp_fractional_scale_manager, frame->wl_surface);
|
||||
CHECK_NULL(frame->wp_fractional_scale);
|
||||
wp_fractional_scale_v1_add_listener(frame->wp_fractional_scale, &wp_fractional_scale_listener, frame);
|
||||
}
|
||||
wl_surface_add_listener(frame->wl_surface, &wl_surface_listener, frame);
|
||||
xdg_surface_add_listener(frame->xdg_surface, &xdg_surface_listener, frame);
|
||||
frame->toplevel = JNI_TRUE;
|
||||
@@ -530,6 +560,8 @@ Java_sun_awt_wl_WLComponentPeer_nativeCreateWLPopup
|
||||
if (frame->wl_surface) return;
|
||||
frame->wl_surface = wl_compositor_create_surface(wl_compositor);
|
||||
CHECK_NULL(frame->wl_surface);
|
||||
frame->wp_viewport = wp_viewporter_get_viewport(wp_viewporter, frame->wl_surface);
|
||||
CHECK_NULL(frame->wp_viewport);
|
||||
frame->xdg_surface = xdg_wm_base_get_xdg_surface(xdg_wm_base, frame->wl_surface);
|
||||
CHECK_NULL(frame->xdg_surface);
|
||||
|
||||
@@ -543,8 +575,14 @@ Java_sun_awt_wl_WLComponentPeer_nativeCreateWLPopup
|
||||
frame->xdg_popup = xdg_surface_get_popup(frame->xdg_surface, parentFrame->xdg_surface, xdg_positioner);
|
||||
CHECK_NULL(frame->xdg_popup);
|
||||
xdg_popup_add_listener(frame->xdg_popup, &xdg_popup_listener, frame);
|
||||
xdg_positioner_destroy(xdg_positioner);
|
||||
|
||||
if (wp_fractional_scale_manager != NULL) {
|
||||
frame->wp_fractional_scale = wp_fractional_scale_manager_v1_get_fractional_scale(wp_fractional_scale_manager, frame->wl_surface);
|
||||
CHECK_NULL(frame->wp_fractional_scale);
|
||||
wp_fractional_scale_v1_add_listener(frame->wp_fractional_scale, &wp_fractional_scale_listener, frame);
|
||||
}
|
||||
|
||||
xdg_positioner_destroy(xdg_positioner);
|
||||
// From xdg-shell.xml: "After creating a role-specific object and
|
||||
// setting it up, the client must perform an initial commit
|
||||
// without any buffer attached"
|
||||
@@ -586,6 +624,10 @@ DoHide(JNIEnv *env, struct WLFrame *frame)
|
||||
if (frame->gtk_surface != NULL) {
|
||||
gtk_surface1_destroy(frame->gtk_surface);
|
||||
}
|
||||
if (frame->wp_fractional_scale != NULL) {
|
||||
wp_fractional_scale_v1_destroy(frame->wp_fractional_scale);
|
||||
}
|
||||
wp_viewport_destroy(frame->wp_viewport);
|
||||
xdg_surface_destroy(frame->xdg_surface);
|
||||
wl_surface_destroy(frame->wl_surface);
|
||||
delete_all_tokens(frame->activation_token_list);
|
||||
@@ -596,6 +638,7 @@ DoHide(JNIEnv *env, struct WLFrame *frame)
|
||||
frame->xdg_surface = NULL;
|
||||
frame->xdg_toplevel = NULL;
|
||||
frame->xdg_popup = NULL;
|
||||
frame->wp_viewport = NULL;
|
||||
frame->toplevel = JNI_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -644,6 +687,17 @@ JNIEXPORT void JNICALL Java_sun_awt_wl_WLComponentPeer_nativeStartResize
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_sun_awt_wl_WLComponentPeer_nativeSetSize
|
||||
(JNIEnv *env, jobject obj, jlong ptr, jint width, jint height)
|
||||
{
|
||||
struct WLFrame *frame = jlong_to_ptr(ptr);
|
||||
if (frame->wp_viewport != NULL) {
|
||||
printf("viewport -> %dx%d\n", width, height);
|
||||
wp_viewport_set_destination(frame->wp_viewport, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_sun_awt_wl_WLComponentPeer_nativeSetWindowGeometry
|
||||
(JNIEnv *env, jobject obj, jlong ptr, jint x, jint y, jint width, jint height)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <Trace.h>
|
||||
|
||||
#include "JNIUtilities.h"
|
||||
@@ -37,12 +38,15 @@ typedef struct WLOutput {
|
||||
struct WLOutput * next;
|
||||
|
||||
struct wl_output * wl_output;
|
||||
struct zxdg_output_v1 * zxdg_output;
|
||||
uint32_t id;
|
||||
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t width_logical;
|
||||
int32_t height_logical;
|
||||
int32_t width_mm;
|
||||
int32_t height_mm;
|
||||
|
||||
@@ -138,12 +142,8 @@ wl_output_scale(
|
||||
}
|
||||
|
||||
static void
|
||||
wl_output_done(
|
||||
void *data,
|
||||
struct wl_output *wl_output)
|
||||
NotifyOutputConfigured(WLOutput* output)
|
||||
{
|
||||
WLOutput * output = data;
|
||||
|
||||
JNIEnv *env = getEnv();
|
||||
jobject obj = (*env)->CallStaticObjectMethod(env, geClass, getSingleInstanceMID);
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
@@ -161,6 +161,8 @@ wl_output_done(
|
||||
output->y,
|
||||
output->width,
|
||||
output->height,
|
||||
output->width_logical,
|
||||
output->height_logical,
|
||||
output->width_mm,
|
||||
output->height_mm,
|
||||
(jint)output->subpixel,
|
||||
@@ -169,6 +171,18 @@ wl_output_done(
|
||||
JNU_CHECK_EXCEPTION(env);
|
||||
}
|
||||
|
||||
static void
|
||||
wl_output_done(
|
||||
void *data,
|
||||
struct wl_output *wl_output)
|
||||
{
|
||||
WLOutput * output = data;
|
||||
if (zxdg_output_manager_v1 == NULL) {
|
||||
// When the manager is present we'll wait for another done event (see zxdg_output_done()).
|
||||
NotifyOutputConfigured(output);
|
||||
}
|
||||
}
|
||||
|
||||
struct wl_output_listener wl_output_listener = {
|
||||
.geometry = &wl_output_geometry,
|
||||
.mode = &wl_output_mode,
|
||||
@@ -182,6 +196,47 @@ struct wl_output_listener wl_output_listener = {
|
||||
.scale = &wl_output_scale
|
||||
};
|
||||
|
||||
static void
|
||||
zxdg_output_logical_size(void *data, struct zxdg_output_v1 *zxdg_output_v1, int32_t width, int32_t height)
|
||||
{
|
||||
WLOutput * output = data;
|
||||
output->width_logical = width;
|
||||
output->height_logical = height;
|
||||
}
|
||||
|
||||
static void
|
||||
zxdg_output_done(void *data, struct zxdg_output_v1 *zxdg_output_v1)
|
||||
{
|
||||
WLOutput * output = data;
|
||||
NotifyOutputConfigured(output);
|
||||
}
|
||||
|
||||
static void
|
||||
zxdg_output_logical_position(void *data, struct zxdg_output_v1 *zxdg_output_v1, int32_t x, int32_t y)
|
||||
{
|
||||
// Ignored
|
||||
}
|
||||
|
||||
static void
|
||||
zxdg_output_description(void *data, struct zxdg_output_v1 *zxdg_output_v1, const char *description)
|
||||
{
|
||||
// Ignored
|
||||
}
|
||||
|
||||
static void
|
||||
zxdg_output_name(void *data, struct zxdg_output_v1 *zxdg_output_v1, const char *name)
|
||||
{
|
||||
// Ignored
|
||||
}
|
||||
|
||||
struct zxdg_output_v1_listener zxdg_output_listener = {
|
||||
.logical_position = zxdg_output_logical_position,
|
||||
.logical_size = zxdg_output_logical_size,
|
||||
.description = zxdg_output_description,
|
||||
.name = zxdg_output_name,
|
||||
.done = zxdg_output_done
|
||||
};
|
||||
|
||||
jboolean
|
||||
WLGraphicsEnvironment_initIDs
|
||||
(JNIEnv *env, jclass clazz)
|
||||
@@ -197,7 +252,7 @@ WLGraphicsEnvironment_initIDs
|
||||
CHECK_NULL_RETURN(
|
||||
notifyOutputConfiguredMID = (*env)->GetMethodID(env, clazz,
|
||||
"notifyOutputConfigured",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIIIIIII)V"),
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIIIIIIIIIII)V"),
|
||||
JNI_FALSE);
|
||||
CHECK_NULL_RETURN(
|
||||
notifyOutputDestroyedMID = (*env)->GetMethodID(env, clazz,
|
||||
@@ -207,6 +262,17 @@ WLGraphicsEnvironment_initIDs
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
static void RegisterXdgOutput(WLOutput* output)
|
||||
{
|
||||
assert(zxdg_output_manager_v1 != NULL);
|
||||
|
||||
if (output->zxdg_output == NULL) {
|
||||
output->zxdg_output = zxdg_output_manager_v1_get_xdg_output(zxdg_output_manager_v1, output->wl_output);
|
||||
CHECK_NULL(output->zxdg_output);
|
||||
zxdg_output_v1_add_listener(output->zxdg_output, &zxdg_output_listener, output);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WLOutputRegister(struct wl_registry *wl_registry, uint32_t id)
|
||||
{
|
||||
@@ -218,10 +284,25 @@ WLOutputRegister(struct wl_registry *wl_registry, uint32_t id)
|
||||
output->wl_output = wl_registry_bind(wl_registry, id, &wl_output_interface, 2);
|
||||
if (output->wl_output == NULL) {
|
||||
JNU_ThrowByName(env, "java/awt/AWTError", "wl_registry_bind() failed");
|
||||
return;
|
||||
}
|
||||
wl_output_add_listener(output->wl_output, &wl_output_listener, output);
|
||||
output->next = outputList;
|
||||
outputList = output;
|
||||
|
||||
if (zxdg_output_manager_v1 != NULL) {
|
||||
RegisterXdgOutput(output);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WLOutputXdgOutputManagerBecameAvailable(void)
|
||||
{
|
||||
assert(zxdg_output_manager_v1 != NULL);
|
||||
|
||||
for (WLOutput* output = outputList; output; output = output->next) {
|
||||
RegisterXdgOutput(output);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -237,6 +318,9 @@ WLOutputDeregister(struct wl_registry *wl_registry, uint32_t id)
|
||||
} else {
|
||||
outputList = cur->next;
|
||||
}
|
||||
if (cur->zxdg_output != NULL) {
|
||||
zxdg_output_v1_destroy(cur->zxdg_output);
|
||||
}
|
||||
wl_output_destroy(cur->wl_output);
|
||||
WLOutput * next = cur->next;
|
||||
free(cur->name);
|
||||
|
||||
@@ -30,3 +30,4 @@ void WLOutputRegister(struct wl_registry *wl_registry, uint32_t id);
|
||||
void WLOutputDeregister(struct wl_registry *wl_registry, uint32_t id);
|
||||
uint32_t WLOutputID(struct wl_output *wlOutput);
|
||||
struct wl_output* WLOutputByID(uint32_t id);
|
||||
void WLOutputXdgOutputManagerBecameAvailable(void);
|
||||
|
||||
@@ -64,7 +64,9 @@ struct wl_display *wl_display = NULL;
|
||||
struct wl_shm *wl_shm = NULL;
|
||||
struct wl_compositor *wl_compositor = NULL;
|
||||
struct xdg_wm_base *xdg_wm_base = NULL;
|
||||
struct wp_viewporter *wp_viewporter = NULL;
|
||||
struct xdg_activation_v1 *xdg_activation_v1 = NULL;
|
||||
struct zxdg_output_manager_v1 *zxdg_output_manager_v1 = NULL;
|
||||
struct gtk_shell1* gtk_shell1 = NULL;
|
||||
struct wl_seat *wl_seat = NULL;
|
||||
|
||||
@@ -77,6 +79,7 @@ struct wl_cursor_theme *cursor_themes[MAX_CURSOR_SCALE] = {NULL};
|
||||
struct wl_surface *wl_surface_in_focus = NULL;
|
||||
struct wl_data_device_manager *wl_ddm = NULL;
|
||||
struct zwp_primary_selection_device_manager_v1 *zwp_selection_dm = NULL;
|
||||
struct wp_fractional_scale_manager_v1* wp_fractional_scale_manager = NULL;
|
||||
|
||||
uint32_t last_mouse_pressed_serial = 0;
|
||||
uint32_t last_pointer_enter_serial = 0;
|
||||
@@ -524,8 +527,15 @@ registry_global(void *data, struct wl_registry *wl_registry,
|
||||
wl_ddm = wl_registry_bind(wl_registry, name,&wl_data_device_manager_interface, 3);
|
||||
} else if (strcmp(interface, zwp_primary_selection_device_manager_v1_interface.name) == 0) {
|
||||
zwp_selection_dm = wl_registry_bind(wl_registry, name, &zwp_primary_selection_device_manager_v1_interface, 1);
|
||||
} else if (strcmp(interface, wp_viewporter_interface.name) == 0) {
|
||||
wp_viewporter = wl_registry_bind(wl_registry, name, &wp_viewporter_interface, 1);
|
||||
} else if (strcmp(interface, wp_fractional_scale_manager_v1_interface.name) == 0) {
|
||||
wp_fractional_scale_manager = wl_registry_bind(wl_registry, name, &wp_fractional_scale_manager_v1_interface, 1);
|
||||
} else if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) {
|
||||
zxdg_output_manager_v1 = wl_registry_bind(wl_registry, name, &zxdg_output_manager_v1_interface, 2);
|
||||
WLOutputXdgOutputManagerBecameAvailable();
|
||||
process_new_listener_before_end_of_init();
|
||||
}
|
||||
|
||||
#ifdef WAKEFIELD_ROBOT
|
||||
else if (strcmp(interface, wakefield_interface.name) == 0) {
|
||||
wakefield = wl_registry_bind(wl_registry, name, &wakefield_interface, 1);
|
||||
|
||||
@@ -27,7 +27,10 @@
|
||||
#include <wayland-cursor.h>
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "xdg-activation-v1-client-protocol.h"
|
||||
#include "xdg-output-client-protocol.h"
|
||||
#include "primary-selection-client-protocol.h"
|
||||
#include "viewporter-client-protocol.h"
|
||||
#include "fractional-scale-v1-client-protocol.h"
|
||||
#include "jvm_md.h"
|
||||
#include "jni_util.h"
|
||||
|
||||
@@ -54,12 +57,15 @@ extern struct wl_display *wl_display;
|
||||
extern struct wl_pointer *wl_pointer;
|
||||
extern struct wl_compositor *wl_compositor;
|
||||
extern struct xdg_wm_base *xdg_wm_base;
|
||||
extern struct wp_viewporter *wp_viewporter;
|
||||
extern struct xdg_activation_v1 *xdg_activation_v1;
|
||||
extern struct zxdg_output_manager_v1 *zxdg_output_manager_v1; // optional, check for NULL before use
|
||||
extern struct gtk_shell1* gtk_shell1; // optional, check for NULL before use
|
||||
|
||||
extern struct wl_cursor_theme *wl_cursor_theme;
|
||||
extern struct wl_data_device_manager *wl_ddm;
|
||||
extern struct zwp_primary_selection_device_manager_v1 *zwp_selection_dm;
|
||||
extern struct wp_fractional_scale_manager_v1* wp_fractional_scale_manager; // optional, check for NULL before use
|
||||
|
||||
extern struct wl_surface *wl_surface_in_focus;
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/* Generated by wayland-scanner 1.19.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2022 Kenny Levinsen
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface wp_fractional_scale_v1_interface;
|
||||
|
||||
static const struct wl_interface *fractional_scale_v1_types[] = {
|
||||
NULL,
|
||||
&wp_fractional_scale_v1_interface,
|
||||
&wl_surface_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_fractional_scale_manager_v1_requests[] = {
|
||||
{ "destroy", "", fractional_scale_v1_types + 0 },
|
||||
{ "get_fractional_scale", "no", fractional_scale_v1_types + 1 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_fractional_scale_manager_v1_interface = {
|
||||
"wp_fractional_scale_manager_v1", 1,
|
||||
2, wp_fractional_scale_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_fractional_scale_v1_requests[] = {
|
||||
{ "destroy", "", fractional_scale_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message wp_fractional_scale_v1_events[] = {
|
||||
{ "preferred_scale", "u", fractional_scale_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_fractional_scale_v1_interface = {
|
||||
"wp_fractional_scale_v1", 1,
|
||||
1, wp_fractional_scale_v1_requests,
|
||||
1, wp_fractional_scale_v1_events,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
/* Generated by wayland-scanner 1.19.0 */
|
||||
|
||||
#ifndef FRACTIONAL_SCALE_V1_CLIENT_PROTOCOL_H
|
||||
#define FRACTIONAL_SCALE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_fractional_scale_v1 The fractional_scale_v1 protocol
|
||||
* Protocol for requesting fractional surface scales
|
||||
*
|
||||
* @section page_desc_fractional_scale_v1 Description
|
||||
*
|
||||
* This protocol allows a compositor to suggest for surfaces to render at
|
||||
* fractional scales.
|
||||
*
|
||||
* A client can submit scaled content by utilizing wp_viewport. This is done by
|
||||
* creating a wp_viewport object for the surface and setting the destination
|
||||
* rectangle to the surface size before the scale factor is applied.
|
||||
*
|
||||
* The buffer size is calculated by multiplying the surface size by the
|
||||
* intended scale.
|
||||
*
|
||||
* The wl_surface buffer scale should remain set to 1.
|
||||
*
|
||||
* If a surface has a surface-local size of 100 px by 50 px and wishes to
|
||||
* submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should
|
||||
* be used and the wp_viewport destination rectangle should be 100 px by 50 px.
|
||||
*
|
||||
* For toplevel surfaces, the size is rounded halfway away from zero. The
|
||||
* rounding algorithm for subsurface position and size is not defined.
|
||||
*
|
||||
* @section page_ifaces_fractional_scale_v1 Interfaces
|
||||
* - @subpage page_iface_wp_fractional_scale_manager_v1 - fractional surface scale information
|
||||
* - @subpage page_iface_wp_fractional_scale_v1 - fractional scale interface to a wl_surface
|
||||
* @section page_copyright_fractional_scale_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2022 Kenny Levinsen
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_surface;
|
||||
struct wp_fractional_scale_manager_v1;
|
||||
struct wp_fractional_scale_v1;
|
||||
|
||||
#ifndef WP_FRACTIONAL_SCALE_MANAGER_V1_INTERFACE
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_fractional_scale_manager_v1 wp_fractional_scale_manager_v1
|
||||
* @section page_iface_wp_fractional_scale_manager_v1_desc Description
|
||||
*
|
||||
* A global interface for requesting surfaces to use fractional scales.
|
||||
* @section page_iface_wp_fractional_scale_manager_v1_api API
|
||||
* See @ref iface_wp_fractional_scale_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_fractional_scale_manager_v1 The wp_fractional_scale_manager_v1 interface
|
||||
*
|
||||
* A global interface for requesting surfaces to use fractional scales.
|
||||
*/
|
||||
extern const struct wl_interface wp_fractional_scale_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef WP_FRACTIONAL_SCALE_V1_INTERFACE
|
||||
#define WP_FRACTIONAL_SCALE_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_fractional_scale_v1 wp_fractional_scale_v1
|
||||
* @section page_iface_wp_fractional_scale_v1_desc Description
|
||||
*
|
||||
* An additional interface to a wl_surface object which allows the compositor
|
||||
* to inform the client of the preferred scale.
|
||||
* @section page_iface_wp_fractional_scale_v1_api API
|
||||
* See @ref iface_wp_fractional_scale_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_fractional_scale_v1 The wp_fractional_scale_v1 interface
|
||||
*
|
||||
* An additional interface to a wl_surface object which allows the compositor
|
||||
* to inform the client of the preferred scale.
|
||||
*/
|
||||
extern const struct wl_interface wp_fractional_scale_v1_interface;
|
||||
#endif
|
||||
|
||||
#ifndef WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM
|
||||
enum wp_fractional_scale_manager_v1_error {
|
||||
/**
|
||||
* the surface already has a fractional_scale object associated
|
||||
*/
|
||||
WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS = 0,
|
||||
};
|
||||
#endif /* WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM */
|
||||
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY 0
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_manager_v1
|
||||
*/
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_manager_v1
|
||||
*/
|
||||
#define WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_fractional_scale_manager_v1 */
|
||||
static inline void
|
||||
wp_fractional_scale_manager_v1_set_user_data(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_fractional_scale_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_fractional_scale_manager_v1 */
|
||||
static inline void *
|
||||
wp_fractional_scale_manager_v1_get_user_data(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_fractional_scale_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_fractional_scale_manager_v1_get_version(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_manager_v1
|
||||
*
|
||||
* Informs the server that the client will not be using this protocol
|
||||
* object anymore. This does not affect any other objects,
|
||||
* wp_fractional_scale_v1 objects included.
|
||||
*/
|
||||
static inline void
|
||||
wp_fractional_scale_manager_v1_destroy(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wp_fractional_scale_manager_v1,
|
||||
WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY);
|
||||
|
||||
wl_proxy_destroy((struct wl_proxy *) wp_fractional_scale_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_manager_v1
|
||||
*
|
||||
* Create an add-on object for the the wl_surface to let the compositor
|
||||
* request fractional scales. If the given wl_surface already has a
|
||||
* wp_fractional_scale_v1 object associated, the fractional_scale_exists
|
||||
* protocol error is raised.
|
||||
*/
|
||||
static inline struct wp_fractional_scale_v1 *
|
||||
wp_fractional_scale_manager_v1_get_fractional_scale(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1, struct wl_surface *surface)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_constructor((struct wl_proxy *) wp_fractional_scale_manager_v1,
|
||||
WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE, &wp_fractional_scale_v1_interface, NULL, surface);
|
||||
|
||||
return (struct wp_fractional_scale_v1 *) id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
* @struct wp_fractional_scale_v1_listener
|
||||
*/
|
||||
struct wp_fractional_scale_v1_listener {
|
||||
/**
|
||||
* notify of new preferred scale
|
||||
*
|
||||
* Notification of a new preferred scale for this surface that
|
||||
* the compositor suggests that the client should use.
|
||||
*
|
||||
* The sent scale is the numerator of a fraction with a denominator
|
||||
* of 120.
|
||||
* @param scale the new preferred scale
|
||||
*/
|
||||
void (*preferred_scale)(void *data,
|
||||
struct wp_fractional_scale_v1 *wp_fractional_scale_v1,
|
||||
uint32_t scale);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
*/
|
||||
static inline int
|
||||
wp_fractional_scale_v1_add_listener(struct wp_fractional_scale_v1 *wp_fractional_scale_v1,
|
||||
const struct wp_fractional_scale_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) wp_fractional_scale_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define WP_FRACTIONAL_SCALE_V1_DESTROY 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
*/
|
||||
#define WP_FRACTIONAL_SCALE_V1_PREFERRED_SCALE_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
*/
|
||||
#define WP_FRACTIONAL_SCALE_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_fractional_scale_v1 */
|
||||
static inline void
|
||||
wp_fractional_scale_v1_set_user_data(struct wp_fractional_scale_v1 *wp_fractional_scale_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_fractional_scale_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_fractional_scale_v1 */
|
||||
static inline void *
|
||||
wp_fractional_scale_v1_get_user_data(struct wp_fractional_scale_v1 *wp_fractional_scale_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_fractional_scale_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_fractional_scale_v1_get_version(struct wp_fractional_scale_v1 *wp_fractional_scale_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_fractional_scale_v1
|
||||
*
|
||||
* Destroy the fractional scale object. When this object is destroyed,
|
||||
* preferred_scale events will no longer be sent.
|
||||
*/
|
||||
static inline void
|
||||
wp_fractional_scale_v1_destroy(struct wp_fractional_scale_v1 *wp_fractional_scale_v1)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wp_fractional_scale_v1,
|
||||
WP_FRACTIONAL_SCALE_V1_DESTROY);
|
||||
|
||||
wl_proxy_destroy((struct wl_proxy *) wp_fractional_scale_v1);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Generated by wayland-scanner 1.19.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2013-2016 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface wp_viewport_interface;
|
||||
|
||||
static const struct wl_interface *viewporter_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wp_viewport_interface,
|
||||
&wl_surface_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_viewporter_requests[] = {
|
||||
{ "destroy", "", viewporter_types + 0 },
|
||||
{ "get_viewport", "no", viewporter_types + 4 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_viewporter_interface = {
|
||||
"wp_viewporter", 1,
|
||||
2, wp_viewporter_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message wp_viewport_requests[] = {
|
||||
{ "destroy", "", viewporter_types + 0 },
|
||||
{ "set_source", "ffff", viewporter_types + 0 },
|
||||
{ "set_destination", "ii", viewporter_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface wp_viewport_interface = {
|
||||
"wp_viewport", 1,
|
||||
3, wp_viewport_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,402 @@
|
||||
/* Generated by wayland-scanner 1.19.0 */
|
||||
|
||||
#ifndef VIEWPORTER_CLIENT_PROTOCOL_H
|
||||
#define VIEWPORTER_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_viewporter The viewporter protocol
|
||||
* @section page_ifaces_viewporter Interfaces
|
||||
* - @subpage page_iface_wp_viewporter - surface cropping and scaling
|
||||
* - @subpage page_iface_wp_viewport - crop and scale interface to a wl_surface
|
||||
* @section page_copyright_viewporter Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2013-2016 Collabora, Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_surface;
|
||||
struct wp_viewport;
|
||||
struct wp_viewporter;
|
||||
|
||||
#ifndef WP_VIEWPORTER_INTERFACE
|
||||
#define WP_VIEWPORTER_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_viewporter wp_viewporter
|
||||
* @section page_iface_wp_viewporter_desc Description
|
||||
*
|
||||
* The global interface exposing surface cropping and scaling
|
||||
* capabilities is used to instantiate an interface extension for a
|
||||
* wl_surface object. This extended interface will then allow
|
||||
* cropping and scaling the surface contents, effectively
|
||||
* disconnecting the direct relationship between the buffer and the
|
||||
* surface size.
|
||||
* @section page_iface_wp_viewporter_api API
|
||||
* See @ref iface_wp_viewporter.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_viewporter The wp_viewporter interface
|
||||
*
|
||||
* The global interface exposing surface cropping and scaling
|
||||
* capabilities is used to instantiate an interface extension for a
|
||||
* wl_surface object. This extended interface will then allow
|
||||
* cropping and scaling the surface contents, effectively
|
||||
* disconnecting the direct relationship between the buffer and the
|
||||
* surface size.
|
||||
*/
|
||||
extern const struct wl_interface wp_viewporter_interface;
|
||||
#endif
|
||||
#ifndef WP_VIEWPORT_INTERFACE
|
||||
#define WP_VIEWPORT_INTERFACE
|
||||
/**
|
||||
* @page page_iface_wp_viewport wp_viewport
|
||||
* @section page_iface_wp_viewport_desc Description
|
||||
*
|
||||
* An additional interface to a wl_surface object, which allows the
|
||||
* client to specify the cropping and scaling of the surface
|
||||
* contents.
|
||||
*
|
||||
* This interface works with two concepts: the source rectangle (src_x,
|
||||
* src_y, src_width, src_height), and the destination size (dst_width,
|
||||
* dst_height). The contents of the source rectangle are scaled to the
|
||||
* destination size, and content outside the source rectangle is ignored.
|
||||
* This state is double-buffered, and is applied on the next
|
||||
* wl_surface.commit.
|
||||
*
|
||||
* The two parts of crop and scale state are independent: the source
|
||||
* rectangle, and the destination size. Initially both are unset, that
|
||||
* is, no scaling is applied. The whole of the current wl_buffer is
|
||||
* used as the source, and the surface size is as defined in
|
||||
* wl_surface.attach.
|
||||
*
|
||||
* If the destination size is set, it causes the surface size to become
|
||||
* dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||
* this size. This overrides whatever the attached wl_buffer size is,
|
||||
* unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||
* has no content and therefore no size. Otherwise, the size is always
|
||||
* at least 1x1 in surface local coordinates.
|
||||
*
|
||||
* If the source rectangle is set, it defines what area of the wl_buffer is
|
||||
* taken as the source. If the source rectangle is set and the destination
|
||||
* size is not set, then src_width and src_height must be integers, and the
|
||||
* surface size becomes the source rectangle size. This results in cropping
|
||||
* without scaling. If src_width or src_height are not integers and
|
||||
* destination size is not set, the bad_size protocol error is raised when
|
||||
* the surface state is applied.
|
||||
*
|
||||
* The coordinate transformations from buffer pixel coordinates up to
|
||||
* the surface-local coordinates happen in the following order:
|
||||
* 1. buffer_transform (wl_surface.set_buffer_transform)
|
||||
* 2. buffer_scale (wl_surface.set_buffer_scale)
|
||||
* 3. crop and scale (wp_viewport.set*)
|
||||
* This means, that the source rectangle coordinates of crop and scale
|
||||
* are given in the coordinates after the buffer transform and scale,
|
||||
* i.e. in the coordinates that would be the surface-local coordinates
|
||||
* if the crop and scale was not applied.
|
||||
*
|
||||
* If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||
* Otherwise, if the source rectangle is partially or completely outside of
|
||||
* the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||
* when the surface state is applied. A NULL wl_buffer does not raise the
|
||||
* out_of_buffer error.
|
||||
*
|
||||
* If the wl_surface associated with the wp_viewport is destroyed,
|
||||
* all wp_viewport requests except 'destroy' raise the protocol error
|
||||
* no_surface.
|
||||
*
|
||||
* If the wp_viewport object is destroyed, the crop and scale
|
||||
* state is removed from the wl_surface. The change will be applied
|
||||
* on the next wl_surface.commit.
|
||||
* @section page_iface_wp_viewport_api API
|
||||
* See @ref iface_wp_viewport.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_wp_viewport The wp_viewport interface
|
||||
*
|
||||
* An additional interface to a wl_surface object, which allows the
|
||||
* client to specify the cropping and scaling of the surface
|
||||
* contents.
|
||||
*
|
||||
* This interface works with two concepts: the source rectangle (src_x,
|
||||
* src_y, src_width, src_height), and the destination size (dst_width,
|
||||
* dst_height). The contents of the source rectangle are scaled to the
|
||||
* destination size, and content outside the source rectangle is ignored.
|
||||
* This state is double-buffered, and is applied on the next
|
||||
* wl_surface.commit.
|
||||
*
|
||||
* The two parts of crop and scale state are independent: the source
|
||||
* rectangle, and the destination size. Initially both are unset, that
|
||||
* is, no scaling is applied. The whole of the current wl_buffer is
|
||||
* used as the source, and the surface size is as defined in
|
||||
* wl_surface.attach.
|
||||
*
|
||||
* If the destination size is set, it causes the surface size to become
|
||||
* dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||
* this size. This overrides whatever the attached wl_buffer size is,
|
||||
* unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||
* has no content and therefore no size. Otherwise, the size is always
|
||||
* at least 1x1 in surface local coordinates.
|
||||
*
|
||||
* If the source rectangle is set, it defines what area of the wl_buffer is
|
||||
* taken as the source. If the source rectangle is set and the destination
|
||||
* size is not set, then src_width and src_height must be integers, and the
|
||||
* surface size becomes the source rectangle size. This results in cropping
|
||||
* without scaling. If src_width or src_height are not integers and
|
||||
* destination size is not set, the bad_size protocol error is raised when
|
||||
* the surface state is applied.
|
||||
*
|
||||
* The coordinate transformations from buffer pixel coordinates up to
|
||||
* the surface-local coordinates happen in the following order:
|
||||
* 1. buffer_transform (wl_surface.set_buffer_transform)
|
||||
* 2. buffer_scale (wl_surface.set_buffer_scale)
|
||||
* 3. crop and scale (wp_viewport.set*)
|
||||
* This means, that the source rectangle coordinates of crop and scale
|
||||
* are given in the coordinates after the buffer transform and scale,
|
||||
* i.e. in the coordinates that would be the surface-local coordinates
|
||||
* if the crop and scale was not applied.
|
||||
*
|
||||
* If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||
* Otherwise, if the source rectangle is partially or completely outside of
|
||||
* the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||
* when the surface state is applied. A NULL wl_buffer does not raise the
|
||||
* out_of_buffer error.
|
||||
*
|
||||
* If the wl_surface associated with the wp_viewport is destroyed,
|
||||
* all wp_viewport requests except 'destroy' raise the protocol error
|
||||
* no_surface.
|
||||
*
|
||||
* If the wp_viewport object is destroyed, the crop and scale
|
||||
* state is removed from the wl_surface. The change will be applied
|
||||
* on the next wl_surface.commit.
|
||||
*/
|
||||
extern const struct wl_interface wp_viewport_interface;
|
||||
#endif
|
||||
|
||||
#ifndef WP_VIEWPORTER_ERROR_ENUM
|
||||
#define WP_VIEWPORTER_ERROR_ENUM
|
||||
enum wp_viewporter_error {
|
||||
/**
|
||||
* the surface already has a viewport object associated
|
||||
*/
|
||||
WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS = 0,
|
||||
};
|
||||
#endif /* WP_VIEWPORTER_ERROR_ENUM */
|
||||
|
||||
#define WP_VIEWPORTER_DESTROY 0
|
||||
#define WP_VIEWPORTER_GET_VIEWPORT 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*/
|
||||
#define WP_VIEWPORTER_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*/
|
||||
#define WP_VIEWPORTER_GET_VIEWPORT_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_viewporter */
|
||||
static inline void
|
||||
wp_viewporter_set_user_data(struct wp_viewporter *wp_viewporter, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_viewporter, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_viewporter */
|
||||
static inline void *
|
||||
wp_viewporter_get_user_data(struct wp_viewporter *wp_viewporter)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_viewporter);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_viewporter_get_version(struct wp_viewporter *wp_viewporter)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_viewporter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*
|
||||
* Informs the server that the client will not be using this
|
||||
* protocol object anymore. This does not affect any other objects,
|
||||
* wp_viewport objects included.
|
||||
*/
|
||||
static inline void
|
||||
wp_viewporter_destroy(struct wp_viewporter *wp_viewporter)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wp_viewporter,
|
||||
WP_VIEWPORTER_DESTROY);
|
||||
|
||||
wl_proxy_destroy((struct wl_proxy *) wp_viewporter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewporter
|
||||
*
|
||||
* Instantiate an interface extension for the given wl_surface to
|
||||
* crop and scale its content. If the given wl_surface already has
|
||||
* a wp_viewport object associated, the viewport_exists
|
||||
* protocol error is raised.
|
||||
*/
|
||||
static inline struct wp_viewport *
|
||||
wp_viewporter_get_viewport(struct wp_viewporter *wp_viewporter, struct wl_surface *surface)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_constructor((struct wl_proxy *) wp_viewporter,
|
||||
WP_VIEWPORTER_GET_VIEWPORT, &wp_viewport_interface, NULL, surface);
|
||||
|
||||
return (struct wp_viewport *) id;
|
||||
}
|
||||
|
||||
#ifndef WP_VIEWPORT_ERROR_ENUM
|
||||
#define WP_VIEWPORT_ERROR_ENUM
|
||||
enum wp_viewport_error {
|
||||
/**
|
||||
* negative or zero values in width or height
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_BAD_VALUE = 0,
|
||||
/**
|
||||
* destination size is not integer
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_BAD_SIZE = 1,
|
||||
/**
|
||||
* source rectangle extends outside of the content area
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_OUT_OF_BUFFER = 2,
|
||||
/**
|
||||
* the wl_surface was destroyed
|
||||
*/
|
||||
WP_VIEWPORT_ERROR_NO_SURFACE = 3,
|
||||
};
|
||||
#endif /* WP_VIEWPORT_ERROR_ENUM */
|
||||
|
||||
#define WP_VIEWPORT_DESTROY 0
|
||||
#define WP_VIEWPORT_SET_SOURCE 1
|
||||
#define WP_VIEWPORT_SET_DESTINATION 2
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_SET_SOURCE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*/
|
||||
#define WP_VIEWPORT_SET_DESTINATION_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_wp_viewport */
|
||||
static inline void
|
||||
wp_viewport_set_user_data(struct wp_viewport *wp_viewport, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) wp_viewport, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_wp_viewport */
|
||||
static inline void *
|
||||
wp_viewport_get_user_data(struct wp_viewport *wp_viewport)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) wp_viewport);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
wp_viewport_get_version(struct wp_viewport *wp_viewport)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) wp_viewport);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*
|
||||
* The associated wl_surface's crop and scale state is removed.
|
||||
* The change is applied on the next wl_surface.commit.
|
||||
*/
|
||||
static inline void
|
||||
wp_viewport_destroy(struct wp_viewport *wp_viewport)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wp_viewport,
|
||||
WP_VIEWPORT_DESTROY);
|
||||
|
||||
wl_proxy_destroy((struct wl_proxy *) wp_viewport);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*
|
||||
* Set the source rectangle of the associated wl_surface. See
|
||||
* wp_viewport for the description, and relation to the wl_buffer
|
||||
* size.
|
||||
*
|
||||
* If all of x, y, width and height are -1.0, the source rectangle is
|
||||
* unset instead. Any other set of values where width or height are zero
|
||||
* or negative, or x or y are negative, raise the bad_value protocol
|
||||
* error.
|
||||
*
|
||||
* The crop and scale state is double-buffered state, and will be
|
||||
* applied on the next wl_surface.commit.
|
||||
*/
|
||||
static inline void
|
||||
wp_viewport_set_source(struct wp_viewport *wp_viewport, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wp_viewport,
|
||||
WP_VIEWPORT_SET_SOURCE, x, y, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_wp_viewport
|
||||
*
|
||||
* Set the destination size of the associated wl_surface. See
|
||||
* wp_viewport for the description, and relation to the wl_buffer
|
||||
* size.
|
||||
*
|
||||
* If width is -1 and height is -1, the destination size is unset
|
||||
* instead. Any other pair of values for width and height that
|
||||
* contains zero or negative values raises the bad_value protocol
|
||||
* error.
|
||||
*
|
||||
* The crop and scale state is double-buffered state, and will be
|
||||
* applied on the next wl_surface.commit.
|
||||
*/
|
||||
static inline void
|
||||
wp_viewport_set_destination(struct wp_viewport *wp_viewport, int32_t width, int32_t height)
|
||||
{
|
||||
wl_proxy_marshal((struct wl_proxy *) wp_viewport,
|
||||
WP_VIEWPORT_SET_DESTINATION, width, height);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/* Generated by wayland-scanner 1.22.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2017 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_output_interface;
|
||||
extern const struct wl_interface zxdg_output_v1_interface;
|
||||
|
||||
static const struct wl_interface *xdg_output_unstable_v1_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
&zxdg_output_v1_interface,
|
||||
&wl_output_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_manager_v1_requests[] = {
|
||||
{ "destroy", "", xdg_output_unstable_v1_types + 0 },
|
||||
{ "get_xdg_output", "no", xdg_output_unstable_v1_types + 2 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_output_manager_v1_interface = {
|
||||
"zxdg_output_manager_v1", 3,
|
||||
2, zxdg_output_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_v1_requests[] = {
|
||||
{ "destroy", "", xdg_output_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_output_v1_events[] = {
|
||||
{ "logical_position", "ii", xdg_output_unstable_v1_types + 0 },
|
||||
{ "logical_size", "ii", xdg_output_unstable_v1_types + 0 },
|
||||
{ "done", "", xdg_output_unstable_v1_types + 0 },
|
||||
{ "name", "2s", xdg_output_unstable_v1_types + 0 },
|
||||
{ "description", "2s", xdg_output_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_output_v1_interface = {
|
||||
"zxdg_output_v1", 3,
|
||||
1, zxdg_output_v1_requests,
|
||||
5, zxdg_output_v1_events,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,414 @@
|
||||
/* Generated by wayland-scanner 1.22.0 */
|
||||
|
||||
#ifndef XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
#define XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_xdg_output_unstable_v1 The xdg_output_unstable_v1 protocol
|
||||
* Protocol to describe output regions
|
||||
*
|
||||
* @section page_desc_xdg_output_unstable_v1 Description
|
||||
*
|
||||
* This protocol aims at describing outputs in a way which is more in line
|
||||
* with the concept of an output on desktop oriented systems.
|
||||
*
|
||||
* Some information are more specific to the concept of an output for
|
||||
* a desktop oriented system and may not make sense in other applications,
|
||||
* such as IVI systems for example.
|
||||
*
|
||||
* Typically, the global compositor space on a desktop system is made of
|
||||
* a contiguous or overlapping set of rectangular regions.
|
||||
*
|
||||
* The logical_position and logical_size events defined in this protocol
|
||||
* might provide information identical to their counterparts already
|
||||
* available from wl_output, in which case the information provided by this
|
||||
* protocol should be preferred to their equivalent in wl_output. The goal is
|
||||
* to move the desktop specific concepts (such as output location within the
|
||||
* global compositor space, etc.) out of the core wl_output protocol.
|
||||
*
|
||||
* Warning! The protocol described in this file is experimental and
|
||||
* backward incompatible changes may be made. Backward compatible
|
||||
* changes may be added together with the corresponding interface
|
||||
* version bump.
|
||||
* Backward incompatible changes are done by bumping the version
|
||||
* number in the protocol and interface names and resetting the
|
||||
* interface version. Once the protocol is to be declared stable,
|
||||
* the 'z' prefix and the version number in the protocol and
|
||||
* interface names are removed and the interface version number is
|
||||
* reset.
|
||||
*
|
||||
* @section page_ifaces_xdg_output_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zxdg_output_manager_v1 - manage xdg_output objects
|
||||
* - @subpage page_iface_zxdg_output_v1 - compositor logical output region
|
||||
* @section page_copyright_xdg_output_unstable_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2017 Red Hat Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct wl_output;
|
||||
struct zxdg_output_manager_v1;
|
||||
struct zxdg_output_v1;
|
||||
|
||||
#ifndef ZXDG_OUTPUT_MANAGER_V1_INTERFACE
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_output_manager_v1 zxdg_output_manager_v1
|
||||
* @section page_iface_zxdg_output_manager_v1_desc Description
|
||||
*
|
||||
* A global factory interface for xdg_output objects.
|
||||
* @section page_iface_zxdg_output_manager_v1_api API
|
||||
* See @ref iface_zxdg_output_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_output_manager_v1 The zxdg_output_manager_v1 interface
|
||||
*
|
||||
* A global factory interface for xdg_output objects.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_output_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef ZXDG_OUTPUT_V1_INTERFACE
|
||||
#define ZXDG_OUTPUT_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_output_v1 zxdg_output_v1
|
||||
* @section page_iface_zxdg_output_v1_desc Description
|
||||
*
|
||||
* An xdg_output describes part of the compositor geometry.
|
||||
*
|
||||
* This typically corresponds to a monitor that displays part of the
|
||||
* compositor space.
|
||||
*
|
||||
* For objects version 3 onwards, after all xdg_output properties have been
|
||||
* sent (when the object is created and when properties are updated), a
|
||||
* wl_output.done event is sent. This allows changes to the output
|
||||
* properties to be seen as atomic, even if they happen via multiple events.
|
||||
* @section page_iface_zxdg_output_v1_api API
|
||||
* See @ref iface_zxdg_output_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_output_v1 The zxdg_output_v1 interface
|
||||
*
|
||||
* An xdg_output describes part of the compositor geometry.
|
||||
*
|
||||
* This typically corresponds to a monitor that displays part of the
|
||||
* compositor space.
|
||||
*
|
||||
* For objects version 3 onwards, after all xdg_output properties have been
|
||||
* sent (when the object is created and when properties are updated), a
|
||||
* wl_output.done event is sent. This allows changes to the output
|
||||
* properties to be seen as atomic, even if they happen via multiple events.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_output_v1_interface;
|
||||
#endif
|
||||
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_DESTROY 0
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_manager_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_manager_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_output_manager_v1 */
|
||||
static inline void
|
||||
zxdg_output_manager_v1_set_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_output_manager_v1 */
|
||||
static inline void *
|
||||
zxdg_output_manager_v1_get_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_output_manager_v1_get_version(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_manager_v1
|
||||
*
|
||||
* Using this request a client can tell the server that it is not
|
||||
* going to use the xdg_output_manager object anymore.
|
||||
*
|
||||
* Any objects already created through this instance are not affected.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_output_manager_v1_destroy(struct zxdg_output_manager_v1 *zxdg_output_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_manager_v1,
|
||||
ZXDG_OUTPUT_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_manager_v1
|
||||
*
|
||||
* This creates a new xdg_output object for the given wl_output.
|
||||
*/
|
||||
static inline struct zxdg_output_v1 *
|
||||
zxdg_output_manager_v1_get_xdg_output(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, struct wl_output *output)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_manager_v1,
|
||||
ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1), 0, NULL, output);
|
||||
|
||||
return (struct zxdg_output_v1 *) id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
* @struct zxdg_output_v1_listener
|
||||
*/
|
||||
struct zxdg_output_v1_listener {
|
||||
/**
|
||||
* position of the output within the global compositor space
|
||||
*
|
||||
* The position event describes the location of the wl_output
|
||||
* within the global compositor space.
|
||||
*
|
||||
* The logical_position event is sent after creating an xdg_output
|
||||
* (see xdg_output_manager.get_xdg_output) and whenever the
|
||||
* location of the output changes within the global compositor
|
||||
* space.
|
||||
* @param x x position within the global compositor space
|
||||
* @param y y position within the global compositor space
|
||||
*/
|
||||
void (*logical_position)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1,
|
||||
int32_t x,
|
||||
int32_t y);
|
||||
/**
|
||||
* size of the output in the global compositor space
|
||||
*
|
||||
* The logical_size event describes the size of the output in the
|
||||
* global compositor space.
|
||||
*
|
||||
* Most regular Wayland clients should not pay attention to the
|
||||
* logical size and would rather rely on xdg_shell interfaces.
|
||||
*
|
||||
* Some clients such as Xwayland, however, need this to configure
|
||||
* their surfaces in the global compositor space as the compositor
|
||||
* may apply a different scale from what is advertised by the
|
||||
* output scaling property (to achieve fractional scaling, for
|
||||
* example).
|
||||
*
|
||||
* For example, for a wl_output mode 3840×2160 and a scale factor
|
||||
* 2:
|
||||
*
|
||||
* - A compositor not scaling the monitor viewport in its
|
||||
* compositing space will advertise a logical size of 3840×2160,
|
||||
*
|
||||
* - A compositor scaling the monitor viewport with scale factor 2
|
||||
* will advertise a logical size of 1920×1080,
|
||||
*
|
||||
* - A compositor scaling the monitor viewport using a fractional
|
||||
* scale of 1.5 will advertise a logical size of 2560×1440.
|
||||
*
|
||||
* For example, for a wl_output mode 1920×1080 and a 90 degree
|
||||
* rotation, the compositor will advertise a logical size of
|
||||
* 1080x1920.
|
||||
*
|
||||
* The logical_size event is sent after creating an xdg_output (see
|
||||
* xdg_output_manager.get_xdg_output) and whenever the logical size
|
||||
* of the output changes, either as a result of a change in the
|
||||
* applied scale or because of a change in the corresponding output
|
||||
* mode(see wl_output.mode) or transform (see wl_output.transform).
|
||||
* @param width width in global compositor space
|
||||
* @param height height in global compositor space
|
||||
*/
|
||||
void (*logical_size)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1,
|
||||
int32_t width,
|
||||
int32_t height);
|
||||
/**
|
||||
* all information about the output have been sent
|
||||
*
|
||||
* This event is sent after all other properties of an xdg_output
|
||||
* have been sent.
|
||||
*
|
||||
* This allows changes to the xdg_output properties to be seen as
|
||||
* atomic, even if they happen via multiple events.
|
||||
*
|
||||
* For objects version 3 onwards, this event is deprecated.
|
||||
* Compositors are not required to send it anymore and must send
|
||||
* wl_output.done instead.
|
||||
*/
|
||||
void (*done)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1);
|
||||
/**
|
||||
* name of this output
|
||||
*
|
||||
* Many compositors will assign names to their outputs, show them
|
||||
* to the user, allow them to be configured by name, etc. The
|
||||
* client may wish to know this name as well to offer the user
|
||||
* similar behaviors.
|
||||
*
|
||||
* The naming convention is compositor defined, but limited to
|
||||
* alphanumeric characters and dashes (-). Each name is unique
|
||||
* among all wl_output globals, but if a wl_output global is
|
||||
* destroyed the same name may be reused later. The names will also
|
||||
* remain consistent across sessions with the same hardware and
|
||||
* software configuration.
|
||||
*
|
||||
* Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc.
|
||||
* However, do not assume that the name is a reflection of an
|
||||
* underlying DRM connector, X11 connection, etc.
|
||||
*
|
||||
* The name event is sent after creating an xdg_output (see
|
||||
* xdg_output_manager.get_xdg_output). This event is only sent once
|
||||
* per xdg_output, and the name does not change over the lifetime
|
||||
* of the wl_output global.
|
||||
*
|
||||
* This event is deprecated, instead clients should use
|
||||
* wl_output.name. Compositors must still support this event.
|
||||
* @param name output name
|
||||
* @since 2
|
||||
*/
|
||||
void (*name)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1,
|
||||
const char *name);
|
||||
/**
|
||||
* human-readable description of this output
|
||||
*
|
||||
* Many compositors can produce human-readable descriptions of
|
||||
* their outputs. The client may wish to know this description as
|
||||
* well, to communicate the user for various purposes.
|
||||
*
|
||||
* The description is a UTF-8 string with no convention defined for
|
||||
* its contents. Examples might include 'Foocorp 11" Display' or
|
||||
* 'Virtual X11 output via :1'.
|
||||
*
|
||||
* The description event is sent after creating an xdg_output (see
|
||||
* xdg_output_manager.get_xdg_output) and whenever the description
|
||||
* changes. The description is optional, and may not be sent at
|
||||
* all.
|
||||
*
|
||||
* For objects of version 2 and lower, this event is only sent once
|
||||
* per xdg_output, and the description does not change over the
|
||||
* lifetime of the wl_output global.
|
||||
*
|
||||
* This event is deprecated, instead clients should use
|
||||
* wl_output.description. Compositors must still support this
|
||||
* event.
|
||||
* @param description output description
|
||||
* @since 2
|
||||
*/
|
||||
void (*description)(void *data,
|
||||
struct zxdg_output_v1 *zxdg_output_v1,
|
||||
const char *description);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
static inline int
|
||||
zxdg_output_v1_add_listener(struct zxdg_output_v1 *zxdg_output_v1,
|
||||
const struct zxdg_output_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) zxdg_output_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define ZXDG_OUTPUT_V1_DESTROY 0
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_LOGICAL_POSITION_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_LOGICAL_SIZE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_DONE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_NAME_SINCE_VERSION 2
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*/
|
||||
#define ZXDG_OUTPUT_V1_DESTROY_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_output_v1 */
|
||||
static inline void
|
||||
zxdg_output_v1_set_user_data(struct zxdg_output_v1 *zxdg_output_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_output_v1 */
|
||||
static inline void *
|
||||
zxdg_output_v1_get_user_data(struct zxdg_output_v1 *zxdg_output_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_output_v1_get_version(struct zxdg_output_v1 *zxdg_output_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_output_v1
|
||||
*
|
||||
* Using this request a client can tell the server that it is not
|
||||
* going to use the xdg_output object anymore.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_output_v1_destroy(struct zxdg_output_v1 *zxdg_output_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_output_v1,
|
||||
ZXDG_OUTPUT_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user