Tk Source Code

View Ticket
Login
Ticket UUID: d95e5d8f16dbee75cd4e2e6c92329bb5bfdda910
Title: hidden panes in panedwindow incorrectly trigger <Map> events
Type: Bug Version: 8.6.5
Submitter: griffin Created on: 2016-03-10 02:02:20
Subsystem: 21. [panedwindow] Assigned To: fvogel
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2016-03-11 08:26:17
Resolution: Fixed Closed By: fvogel
    Closed on: 2016-03-11 08:26:17
Description:
When a panedwindow is mapped, it triggers a <Map> event for *all* of it's slaves, event those configured has hidden (-hide 1).  This is incorrect since the hidden panes are not (supposed to be) displayed, and they are not, but there is still the <Map> event. 

Here's a test case that illustrates problem:


proc report_map {w} {
    puts "<Map> $w : is mapped? [winfo ismapped $w]"
    
}

proc check_map {} {
    update idletasks
    foreach w [winfo children .] {
        puts "$w is mapped? [winfo ismapped $w]"
    }
}

panedwindow .p1 -sashrelief raised
panedwindow .p2 -sashrelief raised

label .l1 -text Label1
label .l2 -text Label2
label .l3 -text Label3
bind Label <Map> {report_map %W}

.p2 add .l2 -sticky nsew
.p2 add .l3 -sticky nsew
.p1 add .p2 -sticky nsew
.p1 add .l1 -sticky nsew

pack .p1 -side top -expand 1 -fill both

puts "All in!"
update idletasks
check_map

puts "hide .l1"
.p2 paneconfigure .l1 -hide 1

update idletasks
check_map

puts "hide .p2"
.p1 paneconfigure .p2 -hide 1

update idletasks
check_map

puts "show .p2"
.p1 paneconfigure .p2 -hide 0

update idletasks
check_map

puts "done"
exit
User Comments: fvogel added on 2016-03-11 08:26:17:
Test case added, everything merged to trunk and core-8-6-branch.

Thanks again for the clear identification of the problem, the easy to understand test case, and the correct patch! I had nothing to do on this one :-)

fvogel added on 2016-03-10 07:33:12:
Thanks for the patch. I have put it in branch bug-d95e5d8f16.

The test suite is still happy with this patch (on Windows Vista at least). I plan to add a test case corresponding to the present ticket.

griffin added on 2016-03-10 02:05:13:
Here's a patch that solves the problem:

$ diff -c tk8.6.x/generic/tkPanedWindow.c tk8.6.5/generic/tkPanedW>
*** tk8.6.x/generic/tkPanedWindow.c     2016-01-29 13:40:55.537003000 -0800
--- tk8.6.5/generic/tkPanedWindow.c     2016-03-09 17:46:18.089916000 -0800
***************
*** 1370,1380 ****
        DestroyPanedWindow(pwPtr);
      } else if (eventPtr->type == UnmapNotify) {
          for (i = 0; i < pwPtr->numSlaves; i++) {
!             Tk_UnmapWindow(pwPtr->slaves[i]->tkwin);
          }
      } else if (eventPtr->type == MapNotify) {
          for (i = 0; i < pwPtr->numSlaves; i++) {
!             Tk_MapWindow(pwPtr->slaves[i]->tkwin);
          }
      }
  }
--- 1370,1384 ----
        DestroyPanedWindow(pwPtr);
      } else if (eventPtr->type == UnmapNotify) {
          for (i = 0; i < pwPtr->numSlaves; i++) {
!             if (! pwPtr->slaves[i]->hide) {
!                 Tk_UnmapWindow(pwPtr->slaves[i]->tkwin);
!             }
          }
      } else if (eventPtr->type == MapNotify) {
          for (i = 0; i < pwPtr->numSlaves; i++) {
!             if (! pwPtr->slaves[i]->hide) {
!                 Tk_MapWindow(pwPtr->slaves[i]->tkwin);
!             }
          }
      }
  }