![]() |
#1 |
Member
![]() Posts: 23
Karma: 10
Join Date: Feb 2020
Device: Kobo Forma
|
Koreader Emulator on a Macbook (retina display)
I've got Koreader running on a 2017 Macbook with a retina display. The window drawn is four times the size of the actual content (see attachment).
Things work fine on an external monitor, including a 4k one. I've been poking at the source and can't figure out where the window or canvas is created. Could anyone point me at an appropriate place to start looking? Thanks! Jason |
![]() |
![]() |
![]() |
#2 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
SDL2 might need a hint that there's a HiDPI scale factor to be applied somewhere.
(Shot in the dark, HiDPI is a wonderful mess that I'm happy I personally don't have to deal with anywhere for now ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
c.f., https://wiki.libsdl.org/SDL_CreateWindow
Note that we don't actually build a macOS application bundle, so I have no idea how to deal with the plist requirements. |
![]() |
![]() |
![]() |
#4 |
cosiñeiro
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
|
Yup, what NiLuJe said.
brew should contain a SDL version recent enough to support Code:
SDL_WINDOW_ALLOW_HIGHDPI If you want to submit a PR please make sure to OR that flag just Code:
if ffi.os == "OSX" As brew is a rolling release "distro" I'm pretty sure we don't need to check for versions there. |
![]() |
![]() |
![]() |
#5 |
Member
![]() Posts: 23
Karma: 10
Join Date: Feb 2020
Device: Kobo Forma
|
Thanks very much, NiLuJe and pazos. I threw this in (not to submit, just to try):
bit.bor(bit.bor(full_screen and 1 or 0, SDL.SDL_WINDOW_RESIZABLE), SDL.SDL_WINDOW_ALLOW_HIGHDPI) and also had to add this to SDL2_0_h.lua line 853 static const int SDL_WINDOW_ALLOW_HIGHDPI = 4096; I'm not sure if there is any interest in this, but I can submit it as a fix after wrapping things nicely and setting the flags in a nicer way. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Member
![]() Posts: 23
Karma: 10
Join Date: Feb 2020
Device: Kobo Forma
|
Actually spoke too soon. It's not working again. I'll keep poking.
|
![]() |
![]() |
![]() |
#7 |
Member
![]() Posts: 23
Karma: 10
Join Date: Feb 2020
Device: Kobo Forma
|
Setting to 8192 rather than 4096 works. I can't count, apparently.
|
![]() |
![]() |
![]() |
#8 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Don't worry too much about the constant, just add it to the list near the bottom, and as long as you PR from a branch where we can push to, I'll run a rebuild of the autogenerated SDL2_0_h.lua
![]() |
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,751
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
Isn't that SDL's job? I imagine that flag does nothing at all on platforms other than iOS and MacOS? And conversely, if it does do something, surely it should be doing it?
Last edited by Frenzie; 02-28-2020 at 10:28 AM. |
![]() |
![]() |
![]() |
#10 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Yep, it's handled by platform-specific bits wherever it's "needed".
|
![]() |
![]() |
![]() |
#11 |
cosiñeiro
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
|
And probably the flag gets ignored on SDL versions < 2.0.1, but I dunno. My suggestion of wrapping it in osx only was related to avoid sdl version checks, but I wasn't aware of the gorgeous SDL_Linked_Version_AtLeast() function. So using that makes sense even in the case the flag is actually ignored on previous versions.
|
![]() |
![]() |
![]() |
#12 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,751
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
You're aware that SDL 2.0.1 came out about 7 years ago, right?
![]() Edit: I mean, literally the only thing older is SDL 2.0.0. Which came out a few weeks prior. ![]() But fine, closer to 6 than to 7. Doesn't change anything, imo. That's all EOL. Ubuntu 14.04 shipped with 2.0.2. Last edited by Frenzie; 02-28-2020 at 12:26 PM. |
![]() |
![]() |
![]() |
#13 |
Member
![]() Posts: 23
Karma: 10
Join Date: Feb 2020
Device: Kobo Forma
|
My reading of the above is that we should add the HIGHDPI flag when the emulator is running on a retina Macbook. I think the issue is that there is a scaling factor applied to reduce the hardware resolution of 2560 x 1600 to the apparent resolution of 1280 X 800, and leaving this flag out results in the window being created for the apparent resolution and the canvas being created for the hardware resolution.
I added the following code to ffi/SDL2_0.lua -- set up screen (window) if ffi.os == "OSX" then screen_flags = bit.bor(full_screen and 1 or 0, SDL.SDL_WINDOW_RESIZABLE, SDL.SDL_WINDOW_ALLOW_HIGHDPI) else screen_flags = bit.bor(full_screen and 1 or 0, SDL.SDL_WINDOW_RESIZABLE) end S.screen = SDL.SDL_CreateWindow("KOReader", tonumber(os.getenv("KOREADER_WINDOW_POS_X")) or SDL.SDL_WINDOWPOS_UNDEFINED, tonumber(os.getenv("KOREADER_WINDOW_POS_Y")) or SDL.SDL_WINDOWPOS_UNDEFINED, S.w, S.h, screen_flags ) I also removed the declaration of the SDL_WINDOW_ALLOW_HIGHDPI flag from SDL2_0_h.lua and put it in SDL2_0_decl.c. I'm not certain how I should build to test. I've tried running kodev build, and it doesn't recreate the SDL2_0_h.lua file. I also tried kodev clean with the same result. Any pointers on how I should build to test this before putting in a PR? (Sorry for the newbie question - i've never worked with this stuff before.) |
![]() |
![]() |
![]() |
#14 |
cosiñeiro
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,406
Karma: 2451781
Join Date: Apr 2014
Device: BQ Cervantes 4
|
I'm still using SDL1.2 for some stuff. I do never forget that SDL2.0 removed the linux framebuffer support.
![]() On the bright side newer SDL versions paired with DirectFB allow to run SDL thingies without X11. It is actually cool to run graphical things on the Raspberry Pi this way. |
![]() |
![]() |
![]() |
#15 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,751
Karma: 730681
Join Date: Oct 2014
Location: Antwerp
Device: Kobo Aura H2O
|
@pazos But when I put in the PR for removing SDL 1.2 you said something like "be gone legacy stuff /thumbs up" :P
@jbenwell We do that manually with https://github.com/koreader/ffi-cdecl As long as it's in SDL2_0_decl.c it should be fine. Anyway, if you really must put in that condition, you should use the SDL_Linked_Version_AtLeast function I put in place for that very reason. Well, except I implicitly did not intend for it to check for 2.0.1, just for newer than 2.0.4. It's quite possible the program is broken on <2.0.4 because no one's tested that in half a decade. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
iBooks on Mavericks with non-retina display | SamL | Apple Devices | 3 | 01-10-2014 05:25 AM |
Is anyone using the MacBook Pro with Retina display as an eReader? | pata | Apple Devices | 12 | 08-14-2012 11:29 AM |
iPad Apple’s New Retina Display: Do All Those Pixels Matter? | monkeyluis | Apple Devices | 0 | 03-15-2012 08:46 AM |
Rumoured Retina Display on iPad 3 | Skilgannon | Apple Devices | 16 | 03-07-2012 03:29 PM |