Tk Source Code

View Ticket
Login
Ticket UUID: e3b954df689d2a96fc36bb98f93bc6431e1f5fdc
Title: View->Show Tab Bar causes mouse pointer to be offset on macOS
Type: Bug Version:
Submitter: marc_culler Created on: 2018-11-16 19:25:51
Subsystem: 66. Aqua Window Operations Assigned To: marc_culler
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2018-11-24 22:40:10
Resolution: Fixed Closed By: marc_culler
    Closed on: 2018-11-24 22:40:10
Description:
In macOS 10.13 (High Sierra) an option was introduced for an application to show
all of its windows as tabs in the main window. In macOS 10.14 it became the
default for applications to opt in to this feature.  There is a preferences
setting which will make all applications use tabs.  (The default setting is to
use tabs only in full screen mode.)

In those OS's if an application creates a menu named "View" the window manager
will insert items "Show Tab Bar" or "Hide Tab Bar" as appropriate.  If a Tk
application has such a menu, and if the user selects "Show Tab Bar" then a tab
bar will appear on the screen (even if there is only one window).  Once the tab
bar appears, the mouse cursor will be offset from the mouse point vertically,
by the height of the tab bar.  Moreover, if the application is closed in the
"Show Tab Bar" state then it will automatically reopen in the "Show Tab Bar"
state.

I will attach a modified version of the plot demo which demonstrates this.  If
you select "Show Tab Bar" from the View menu you will have to click 1 cm above a
dot to select it.
User Comments: marc_culler (claiming to be Marc Culler) added on 2018-11-24 22:40:10:

This was fixed in the [bug-e3b954df68] branch which also reworked the
implementation of [NSWindow toggleFullScreen]. The branch has been merged
into core-8-6-branch and trunk.


marc_culler (claiming to be Marc Culler) added on 2018-11-18 02:50:10:
I see three problems when I make the plot go full screen.  This is with the
default preferences setting of "Prefer tabs when opening documents In Full Screen Only". 

1. The mouse cursor is offset below the mouse point by about twice as much as
when the tab bar is displayed on a normal window. I am guessing that the offset
is twice the height of a title bar.  (But the tab bar seems to be the same
height as the title bar.)  That is, the window is displaying itself as if it
had both a title bar and a tab bar but in fact it has a hidden title bar and
no tab bar, so its top left corner should actually be at (0,0) in CG coordinates. 

2. When the window is not full screen the View menu has an an active item
"Enter Full Screen".  Selecting this makes the window go full screen.  However,
when the window is full screen the View menu has an "Exit Full Screen" item, but
that item is grayed out, so it cannot be used to return to a normal sized
window.

3. When the window is in "Hide Tab Bar" state, making the window full screen
and then making it go back to its previous size creates a black box at the
bottom which is the height of a title bar. Selecting "Show Tab Bar" and then
selecting "Hide Tab Bar" makes the black box go away. So it would seem that when
the window exits full screen mode it forgets its state and and displays itself
at the bottom left corner of title bar, but with the height that it would be
using if the tab bar were visible.  That is, it computes its top left corner as
if it had no tab bar but it computes its height as if it did have a tab bar.

kevin_walzer added on 2018-11-17 13:46:53:
Because the buggy behavior you are reporting is also visible in the new fullscreen implementation. Make the plot window go fullscreen to confirm.

marc_culler (claiming to be Marc Culler) added on 2018-11-17 13:30:14:
Disabling the tab bar doesn't seem like a solution to me.  My users report that
the tabs are very convenient.  They don't want to get rid of them - they just
want them to work correctly.

I have reports of other related issues which I couldn't demonstrate as easily.
A window with a text widget and a scroll bar can start scrolling incorrectly
when the tab bar appears.  The bottom of the scrollbar is clipped off and it
becomes impossible to scroll to the last line.  This seems to only happen
if the window is resized after the tab bar appears. These issues can be
corrected by minimizing the window and reopening it.

I suspect this will be easy to fix nnce we understand exactly how the geometry
calculatons are going wrong. The [NSWindowTabGroup tabBarVisible] property
might be useful when doing the computations.

I don't understand why this problem should be related in any way to the code
for fullscreen windows.  What does fullscreen have to do with tabs? Please
explain the connection.

kevin_walzer added on 2018-11-17 13:29:11:
Adding the     ApplyWindowAttributeFlagChanges(winPtr, window, oldAttributes,
        wmPtr->flags, 1, 0);
 
before the fullscreen is finalized sets the cursor part correct in fullscreen mode, but the the geometry issue is shifted back to when the window is restored.

kevin_walzer added on 2018-11-17 03:46:18:
Adding this code to the TkMacOSXMakeRealWindowExist method in tkMacOSXWm.c seems to fix the issue of the tab bar displaying, by disabling it: 

 if([window respondsToSelector:@selector(setTabbingMode:)]) {
    [window setTabbingMode:NSWindowTabbingModeDisallowed];
}

The geometry piece is more complicated. This problem with the cursor hitting the right spot did not exist before the fullscreen implementation was revised to remove the unmapping and re-mapping of the windows. That seems essential to allow Tk to correctly register the update window geometry. I experimented with adding that back in, and the geometry is correct with the cursor; you don't see that slight offset. However, the cached window size (before fullscreen) is lost if we re-add the window mapping. There needs to be some way to restore that. I didn't see a problem with revising the implementation because it seemed a bit cleaner and simpler, but this behavior is a regression.

Attachments: