forked from isHarryh/Ark-Pets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: native classes and interfaces
- Loading branch information
Showing
12 changed files
with
321 additions
and
278 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
core/src/cn/harryh/arkpets/natives/CoreGraphicsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package cn.harryh.arkpets.natives; | ||
|
||
import com.sun.jna.Library; | ||
import com.sun.jna.Native; | ||
import com.sun.jna.Structure; | ||
import com.sun.jna.platform.mac.CoreFoundation; | ||
|
||
|
||
public class CoreGraphicsHelper { | ||
public static CoreFoundation.CFStringRef kCGWindowNumber; | ||
public static CoreFoundation.CFStringRef kCGWindowLayer; | ||
public static CoreFoundation.CFStringRef kCGWindowBounds; | ||
public static CoreFoundation.CFStringRef kCGWindowName; | ||
public static CoreFoundation.CFStringRef kCGWindowOwnerName; | ||
|
||
public static final int kCGWindowListExcludeDesktopElements = (1 << 4); | ||
public static final int kCGWindowListOptionOnScreenOnly = 1; | ||
|
||
public static final int NSStatusWindowLevel = 25; | ||
public static final int NSNormalWindowLevel = 0; | ||
|
||
public static void initCG() { | ||
kCGWindowNumber = CoreFoundation.CFStringRef.createCFString("kCGWindowNumber"); | ||
kCGWindowBounds = CoreFoundation.CFStringRef.createCFString("kCGWindowBounds"); | ||
kCGWindowLayer = CoreFoundation.CFStringRef.createCFString("kCGWindowLayer"); | ||
kCGWindowName = CoreFoundation.CFStringRef.createCFString("kCGWindowName"); | ||
kCGWindowOwnerName = CoreFoundation.CFStringRef.createCFString("kCGWindowOwnerName"); | ||
} | ||
|
||
public static void freeCG() { | ||
kCGWindowNumber.release(); | ||
kCGWindowLayer.release(); | ||
kCGWindowName.release(); | ||
kCGWindowBounds.release(); | ||
kCGWindowOwnerName.release(); | ||
} | ||
|
||
public interface CGInterface extends Library { | ||
CGInterface INSTANCE = Native.load("CoreGraphics", CGInterface.class); | ||
|
||
CoreFoundation.CFArrayRef CGWindowListCopyWindowInfo(int option, int relativeToWindow); | ||
|
||
CoreFoundation.CFArrayRef CGWindowListCreateDescriptionFromArray(CoreFoundation.CFArrayRef windowArray); | ||
|
||
boolean CGRectMakeWithDictionaryRepresentation(CoreFoundation.CFDictionaryRef dict, CGRect.ByReference rect); | ||
|
||
CoreFoundation.CFDictionaryRef CGSessionCopyCurrentDictionary(); | ||
} | ||
|
||
@Structure.FieldOrder({"origin", "size"}) | ||
public static class CGRect extends Structure { | ||
public CGPoint origin; | ||
public CGSize size; | ||
|
||
public static class ByReference extends CGRect implements Structure.ByReference { | ||
} | ||
|
||
public static class ByValue extends CGRect implements Structure.ByValue { | ||
} | ||
} | ||
|
||
@Structure.FieldOrder({"x", "y"}) | ||
public static class CGPoint extends Structure { | ||
public double x; | ||
public double y; | ||
} | ||
|
||
@Structure.FieldOrder({"width", "height"}) | ||
public static class CGSize extends Structure { | ||
public double width; | ||
public double height; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cn.harryh.arkpets.natives; | ||
|
||
import org.freedesktop.dbus.Struct; | ||
import org.freedesktop.dbus.annotations.DBusInterfaceName; | ||
import org.freedesktop.dbus.annotations.Position; | ||
import org.freedesktop.dbus.interfaces.DBusInterface; | ||
import org.freedesktop.dbus.types.UInt32; | ||
|
||
import java.util.List; | ||
|
||
|
||
@DBusInterfaceName("org.kde.KWin.ArkPets") | ||
public interface KWinDBusInterface extends DBusInterface { | ||
void MoveResize(String uuid, int x, int y, UInt32 width, UInt32 height); | ||
|
||
void Activate(String uuid); | ||
|
||
void Above(String uuid, boolean enable); | ||
|
||
void Stick(String uuid, boolean enable); | ||
|
||
List<DetailsStruct> List(); | ||
|
||
DetailsStruct Details(String winid); | ||
|
||
boolean IsActive(String uuid); | ||
|
||
UInt32 Version(); | ||
|
||
class DetailsStruct extends Struct { | ||
@Position(0) | ||
public final int x; | ||
@Position(1) | ||
public final int y; | ||
@Position(2) | ||
public final UInt32 w; | ||
@Position(3) | ||
public final UInt32 h; | ||
@Position(4) | ||
public final String title; | ||
@Position(5) | ||
public final String wclass; | ||
@Position(6) | ||
public final boolean visible; | ||
@Position(7) | ||
public final String id; | ||
|
||
public DetailsStruct(int x, int y, UInt32 w, UInt32 h, String title, String wClass, boolean visible, String id) { | ||
this.x = x; | ||
this.y = y; | ||
this.w = w; | ||
this.h = h; | ||
this.title = title; | ||
this.wclass = wClass; | ||
this.visible = visible; | ||
this.id = id; | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
core/src/cn/harryh/arkpets/natives/MutterDBusInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cn.harryh.arkpets.natives; | ||
|
||
import org.freedesktop.dbus.Struct; | ||
import org.freedesktop.dbus.annotations.DBusInterfaceName; | ||
import org.freedesktop.dbus.annotations.Position; | ||
import org.freedesktop.dbus.interfaces.DBusInterface; | ||
import org.freedesktop.dbus.types.UInt32; | ||
|
||
import java.util.List; | ||
|
||
|
||
@DBusInterfaceName("org.gnome.Shell.Extensions.ArkPets") | ||
public interface MutterDBusInterface extends DBusInterface { | ||
void MoveResize(UInt32 winid, int x, int y, UInt32 width, UInt32 height); | ||
|
||
void Activate(UInt32 winid); | ||
|
||
void Above(UInt32 winid, boolean above); | ||
|
||
void Stick(UInt32 winid, boolean stick); | ||
|
||
List<DetailsStruct> List(); | ||
|
||
DetailsStruct Details(UInt32 winid); | ||
|
||
boolean IsActive(UInt32 winid); | ||
|
||
String Version(); | ||
|
||
class DetailsStruct extends Struct { | ||
@Position(0) | ||
public final int x; | ||
@Position(1) | ||
public final int y; | ||
@Position(2) | ||
public final UInt32 w; | ||
@Position(3) | ||
public final UInt32 h; | ||
@Position(4) | ||
public final String title; | ||
@Position(5) | ||
public final String wclass; | ||
@Position(6) | ||
public final boolean visible; | ||
@Position(7) | ||
public final UInt32 id; | ||
|
||
public DetailsStruct(int x, int y, UInt32 w, UInt32 h, String title, String wClass, boolean visible, UInt32 id) { | ||
this.x = x; | ||
this.y = y; | ||
this.w = w; | ||
this.h = h; | ||
this.title = title; | ||
this.wclass = wClass; | ||
this.visible = visible; | ||
this.id = id; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.