147 // becomes active/inactive. This event should be filtered out for
148 // non-focused applet. This method can be called from different threads.
149 public void handleWindowFocusEvent(boolean parentWindowActive) {
150 this.parentWindowActive = parentWindowActive;
151 // If several applets are running in different browser's windows, it is necessary to
152 // detect the switching between the parent windows and update globalFocusedWindow accordingly.
153 synchronized (classLock) {
154 if (!parentWindowActive) {
155 this.browserWindowFocusedApplet = globalFocusedWindow;
156 }
157 if (parentWindowActive && globalFocusedWindow != this && isParentWindowChanged()) {
158 // It looks like we have switched to another browser window, let's restore focus to
159 // the previously focused applet in this window. If no applets were focused in the
160 // window, we will set focus to the first applet in the window.
161 globalFocusedWindow = (this.browserWindowFocusedApplet != null) ? this.browserWindowFocusedApplet
162 : this;
163 }
164 }
165 // ignore focus "lost" native request as it may mistakenly
166 // deactivate active window (see 8001161)
167 if (globalFocusedWindow == this && parentWindowActive) {
168 responder.handleWindowFocusEvent(parentWindowActive, null);
169 }
170 }
171
172 public boolean isParentWindowActive() {
173 return parentWindowActive;
174 }
175
176 private boolean isParentWindowChanged() {
177 // If globalFocusedWindow is located at inactive parent window or null, we have swithed to
178 // another window.
179 return globalFocusedWindow != null ? !globalFocusedWindow.isParentWindowActive() : true;
180 }
181 }
|
147 // becomes active/inactive. This event should be filtered out for
148 // non-focused applet. This method can be called from different threads.
149 public void handleWindowFocusEvent(boolean parentWindowActive) {
150 this.parentWindowActive = parentWindowActive;
151 // If several applets are running in different browser's windows, it is necessary to
152 // detect the switching between the parent windows and update globalFocusedWindow accordingly.
153 synchronized (classLock) {
154 if (!parentWindowActive) {
155 this.browserWindowFocusedApplet = globalFocusedWindow;
156 }
157 if (parentWindowActive && globalFocusedWindow != this && isParentWindowChanged()) {
158 // It looks like we have switched to another browser window, let's restore focus to
159 // the previously focused applet in this window. If no applets were focused in the
160 // window, we will set focus to the first applet in the window.
161 globalFocusedWindow = (this.browserWindowFocusedApplet != null) ? this.browserWindowFocusedApplet
162 : this;
163 }
164 }
165 // ignore focus "lost" native request as it may mistakenly
166 // deactivate active window (see 8001161)
167 if (globalFocusedWindow == this) {
168 responder.handleWindowFocusEvent(parentWindowActive, null);
169 }
170 }
171
172 public boolean isParentWindowActive() {
173 return parentWindowActive;
174 }
175
176 private boolean isParentWindowChanged() {
177 // If globalFocusedWindow is located at inactive parent window or null, we have swithed to
178 // another window.
179 return globalFocusedWindow != null ? !globalFocusedWindow.isParentWindowActive() : true;
180 }
181 }
|