< prev index next >

src/java.desktop/unix/classes/sun/awt/X11InputMethodBase.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2018, 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


 494                                            int chgOffset,
 495                                            int chgLength,
 496                                            int caretPosition,
 497                                            long when);
 498 
 499     /**
 500      * Flushes composed and committed text held in this context.
 501      * This method is invoked in the AWT Toolkit (X event loop) thread context
 502      * and thus inside the AWT Lock.
 503      */
 504     // NOTE: This method may be called by privileged threads.
 505     //       This functionality is implemented in a package-private method
 506     //       to insure that it cannot be overridden by client subclasses.
 507     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 508     void flushText() {
 509         String flush = (committedText != null ? committedText : "");
 510         if (composedText != null) {
 511             flush += composedText.toString();
 512         }
 513 
 514         if (!flush.equals("")) {
 515             AttributedString attrstr = new AttributedString(flush);
 516             postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
 517                                  attrstr.getIterator(),
 518                                  flush.length(),
 519                                  null,
 520                                  null,
 521                                  EventQueue.getMostRecentEventTime());
 522             composedText = null;
 523             committedText = null;
 524         }
 525     }
 526 
 527     /*
 528      * Subclasses should override disposeImpl() instead of dispose(). Client
 529      * code should always invoke dispose(), never disposeImpl().
 530      */
 531     protected abstract void disposeImpl();
 532 
 533     /**
 534      * Frees all X Window resources associated with this object.


   1 /*
   2  * Copyright (c) 1997, 2019, 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


 494                                            int chgOffset,
 495                                            int chgLength,
 496                                            int caretPosition,
 497                                            long when);
 498 
 499     /**
 500      * Flushes composed and committed text held in this context.
 501      * This method is invoked in the AWT Toolkit (X event loop) thread context
 502      * and thus inside the AWT Lock.
 503      */
 504     // NOTE: This method may be called by privileged threads.
 505     //       This functionality is implemented in a package-private method
 506     //       to insure that it cannot be overridden by client subclasses.
 507     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
 508     void flushText() {
 509         String flush = (committedText != null ? committedText : "");
 510         if (composedText != null) {
 511             flush += composedText.toString();
 512         }
 513 
 514         if (!flush.isEmpty()) {
 515             AttributedString attrstr = new AttributedString(flush);
 516             postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
 517                                  attrstr.getIterator(),
 518                                  flush.length(),
 519                                  null,
 520                                  null,
 521                                  EventQueue.getMostRecentEventTime());
 522             composedText = null;
 523             committedText = null;
 524         }
 525     }
 526 
 527     /*
 528      * Subclasses should override disposeImpl() instead of dispose(). Client
 529      * code should always invoke dispose(), never disposeImpl().
 530      */
 531     protected abstract void disposeImpl();
 532 
 533     /**
 534      * Frees all X Window resources associated with this object.


< prev index next >