<?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>892</bug_id>
          
          <creation_ts>2013-11-05 16:41:32 +0100</creation_ts>
          <short_desc>Newt and Java focus gained and lost events are inconsistent</short_desc>
          <delta_ts>2013-11-17 04:57:28 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Newt</product>
          <component>windows</component>
          <version>1</version>
          <rep_platform>pc_x86_64</rep_platform>
          <op_sys>windows</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>879</dependson>
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Jesse">narf_bro</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>narf_bro</cc>
          
          <cf_type>---</cf_type>
          <cf_scm_refs>0be87f241c0f0b2f5881d9a602ce12378b8e453d</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3276</commentid>
    <comment_count>0</comment_count>
    <who name="Jesse">narf_bro</who>
    <bug_when>2013-11-05 16:41:32 +0100</bug_when>
    <thetext>Currently I&apos;m unable to rely on the focus listener behaviour. Build: Nov01_2013 2.1.2

If I add a Java FocusListener to the NewtCanvasAWT, focus events behave like this:

- focusLost issued correctly when I lose focus
- focusGained is sometimes followed by focusLost even though the window retains focus if I click in the window. (steps: click back and forth from in window and out, about 25% of the time you&apos;ll get a focusLost after gained even though it still has focus)
- focusGained is always followed by focusLost even though the window retains focus if I click on the program in the taskbar. (steps: click away from window, select the window from the taskbar)

If I add a Newt WindowListener to the glWindow held by my NewtCanvasAWT, focus events behave like this:
- focusLost issued correctly when I lose focus
- focusGained issued correctly when I gain focus
- focusLost and focusGained issued very quickly back to back with every single click inside the window after focus has been gained.

The WindowListener is far more consistent but the back-to-back focusLost/focusGained events make it difficult to trust a focusLost event.

Expected: It should not re-issue a lost/gained event on every click inside the window. It should only issue an event when focus is actually gained or lost.

Workaround: I use the WindowListener and consider focus &quot;actually&quot; lost if it is not immediately followed by a focusGained.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3322</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2013-11-14 21:42:28 +0100</bug_when>
    <thetext>AWT [ NewtCanvasAWT.GLWindow ]:

(Not a bug)

The problem about temp. loosing and re-gaining focus is well known
and more related how we implement focus traversal between GLWindow and the underlying AWT &apos;tree&apos;.

If the GLWindow requires the focus, we need to give it&apos;s AWT component the focus
first - then steal it back and transfer it to GLWindow.
This allows focus traversal back / forth within the AWT tree, 
while allowing GLWindow using the focus.

We maybe able to review the current code .. hence I keep this bug open as an earmark.

Due to a focus traversal change we lately made, 
maybe it&apos;s possible to avoid the focus ping-pong between AWT/GLWindow.
But this is a tedious validation process.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3323</commentid>
    <comment_count>2</comment_count>
    <who name="Jesse">narf_bro</who>
    <bug_when>2013-11-14 21:51:37 +0100</bug_when>
    <thetext>Is it simpler to just not issue the focusGained/Lost events in the case you described, rather than change the underlying functionality? If I have the GLWindow already focused I would not expect that it would issue a lose/regain focus event on every click, since it conceptually never lost focus.

As it stands now, if I want to do something simple like shut off sounds in the game when the user clicks away from the window, I cannot reliably use focusGained/Lost, because they issue even if I have clicked within the window.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3335</commentid>
    <comment_count>3</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2013-11-17 04:57:28 +0100</bug_when>
    <thetext>Fixed w/ fix of Bug 879</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>