<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>1249</bug_id>
          
          <creation_ts>2015-10-07 13:33:07 +0200</creation_ts>
          <short_desc>NEWT X11: setVisible(false) IconicState not listening to _NET_WM_STATE_HIDDEN; setVisible(true) not restoring from _NET_WM_STATE_HIDDEN</short_desc>
          <delta_ts>2015-10-10 02:31:21 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Newt</product>
          <component>x11</component>
          <version>2.3.2</version>
          <rep_platform>All</rep_platform>
          <op_sys>linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>blocker</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>1250</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Xerxes Rånby">xerxes</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          
          
          <cf_type>DEFECT</cf_type>
          <cf_scm_refs>jogl dca5d36370ec5eb44998bae593880e3b10cc9a4e
jogl e418a665756af52fe2ca691ca220644e9b27c22c
jogl 8ce5203a581e731d5aa7d553455b04213d94115c
jogl ecdaa59aa48c16a558ec7a0b50df9419a9ccedc1
jogl c61fa44d9a2e2049fec7833990f7bb699545bd15</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>5389</commentid>
    <comment_count>0</comment_count>
    <who name="Xerxes Rånby">xerxes</who>
    <bug_when>2015-10-07 13:33:07 +0200</bug_when>
    <thetext>Reproducible using
Fedora 22 + Gnome shell + OpenJDK 8
Ubuntu 14.04.3 LTS+ Compiz Unity + OpenJDK 7 &amp; OpenJDK 8

Testcase:
com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT
test01CreateVisibleDestroy

This testcase and many similar testcases fail at the assert when transisting from STATE_BIT_VISIBLE true to false. The STATE_BIT_VISIBLE do not get cleared.

        glWindow1.setVisible(false);
        Assert.assertEquals(false, glWindow1.isVisible());

the testcase also fail when using absurd timeouts

        glWindow1.setVisible(false);
        Thread.sleep(7000);
        Assert.assertEquals(false, glWindow1.isVisible());

the window DO get hidden by the setVisible(false)


Example output:
https://gist.github.com/xranby/0d1751b0b0a0647fb576

IRC discussion:
http://jogamp.org/log/irc/jogamp_20151006050515.html#l412

All of these gets fixed on my machine by adding a patch such as this one https://github.com/xranby/jogl/commit/c0179c95a6ec57a618522d6baeadb804d7d1ab9a</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5391</commentid>
    <comment_count>1</comment_count>
    <who name="Xerxes Rånby">xerxes</who>
    <bug_when>2015-10-07 17:51:38 +0200</bug_when>
    <thetext>branch ready to merge:  workaround the issue in Fedora 22 and Ubuntu 
https://github.com/xranby/jogl/commits/Bug1249</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5393</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-07 23:24:08 +0200</bug_when>
    <thetext>1) visibility true -&gt; false only fails on mentioned platforms for child-windows?
