--
You received this message because you are subscribed to the Google Groups "Java Native Access" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/887d350c-f583-412d-872a-e14da173dffen%40googlegroups.com.
Yes, there is. I’ve implemented it here.
https://github.com/oshi/oshi/blob/master/oshi-core/src/main/java/oshi/driver/mac/WindowInfo.java
with JNA mappings
Haven’t yet submitted this to JNA but will consider it if there’s a desire for it.
--
Hmm... I’d like to see this (and similar stuff) being added to contrib.
Not because I need this particular API but because I can foresee the day when I’ll have to access the Mac port of COM (which is rumored to be available once you have some Office application on the Mac).
I have absolutely no idea if that kind of synergy will actually happen though.
Regards,
Jo
Sensitivity: C2 Internal
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/5A04BBD6-51F7-452A-9EAF-455608D020CE%40gmail.com.
The content of this e-mail is intended only for the
confidential use of the person addressed.
If you are not the intended
recipient, please notify the sender and delete this e-mail immediately.
Thank
you.
Well, JNA is about accessing C-style APIs which have not been made accessible through the JDK in a platform-independent manner, so that’s the kind of trade-off I’d expect from a FFI like JNA: You lose platform-independence, you gain access to platform-specific APIs (and usually you’ll do some kind of platform awareness at higher levels – you don’t expect DDE to work on Mac so you offer another real-time API, for example).
That said, if there’s something in JNA that can be made platform-independent, or merely less platform-dependent, then yes.
I guess progress will be slow though; most developers don’t have both a Windows and a Mac development machine. So I think that independent work on both platforms, with the option of later investigating what can be merged, would be the faster option overall, and the one with earlier successes.
On HWND, from the perspective of an old-time GDI user here: It may be a pointer under the hood, but you can’t dereference it and you shouldn’t do calculations with it. Mapping it in Java as an opaque handle type is the right way to do it; if the equivalent Mac abstraction is indeed a pointer, then the types should be different, if it’s a handle as in Windows, then it could be a HWND – though in that case you may want to have a WindowHandle class that would be a HWND on Windows and whatever the right type is on Mac.
I find the litmus test for such things is the question “what if somebody writes a subclass that is a proxy to such a handle on another machine”? With the idea that you can do the same calls remotely as locally. Are the same calls available? If yes, make it the same type, if not, make it a different one. Is there a subset of common calls, preferably one that has a chance of being a valid abstraction? Make a common superclass for the Windows and the Mac type.
That kind of stuff.
Having some common aspect is an indicator that two classes are in fact related, but one shouldn’t unify unless it gives the caller a clear benefit.
Regards,
Jo
From: jna-...@googlegroups.com <jna-...@googlegroups.com>
On Behalf Of George Grigalashvili
Sent: Dienstag, 27. April 2021 09:05
To: Java Native Access <jna-...@googlegroups.com>
Subject: [External Sender] Re: Is there a way to get the WindowUtils working on macOS?
Thank you guys for the feedback.
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/fe2cc67b-11d5-47b8-a337-c694bad9d1den%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/VI1PR0102MB2734B082CC3D65846A1AE00AB9419%40VI1PR0102MB2734.eurprd01.prod.exchangelabs.com.
The macOS equivalent in this case is a 64-bit integer CFNumber with its type defined as the constant kCGWindowIDCFNumberType. In my cross-platform implementation I just use a long and document that/how it can be cast to an HWND for Windows as a native pointer peer value. The X equivalent is an integer property (not sure if 32- or 64- bit) identified as a “Window ID”. So “WindowID” is an appropriate class/field name, but wrapping a long might be overkill.
Note that an intermediate solution that I’ve done is to have my own cross-platform API and in the case of Windows, just call the existing JNA implementation and add my own features to it, thus my suggestion for a new API in JNA. However, I also focus on an “information” library (think “read only”) so haven’t done the work of trying to implement interactive features like setting transparency, showing windows, etc. It may be that the CoreGraphics library on macOS might not be the best approach for manipulating windows, however, and the earlier links to AppleScript or Accessibility API might be needed.
Dan
To view this discussion on the web visit https://groups.google.com/d/msgid/jna-users/CADgGZ6E%2ByTGwS1D1dW8H2%3D3UWLJ9O0Tu7Ax6rZ4x7_dMVWPBGg%40mail.gmail.com.