1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
567 }
568
569 public void inquireCandidatePosition()
570 {
571 Component source = getClientComponent();
572 if (source == null) {
573 return;
574 }
575 // This call should return immediately just to cause
576 // InputMethodRequests.getTextLocation be called within
577 // AWT Event thread. Otherwise, a potential deadlock
578 // could happen.
579 Runnable r = new Runnable() {
580 @Override
581 public void run() {
582 int x = 0;
583 int y = 0;
584 Component client = getClientComponent();
585
586 if (client != null) {
587 if (haveActiveClient()) {
588 Rectangle rc = inputContext.getTextLocation(TextHitInfo.leading(0));
589 x = rc.x;
590 y = rc.y + rc.height;
591 } else {
592 Point pt = client.getLocationOnScreen();
593 Dimension size = client.getSize();
594 x = pt.x;
595 y = pt.y + size.height;
596 }
597 }
598
599 openCandidateWindow(awtFocussedComponentPeer, x, y);
600 }
601 };
602 WToolkit.postEvent(WToolkit.targetToAppContext(source),
603 new InvocationEvent(source, r));
604 }
605
606 // java.awt.Toolkit#getNativeContainer() is not available
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
567 }
568
569 public void inquireCandidatePosition()
570 {
571 Component source = getClientComponent();
572 if (source == null) {
573 return;
574 }
575 // This call should return immediately just to cause
576 // InputMethodRequests.getTextLocation be called within
577 // AWT Event thread. Otherwise, a potential deadlock
578 // could happen.
579 Runnable r = new Runnable() {
580 @Override
581 public void run() {
582 int x = 0;
583 int y = 0;
584 Component client = getClientComponent();
585
586 if (client != null) {
587 if (!client.isShowing()) {
588 return;
589 }
590 if (haveActiveClient()) {
591 Rectangle rc = inputContext.getTextLocation(TextHitInfo.leading(0));
592 x = rc.x;
593 y = rc.y + rc.height;
594 } else {
595 Point pt = client.getLocationOnScreen();
596 Dimension size = client.getSize();
597 x = pt.x;
598 y = pt.y + size.height;
599 }
600 }
601
602 openCandidateWindow(awtFocussedComponentPeer, x, y);
603 }
604 };
605 WToolkit.postEvent(WToolkit.targetToAppContext(source),
606 new InvocationEvent(source, r));
607 }
608
609 // java.awt.Toolkit#getNativeContainer() is not available
|