Project

General

Profile

window_activation.diff

Hynek Cihlar, 07/22/2016 09:52 AM

Download (3.21 KB)

View differences:

src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2016-07-22 13:38:38 +0000
300 300
         {
301 301
            deiconifyWindow(-1);
302 302
         }
303
      });
304
      
305
      window.addWindowFocusListener(new WindowFocusListener()
306
      {
307
         @Override                                  
308
         public void windowLostFocus(WindowEvent e)
309
         {
310
            boolean toOS = (e.getOppositeWindow() == null);
311
            WindowManager.windowDeactivated(windowId, toOS);
312
         }
313
         
303

  
314 304
         @Override
315
         public void windowGainedFocus(WindowEvent e)
305
         public void windowActivated(WindowEvent e)
316 306
         {
317 307
            // in some cases, when the window is activated, it is not properly focused,
318 308
            // listening on key input on the content pane seems to be more reliable
319 309
            pane.requestFocusInWindow();
320 310
            boolean fromOS = (e.getOppositeWindow() == null);
311
            System.out.println("windowGainedFocus " + windowId);
312
            if (fromOS)
313
            {
314
               System.out.println("fromOS!!");
315
            }
321 316
            WindowManager.windowActivated(windowId, fromOS);
322 317
         }
318

  
319
         @Override
320
         public void windowDeactivated(WindowEvent e)
321
         {
322
            boolean toOS = (e.getOppositeWindow() == null);
323
            System.out.println("windowLostFocus " + windowId);
324
            if (toOS)
325
            {
326
               System.out.println("toOS!!");
327
            }
328
            WindowManager.windowDeactivated(windowId, toOS);
329
         }
330
         
331
         
323 332
      });
333
      
334
//      window.addWindowFocusListener(new WindowFocusListener()
335
//      {
336
//         @Override                                  
337
//         public void windowLostFocus(WindowEvent e)
338
//         {
339
//            boolean toOS = (e.getOppositeWindow() == null);
340
//            System.out.println("windowLostFocus " + windowId);
341
//            if (toOS)
342
//            {
343
//               System.out.println("toOS!!");
344
//            }
345
//            WindowManager.windowDeactivated(windowId, toOS);
346
//         }
347
//         
348
//         @Override
349
//         public void windowGainedFocus(WindowEvent e)
350
//         {
351
//            // in some cases, when the window is activated, it is not properly focused,
352
//            // listening on key input on the content pane seems to be more reliable
353
//            pane.requestFocusInWindow();
354
//            boolean fromOS = (e.getOppositeWindow() == null);
355
//            System.out.println("windowGainedFocus " + windowId);
356
//            if (fromOS)
357
//            {
358
//               System.out.println("fromOS!!");
359
//            }
360
//            WindowManager.windowActivated(windowId, fromOS);
361
//         }
362
//      });
324 363

  
325 364
      window.addWindowStateListener(new WindowStateListener()
326 365
      {
......
1064 1103
   
1065 1104
            if (focus)
1066 1105
            {
1106
               System.out.println("window.requestFocus() " + window);
1067 1107
               window.requestFocus();
1068 1108
            }
1069 1109