2) where visibility false -&gt; true works well for child _and_ top-level windows?
3) hence visibility false -&gt; true always works, and true -&gt; false not for child windows on those platforms?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5396</commentid>
    <comment_count>3</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-07 23:35:25 +0200</bug_when>
    <thetext>(In reply to Xerxes Rånby from comment #1)
&gt; branch ready to merge:  workaround the issue in Fedora 22 and Ubuntu 
&gt; https://github.com/xranby/jogl/commits/Bug1249

this is ofc not acceptable, i.e. we should wait for actual visibility
where it works.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5398</commentid>
    <comment_count>4</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-08 00:37:58 +0200</bug_when>
    <thetext>(In reply to Xerxes Rånby from comment #0)
&gt; This testcase and many similar testcases fail at the assert when transisting
&gt; from STATE_BIT_VISIBLE true to false. The STATE_BIT_VISIBLE do not get
&gt; cleared.

Reproducible w/ Debian 8 and Gnome Shell 3.14.4-1~deb8u1,
while working on same platform w/ KDE</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5399</commentid>
    <comment_count>5</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-08 00:43:07 +0200</bug_when>
    <thetext>#1 - TestParenting01NEWT.test01CreateVisibleDestroy failure 
  - parent top-level glWindow1.setVisible(false) 
    misses visibleChanged(false).
  - glWindow1 has a child window glWindow2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5400</commentid>
    <comment_count>6</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-08 00:58:03 +0200</bug_when>
    <thetext>(In reply to Sven Gothel from comment #5)
&gt; #1 - TestParenting01NEWT.test01CreateVisibleDestroy failure 
&gt;   - parent top-level glWindow1.setVisible(false) 
&gt;     misses visibleChanged(false).
&gt;   - glWindow1 has a child window glWindow2

the setVisible(false) on parent is performed via:
  WM_CHANGE_STATE_IDX + IconicState -&gt; _MASK_NET_WM_STATE_HIDDEN

and indeed, we do receive an event other than UnmapNotify:

X11: reconfigureWindow0 X (full)
X11: event . ConfigureNotify call 0x2800002 (parent 0x2800002, above (nil)) 2879/206 640x480 0, child-event: 0
NewtWindows_updateInsets: insets by _NET_FRAME_EXTENTS [ l 1, r 1, t 39, b 1 ]
...... [0] -&gt; [8/24]: _NET_WM_STATE_HIDDEN
**************** X11: WM_STATE of 0x2800002: 0x100


This is a regression of commit 2d837a7a7130702ad36b694875613fae77c7ef06,
which utilizes WM_CHANGE_STATE_IDX + IconicState for visibility
on parent windows.

Notice commit 4a9f65b176d618a8816eff6d24e683c56a4d8086,
which also disabled WM_CHANGE_STATE_IDX + IconicState
for child windows due to similar issue.
Well, we can leave that in, i.e. using Unmap, since child windows
disappearance shall not be animated.

Proposed fix:
  We also have to listen to _NET_WM_STATE_HIDDEN to trigger visibilityChanged()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5401</commentid>
    <comment_count>7</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-08 00:59:27 +0200</bug_when>
    <thetext>This is now a P1 + blocker, b/c this is confirmed to be a regression
which can break NEWT on many platforms, see comment 6.

Thx to Xerxes for this crucial finding!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5405</commentid>
    <comment_count>8</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-08 20:15:30 +0200</bug_when>
    <thetext>commit dca5d36370ec5eb44998bae593880e3b10cc9a4e:

Using Gnome Shell 3.14.4-1~deb8u1 disclosed an issue w/ our newly utilized IconicState/_NET_WM_STATE_HIDDEN,
i.e. visibleChanged(false) was never received.

This is a regression of commit 2d837a7a7130702ad36b694875613fae77c7ef06,
which utilizes WM_CHANGE_STATE_IDX + IconicState for visibility
on top-level windows.

This bug consist out of _two_ isssue:

1) setVisible(false) IconicState not listening to _NET_WM_STATE_HIDDEN
  Here, we &apos;listen&apos; to _NET_WM_STATE_HIDDEN when receiving ConfigureNotify
  if supported _and_ XMapWindow has been issued.
  In such case existence/non-existence of _NET_WM_STATE_HIDDEN determines visibility.
  Otherwise, we have wait for MapNotify/UnmapNotify.

  The &apos;XMapWindow has been issued&apos; criteria is tracked by new field &apos;JavaWindow.isMapped&apos;
  and set/cleared when we actually issue XMapWindow/XUnmapWindow!

2) setVisible(true) not restoring from _NET_WM_STATE_HIDDEN
  It has been observed that restoring IconicState/_NET_WM_STATE_HIDDEN
  via XMapWindow or even NormalState may not work reliably on WMs.
  See &lt;https://stackoverflow.com/questions/30192347/how-to-restore-a-window-with-xlib&gt;

  Hence we restore from this WM state via NormalState _and_ _NET_ACTIVE_WINDOW.

Both strategies seem to work well on KDE as well as on Gnome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5406</commentid>
    <comment_count>9</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-08 21:28:29 +0200</bug_when>
    <thetext>Reopening ..

1/10 tests w/ gnome-shell fails to detect visible -&gt; false,
see:

XXX VISIBLE.1 -&gt; FALSE
X11: reconfigureWindow0 dpy 0x1b5b1a0, scrn 0, parent (nil)/0x177, win 0x2800002, 1405/157 512x512, parentChange 0, isChild 0, undecorated[change 0, val 0], fullscreen[change 0, val 0 (span 0)], alwaysOn[Top[change 0, val 0], Bottom[change 0, val 0]], visible[change 1, val 0, tempInvisible 0], resizable[change 0, val 1], sticky[change 0, val 0], fsEWMHFlags 0
X11: reconfigureWindow0 setPosSize 1405/157 512x512
X11: reconfigureWindow0 VISIBLE OFF
X11: setVisible -&gt; 0, useWM: 1, wait 0, window 0x2800002
X11: reconfigureWindow0 X (full)
X11: event . ConfigureNotify call 0x2800002 (parent 0x2800002, above (nil)) 1406/196 512x512 0, child-event: 0
...... [0] -&gt; [13/25]: _NET_WM_STATE_FOCUSED
**************** X11: WM_STATE of 0x2800002: 1 props -&gt; 0x2000
X11: event . ConfigureNotify call 0x2800002 - isMapped 1, visibleChanged 1, map_state 2
NewtWindows_updateInsets: insets by _NET_FRAME_EXTENTS [ l 1, r 1, t 39, b 1 ]
X11: event . FocusOut call 0x2800002
++++ TestCase.tearDown: com.jogamp.opengl.test.junit.newt.TestGLWindows00NEWT - test11WindowSimpleToggleVisibility</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5410</commentid>
    <comment_count>10</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-09 01:57:14 +0200</bug_when>
    <thetext>NEWT X11: setVisible(*) _NET_WM_STATE_HIDDEN update not received 
at ConfigureNotify event (2)

On gnome shell WM, sometimes KDE WM,
it has been observed that the _NET_WM_STATE_HIDDEN update (visible or invisible)
is not received at ConfigureNotify event.

Turns out the state is finally updated at FocusOut!

This change tests _NET_WM_STATE_HIDDEN visibility hint
for mapped window also for FocusIn and FocusOut events,
besides the ConfigureNotify event.

Further more, NormalState to restore a hidden but mapped
window did not work, so it is no more being sent.
We limit us here to _NET_ACTIVE_WINDOW.

2 unit tests are prepared to test this issue:
  - TestGLWindows00NEWT
  - TestParenting01NEWT</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5411</commentid>
    <comment_count>11</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-09 02:04:19 +0200</bug_when>
    <thetext>jogl 8ce5203a581e731d5aa7d553455b04213d94115c:
Revert TestParenting01NEWT durationPerTest back to 600 (otherwise breaks test)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5412</commentid>
    <comment_count>12</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-09 02:04:56 +0200</bug_when>
    <thetext>On KDE .. this time ..

X11: setVisible -&gt; 1, useWM: 1, wait 0, window 0x6600004
X11: reconfigureWindow0 setPosSize.2 0/1649 320x240
X11: reconfigureWindow0 X (full)
X11: event . ConfigureNotify call 0x6600004 (parent 0x6600004, above (nil)) 2/1676 320x240 0, child-event: 0
...... [0] -&gt; [8/25]: _NET_WM_STATE_HIDDEN
...... [1] -&gt; [12/25]: _NET_WM_STATE_DEMANDS_ATTENTION
**************** X11: WM_STATE of 0x6600004: 2 props -&gt; 0x1100
X11: event . ConfigureNotify call 0x6600004 - isMapped 1, visibleChanged 0, map_state 0
NewtWindows_updateInsets: insets by _NET_FRAME_EXTENTS [ l 2, r 2, t 27, b 4 ]
X11: event . ConfigureNotify call 0x6600004 (parent 0x6600004, above (nil)) 2/1676 320x240 0, child-event: 0
...... [0] -&gt; [8/25]: _NET_WM_STATE_HIDDEN
...... [1] -&gt; [12/25]: _NET_WM_STATE_DEMANDS_ATTENTION
**************** X11: WM_STATE of 0x6600004: 2 props -&gt; 0x1100
X11: event . ConfigureNotify call 0x6600004 - isMapped 1, visibleChanged 0, map_state 0
NewtWindows_updateInsets: insets by _NET_FRAME_EXTENTS [ l 2, r 2, t 27, b 4 ]
XXXX: Visibility not reached as requested within 1000ms : requested true, is false
XXXX: FREEZE</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5413</commentid>
    <comment_count>13</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-09 02:26:39 +0200</bug_when>
    <thetext>jogl ecdaa59aa48c16a558ec7a0b50df9419a9ccedc1:

NEWT X11: setVisible(false) IconicState/_NET_WM_STATE_HIDDEN: Handle case where KDE unmaps the window

Update our internal JavaWindow.isMapped according to MapNotify and UnmapNotify.
This takes care of a situation (KDE) where a window is unmapped
during IconicState.

For unmapped windows we cannot interprete _NET_WM_STATE_HIDDEN
and we have to issue XMapWindow for restoring the window.

+++

Closing for now .. seems to be working well on KDE and Gnome.

Pls reopen, if issues still exists.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5425</commentid>
    <comment_count>14</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-09 22:24:04 +0200</bug_when>
    <thetext>Bug 1250 documents same issue ..</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5431</commentid>
    <comment_count>15</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-10 02:30:51 +0200</bug_when>
    <thetext>*** Bug 1250 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5432</commentid>
    <comment_count>16</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-10-10 02:31:21 +0200</bug_when>
    <thetext>commit c61fa44d9a2e2049fec7833990f7bb699545bd15:

NEWT/X11 Visibility: Listening to more events for updated state
and Adding QUIRK_BIT_VISIBILITY

1) More visibility detection on post ConfigureNotify events,
since the latter may not yet contain the updated visibility state
as it whould (WM bug!):
  - EnterNotify
  - LeaveNotify
  - Disabled
    - Expose
    - VisibilityNotify

2) Introducing quirks.
   Setting QUIRK_BIT_VISIBILITY to handle the issue where
   visibility -&gt; false could not even be set.

These changes also fix issues of Bug 1250
via the QUIRK: 
  - Gnome TestDisplayLifecycle02 setVisible(false) failure</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>