4 ms·
Ask HN: Rendering transparent overlay in cross-platform desktop application?
I'm new to desktop GUI development (web developer) and at the simplest level, I'm trying to do the following across Linux, Mac, and Windows:
- Overlay a transparent PNG/SVG & text label on the screen.
- Stay on top of everything else (as much as the OS/window manager allows).
- Ideally, not interfere with user input, but I can work around this.
I've done a ton of digging on this, and these are my main takeaways:
- wxWidgets and TkInter do not support transparency.
- I've gotten a hack to work with GTK/cairo on Linux, but portability of the transparency part doesn't seem likely.
- Electron and friends are in the progress of supporting this sort of use-case, but that seems INSANELY resource intensive for my needs.
- QT and Java seem to be the only two options that even roughly support this, but I'd imagine my third requirement of not interfering with user input can only be accomplished through the respective native APIs.
Given that all I need is an icon and text rendered transparently on the screen, would it be overly ambitious to try to write the "rendering" part low-level and platform specific (X11, WinAPI, Cocoa?), and have something higher level that toggles/abstracts the implementation (either at packaging or runtime, doesn't matter)? Are there any good examples of simple GUI applications that build native UI's for each platform but communicate with them using cross-platform code? Should I just give up and use QT or Java?
I'm definitely not looking for exact code on how to accomplish this, but rather a high level "how would you do it?" from those experienced with cross-platform desktop app development.
Thanks HN!
- dman 10y agoWhat is this overlay meant to do?
- throwawaygui 10y agoEssentially I'm after the same sort of effect they had in Screenhero[0], so showing the location and name of other people's cursors on your screen. 0: http://media02.hongkiat.com/sharescreen-coworking-screenhero/screenhero-sharing.jpg http://media02.hongkiat.com/sharescreen-coworking-screenhero...
- billconan 10y agoUse Qt, it has the thing you need. it doesn't have to handle user input, you can override QT's event loop to do nothing. Qt's event loop is very hackable. https://kernelcoder.wordpress.com/tag/event-handling-in-qt/ https://kernelcoder.wordpress.com/tag/event-handling-in-qt/
- billconan 10y agook, how to do it, use qt for ui. create a frameless window and adjust the transparency of your window to 0.5. as for user input, you can try to override its eventloop, simply ignore and bypass events. I have never tried this myself. if this doesn't work, you might need to do some platform dependent code. for example creating an event filter, capture operating system event before qt does and throw it away. I have done this on windows, but I didn't try this on mac. you can ask on the official qt forum if you have any trouble.