Menu

#134 TkAqua: handle resolution independent UI in Tiger+

open-remind
5
2006-04-05
2003-09-21
No

In Mac OS X Aqua, Tk assumes 72 DPI resolution. Many
macs have higher resolution, though. This patch correctly
finds the screen size, and thereby the correct tk scaling.

Discussion

  • Revar Desmera

    Revar Desmera - 2003-09-22
     
  • Revar Desmera

    Revar Desmera - 2003-09-22

    Logged In: YES
    user_id=6331

    Sorry, I thought I uploaded the diff before, but it doesn't seem to
    have uploaded. That's okay, this gave me a chance to clean up
    the fix a bit more.

     
  • Revar Desmera

    Revar Desmera - 2003-09-22

    Logged In: YES
    user_id=6331

    The new diff patch is now uploaded.

     
  • Donal K. Fellows

    • assigned_to: gbjsmith --> das
     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    Just a note to say that I thoroughly approve of getting the
    DPI right by default. It's a shame that its so hard to do
    across so many platforms, but that's life (and why [tk
    scaling] isn't a read-only interface...)

    The alterations to tkMacOSXStubs.c look OK to me from a
    casual glance (I don't know the API itself, but it looks likely
    and I presume you got that right! :^) but I'm less sure about
    the alterations to the default fonts; let's not mix up one thing
    for another unnecessarily...

     
  • Revar Desmera

    Revar Desmera - 2003-09-22

    Logged In: YES
    user_id=6331

    I originally did it without the default font changes, and it looked
    _realllllly_ bad on my 100dpi screen. Labels would use normal
    sized fonts, and text, entry, or listbox widgets would use HUGE
    fonts. By changing from the hardcoded fonts to the system
    selected fonts, it looked much much cleaner, by default, and
    should look as good whatever the DPI setting, as it will be using
    the standard OS X system fonts.

     
  • Donal K. Fellows

    • priority: 5 --> 7
     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    OK. So it does make a difference and for sensible reasons.
    No problem. :^)

     
  • Donal K. Fellows

    • priority: 7 --> 8
     
  • Daniel A. Steffen

    Logged In: YES
    user_id=90580

    Jim,

    could you possibly take a look at this and see if it should go into
    8.4.5?
    I'm somewhat unsure about the potential consequences of this
    change esp w.r.t to legacy code that has fixed font sizes, it's not
    by accident that the default fonts needed to be changed in this
    patch to look good... maybe this needs to wait for 8.5 or 9.0 ?

     
  • Daniel A. Steffen

    • assigned_to: das --> wolfsuit
     
  • Daniel A. Steffen

    Logged In: YES
    user_id=90580

    comments about the patch:
    - unused vars
    double horizontalDPI, verticalDPI;
    - a priori, there is no need to go to IOKit for this information,
    the ppi of the main device is available via quickdraw in
    (*(*graphicsDevice)->gdPMap)->hRes resp (*(*graphicsDevice)-
    >gdPMap)->vRes
    (but using CG may still be useful for forwards compatibility/
    proper support for multiple displays)

     
  • Jim Ingham

    Jim Ingham - 2003-11-22

    Logged In: YES
    user_id=169107

    I must be missing something, but when I add this patch, then put a
    text widget with -font {Courier 12} up next to a TextEdit window
    with Courier 12, the text in the text widget looks huge compared
    to the TextEdit window.

     
  • Revar Desmera

    Revar Desmera - 2005-03-14

    Logged In: YES
    user_id=6331

    I have come to realize that what people want here is not accurate DPI,
    because that makes fonts look large on high DPI displays, wasting screen
    real-estate. And they're right, I guess. After thinking on this a while, I
    realized that leaving the mac at 72 DPI is probably best. I withdraw this
    patch.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2006-03-29

    Logged In: YES
    user_id=72656

    It would be nice to separate font DPI dependence, but that's
    not the case now.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2006-03-29
    • status: open --> closed
     
  • Nobody/Anonymous

    Logged In: NO

    Wouldn't it be good to get this patch in anyway, so that
    TkAqua behaves roughly the same as WinTk, Xwin-Tk? (I
    appreciate in the future, when we all have 200dpi displays,
    that further work may be needed on all platforms, but at
    least we'll have a reasonably common basis).

    Vince.

     
  • Daniel A. Steffen

    Logged In: YES
    user_id=90580

    Vince,

    I don't think this patch is the right way to go.
    Mac OS X will have resolution independent UI in a future release (maybe in
    Leopard, as it's already present as a dev test feature in Tiger), but until that's
    fully baked, native widgets can only be drawn at 72 dpi.
    It makes no sense IMO to set Tk's dpi to something it cannot draw the native
    widgets in, that's exactly what causes the ugliness that revar observed and
    that led him to need to change default font sizes for things to look good...
    We will have to take a look into the new resolution independent UI support to
    see which mode use for TkAqua, I suspect until we move to HIView based
    drawing, we'll have to use "Application Scaling":
    http://developer.apple.com/releasenotes/GraphicsImaging/
    ResolutionIndependentUI.html
    http://developer.apple.com/releasenotes/Carbon/HIToolbox.html

     
  • Daniel A. Steffen

    Logged In: YES
    user_id=90580

    make that last url
    http://developer.apple.com/releasenotes/Carbon/
    CarbonResolutionIndependence.html

     
  • Daniel A. Steffen

    • summary: DPI fix for OS X --> TkAqua: handle resolution independent UI in Tiger+
    • priority: 8 --> 5
    • assigned_to: wolfsuit --> das
    • status: closed --> open-remind
     
  • Daniel A. Steffen

    Logged In: YES
    user_id=90580

    I experimented briefly with the resolution independent UI APIs in Tiger, the
    patch below makes Tk use the "Application Scaling" mode and sets the
    physical screen size to the correct value when scaled, however, things are
    very broken with this when UI scaling is turned on in Quartz Debug.
    This may well be due to b ugs in Tiger, but Tk also does not appear to use
    the screen->mwidth & screen->mheight enough to make everything work
    properly (I'm sure macosx specific code is largely at fault there...)

    Leaving this open as a future project to look into when the resolution
    independent UI story becomes clearer...

    Index: macosx/tkMacOSXWm.c

    ====================
    RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXWm.c,v
    retrieving revision 1.24
    diff -u -p -r1.24 tkMacOSXWm.c
    --- macosx/tkMacOSXWm.c 24 Mar 2006 14:58:01 -0000 1.24
    +++ macosx/tkMacOSXWm.c 5 Apr 2006 01:41:37 -0000
    @@ -267,6 +267,10 @@ TkWmNewWindow(
    wmPtr->style = -1;
    wmPtr->macClass = kDocumentWindowClass;
    wmPtr->attributes = kWindowStandardDocumentAttributes;
    +#if defined(MAC_OS_X_VERSION_10_4) && \ + (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    + wmPtr->attributes |= kWindowApplicationScaledAttribute;
    +#endif
    wmPtr->scrollWinPtr = NULL;
    winPtr->wmInfoPtr = wmPtr;

    Index: macosx/tkMacOSXXStubs.c

    ====================
    RCS file: /cvsroot/tktoolkit/tk/macosx/tkMacOSXXStubs.c,v
    retrieving revision 1.15
    diff -u -p -r1.15 tkMacOSXXStubs.c
    --- macosx/tkMacOSXXStubs.c 24 Mar 2006 14:58:01 -0000 1.15
    +++ macosx/tkMacOSXXStubs.c 5 Apr 2006 01:41:37 -0000
    @@ -97,8 +97,19 @@ TkMacOSXDisplayChanged(Display *display)
    screen->width = (*graphicsDevice)->gdRect.right -
    (*graphicsDevice)->gdRect.left;

    +#if defined(MAC_OS_X_VERSION_10_4) && \ + (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
    + {
    + HISize screensize = {screen->width, screen->height};
    + HISizeConvert(&screensize, kHICoordSpace72DPIGlobal, NULL,
    + kHICoordSpaceScreenPixel, NULL);
    + screen->mwidth = screensize.width * 25.4 / 72 + .5;
    + screen->mheight = screensize.height * 25.4 / 72 + .5;
    + }
    +#else
    screen->mwidth = (screen->width * 254 + 360) / 720;
    screen->mheight = (screen->height * 254 + 360) / 720;
    +#endif
    }

    /*

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.