Open dognotdog opened 8 years ago
afaiu Cairo on OSX, it asks for a Quartz surface and uses this. I'd guess the resolution is already decided in the initilisation of the Tk window.
The reason I think it's something to do with surface creation is that a TreeView, for example, does use native size pixels. I've tried looking through the Canvas creation sequence in Tk.jl and Cairo.jl as well as digging a bit in the Tk sources, but it's all convoluted enough that I failed to find out where things go awry, so far.
In the meantime, I'm trying to bring up a native window with a Quartz drawable via Julia's FFI to figure out how to do it, but that's still in progress.
So, drawing into a plain NSView via overriding -drawRect: with the Julia FFI and objc runtime yields correct drawing results, eg. the drawable has a HiDPI resolution without having to do any special setup to get that.
So where in the setup process of the Cairo Canvas is the error?
Could you please spend a few lines, what you want to do and how this looks in code? I had no time to look into the details. but it could be that Cairo is somehow put into the mode to render to a bitmap which is copied to screen and the window size isn't reported correctly as there are many layers of indirection (OSX, TK, Quartz 2D, libcairo).
I would try with a GTK or Qt window and see whether the issue persists. Tk isn't the most actively developed toolkit around.
The Gtk.jl Canvas provides double-buffering via drawing to an image (pixel) surface by default and i fear we see the same problem. But this default can be bypassed and the underlying rendering stage can be accessed.
Unfortunately, I haven't done anything with Tk/Gtk/Qt outside of Julia, so I've not the faintest clue how a HiDPI option should be passed. I know Tk is the old dog of the bunch, but it was the only one I could get working mostly right on short notice.
It seems like creating a simple Cairo surface in a Tk window (as in the Tk examples) doesn't use native pixels on a scaled display (in my case a Retina MacBook with OS X 10.10).
Is there some way to a) query the native pixel size, and b) to set the surface to have native resolution instead of scaled?