diff options
Diffstat (limited to 'tqtinterface/qt4/src/kernel/tqwidget_x11.cpp')
-rw-r--r-- | tqtinterface/qt4/src/kernel/tqwidget_x11.cpp | 521 |
1 files changed, 408 insertions, 113 deletions
diff --git a/tqtinterface/qt4/src/kernel/tqwidget_x11.cpp b/tqtinterface/qt4/src/kernel/tqwidget_x11.cpp index f8c605a..c6e7abb 100644 --- a/tqtinterface/qt4/src/kernel/tqwidget_x11.cpp +++ b/tqtinterface/qt4/src/kernel/tqwidget_x11.cpp @@ -83,6 +83,11 @@ extern Atom qt_net_wm_window_type_menu; extern Atom qt_net_wm_window_type_utility; extern Atom qt_net_wm_window_type_splash; extern Atom qt_net_wm_window_type_override; +extern Atom qt_net_wm_window_type_dropdown_menu; +extern Atom qt_net_wm_window_type_popup_menu; +extern Atom qt_net_wm_window_type_combo; +extern Atom qt_net_wm_window_type_dnd; +extern Atom qt_net_wm_window_type_tooltip; extern Atom qt_net_wm_pid; extern Atom qt_net_wm_user_time; extern Atom qt_enlightenment_desktop; @@ -300,11 +305,9 @@ int qt_sip_count( TQWidget* ); bool qt_wstate_iconified( WId ); void qt_updated_rootinfo(); -#ifndef TQT_NO_XIM -#include "tqinputcontext_p.h" - -extern XIM qt_xim; -extern XIMStyle qt_xim_style; +#ifndef TQT_NO_IM +#include "tqinputcontext.h" +#include "tqinputcontextfactory.h" #endif // Paint event clipping magic @@ -322,6 +325,12 @@ extern bool qt_deferred_map_tqcontains(TQWidget *); static TQWidget *mouseGrb = 0; static TQWidget *keyboardGrb = 0; +#ifndef TQT_NO_XSYNC +extern Atom qt_net_wm_sync_request_counter; +extern Atom qt_net_wm_sync_request; +extern bool qt_use_xsync; +#endif + // defined in qfont_x11.cpp extern bool qt_has_xft; @@ -683,10 +692,6 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) x11Colormap() ); #endif // TQT_NO_XFTFREETYPE - // NET window types - long net_wintypes[7] = { 0, 0, 0, 0, 0, 0, 0 }; - int curr_wintype = 0; - // NET window states long net_winstates[6] = { 0, 0, 0, 0, 0, 0 }; int curr_winstate = 0; @@ -708,7 +713,6 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) if ( testWFlags(WStyle_Splash) ) { if (qt_net_supports(qt_net_wm_window_type_splash)) { clearWFlags( WX11BypassWM ); - net_wintypes[curr_wintype++] = qt_net_wm_window_type_splash; } else { setWFlags( WX11BypassWM | WStyle_Tool | WStyle_NoBorder ); } @@ -717,27 +721,22 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) mwmhints.decorations = 0L; mwmhints.flags |= (1L << 1); // MWM_HINTS_DECORATIONS - if ( testWFlags( WStyle_NoBorder ) ) { - // override netwm type - quick and easy for KDE noborder - net_wintypes[curr_wintype++] = qt_net_wm_window_type_override; - } else { - if ( testWFlags( WStyle_NormalBorder | WStyle_DialogBorder ) ) { - mwmhints.decorations |= (1L << 1); // MWM_DECOR_BORDER - mwmhints.decorations |= (1L << 2); // MWM_DECOR_RESIZEH - } + if ( testWFlags( WStyle_NormalBorder | WStyle_DialogBorder ) ) { + mwmhints.decorations |= (1L << 1); // MWM_DECOR_BORDER + mwmhints.decorations |= (1L << 2); // MWM_DECOR_RESIZEH + } - if ( testWFlags( WStyle_Title ) ) - mwmhints.decorations |= (1L << 3); // MWM_DECOR_TITLE + if ( testWFlags( WStyle_Title ) ) + mwmhints.decorations |= (1L << 3); // MWM_DECOR_TITLE - if ( testWFlags( WStyle_SysMenu ) ) - mwmhints.decorations |= (1L << 4); // MWM_DECOR_MENU + if ( testWFlags( WStyle_SysMenu ) ) + mwmhints.decorations |= (1L << 4); // MWM_DECOR_MENU - if ( testWFlags( WStyle_Minimize ) ) - mwmhints.decorations |= (1L << 5); // MWM_DECOR_MINIMIZE + if ( testWFlags( WStyle_Minimize ) ) + mwmhints.decorations |= (1L << 5); // MWM_DECOR_MINIMIZE - if ( testWFlags( WStyle_Maximize ) ) - mwmhints.decorations |= (1L << 6); // MWM_DECOR_MAXIMIZE - } + if ( testWFlags( WStyle_Maximize ) ) + mwmhints.decorations |= (1L << 6); // MWM_DECOR_MAXIMIZE if (testWFlags(WStyle_Tool)) { wsa.save_under = True; @@ -757,23 +756,6 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) } } - // ### need a better way to do this - if (inherits("TQPopupMenu")) { - // menu netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_menu; - } else if (inherits("TQToolBar")) { - // toolbar netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_toolbar; - } else if (testWFlags(WStyle_Customize) && testWFlags(WStyle_Tool)) { - // utility netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_utility; - } - - if (dialog) // dialog netwm type - net_wintypes[curr_wintype++] = qt_net_wm_window_type_dialog; - // normal netwm type - default - net_wintypes[curr_wintype++] = qt_net_wm_window_type_normal; - // stays on top if (testWFlags(WStyle_StaysOnTop)) { net_winstates[curr_winstate++] = qt_net_wm_state_above; @@ -808,6 +790,7 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) wsa.save_under = True; XChangeWindowAttributes( dpy, id, CWOverrideRedirect | CWSaveUnder, &wsa ); + x11SetWindowType(); } else if ( topLevel && !desktop ) { // top-level widget TQWidget *p = parentWidget(); // real tqparent if (p) @@ -851,11 +834,14 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) XResizeWindow( dpy, id, crect.width(), crect.height() ); XStoreName( dpy, id, tqAppName() ); - Atom protocols[4]; + Atom protocols[5]; int n = 0; protocols[n++] = qt_wm_delete_window; // support del window protocol protocols[n++] = qt_wm_take_focus; // support take focus window protocol protocols[n++] = qt_net_wm_ping; // support _NET_WM_PING protocol +#ifndef TQT_NO_XSYNC + protocols[n++] = qt_net_wm_sync_request;// support the _NET_WM_SYNC_REQUEST protocol +#endif if ( testWFlags( WStyle_ContextHelp ) ) protocols[n++] = qt_net_wm_context_help; XSetWMProtocols( dpy, id, protocols, n ); @@ -867,12 +853,7 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) else XDeleteProperty(dpy, id, qt_xa_motif_wm_hints); - // set _NET_WM_WINDOW_TYPE - if (curr_wintype > 0) - XChangeProperty(dpy, id, qt_net_wm_window_type, XA_ATOM, 32, PropModeReplace, - (unsigned char *) net_wintypes, curr_wintype); - else - XDeleteProperty(dpy, id, qt_net_wm_window_type); + x11SetWindowType(); // set _NET_WM_WINDOW_STATE if (curr_winstate > 0) @@ -886,6 +867,14 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) XChangeProperty(dpy, id, qt_net_wm_pid, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &curr_pid, 1); +#ifndef TQT_NO_XSYNC + // set _NET_WM_SYNC_COUNTER + createSyncCounter(); + long counterVal = topData()->syncCounter; + XChangeProperty( dpy, id, qt_net_wm_sync_request_counter, XA_CARDINAL, 32, PropModeReplace, + (unsigned char*) &counterVal, 1); +#endif + // when we create a toplevel widget, the frame strut should be dirty fstrut_dirty = 1; @@ -923,6 +912,10 @@ void TQWidget::create( WId window, bool initializeWindow, bool destroyOldWindow) if ( destroyw ) qt_XDestroyWindow( this, dpy, destroyw ); + +#if !defined(TQT_NO_IM_EXTENSIONS) + ic = 0; +#endif } @@ -981,11 +974,24 @@ void TQWidget::destroy( bool destroyWindow, bool destroySubWindows ) if ( destroyWindow ) qt_XDestroyWindow( this, x11Display(), winid ); } +#ifndef TQT_NO_XSYNC + destroySyncCounter(); +#endif setWinId( 0 ); extern void qPRCleanup( TQWidget *widget ); // from qapplication_x11.cpp if ( testWState(WState_Reparented) ) qPRCleanup(this); + + if( this == icHolderWidget() ) { + destroyInputContext(); + } else { + // release previous focus information participating with + // preedit preservation of qic + TQInputContext *qic = getInputContext(); + if ( qic ) + qic->releaseComposingWidget( this ); + } } } @@ -1022,14 +1028,18 @@ void TQWidget::reparentSys( TQWidget *tqparent, WFlags f, const TQPoint &p, bool XReparentWindow( x11Display(), old_winid, RootWindow( x11Display(), x11Screen() ), 0, 0 ); - if ( isTopLevel() ) { - // input contexts are associated with toplevel widgets, so we need - // destroy the context here. if we are reparenting back to toplevel, - // then we will have another context created, otherwise we will - // use our new toplevel's context + if ( this == icHolderWidget() ) { + // input contexts are sometimes associated with toplevel widgets, so + // we need destroy the context here. if we are reparenting back to + // toplevel, then we may have another context created, otherwise we + // will use our new ic holder's context destroyInputContext(); } +#ifndef TQT_NO_XSYNC + destroySyncCounter(); +#endif + if ( isTopLevel() || !tqparent ) // we are toplevel, or reparenting to toplevel topData()->parentWinId = 0; @@ -1131,6 +1141,64 @@ void TQWidget::reparentSys( TQWidget *tqparent, WFlags f, const TQPoint &p, bool setMouseTracking(mouse_tracking); } +// Sets the EWMH (netwm) window type. Needed as a separate function +// because create() may be too soon in some cases. +void TQWidget::x11SetWindowType( X11WindowType type ) +{ + // NET window types + long net_wintypes[7] = { 0, 0, 0, 0, 0, 0, 0 }; + int curr_wintype = 0; + if( testWFlags(WType_Desktop)) + return; + if( type == X11WindowTypeSelect ) { + if ( testWFlags(WStyle_Splash)) { + if (qt_net_supports(qt_net_wm_window_type_splash)) { + net_wintypes[curr_wintype++] = qt_net_wm_window_type_splash; + } + } else if (inherits(TQTOOLBAR_OBJECT_NAME_STRING)) { + // toolbar netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_toolbar; + } else if (testWFlags(WStyle_Customize) && testWFlags(WStyle_Tool)) { + // utility netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_utility; + } else if (testWFlags(WType_Dialog)) { + // dialog netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_dialog; + } + } else if( type == X11WindowTypeCombo ) { + // combo netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_combo; + } else if( type == X11WindowTypeDND ) { + // dnd netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_dnd; + } else if( type == X11WindowTypeDropdown ) { + // dropdown netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_dropdown_menu; + } else if( type == X11WindowTypePopup ) { + // popup netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_popup_menu; + } else if( type == X11WindowTypeMenu ) { + // menu netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_menu; + } else if( type == X11WindowTypeTooltip ) { + // tooltip netwm type + net_wintypes[curr_wintype++] = qt_net_wm_window_type_tooltip; + } + + // normal netwm type - default + net_wintypes[curr_wintype++] = qt_net_wm_window_type_normal; + // set _NET_WM_WINDOW_TYPE + if (curr_wintype > 0) + XChangeProperty(x11Display(), winId(), qt_net_wm_window_type, XA_ATOM, 32, PropModeReplace, + (unsigned char *) net_wintypes, curr_wintype); + else + XDeleteProperty(x11Display(), winId(), qt_net_wm_window_type); +} + +void TQWidget::x11SetWindowTransient( TQWidget* tqparent ) +{ + XSetTransientForHint( x11Display(), winId(), tqparent->winId()); +} /*! Translates the widget coordinate \a pos to global screen @@ -1182,7 +1250,8 @@ TQPoint TQWidget::mapFromGlobal( const TQPoint &pos ) const language input systems. In the X11 version of TQt, if \a text is TRUE, this method sets the - XIM "spot" point for complex language input handling. + input method focus point in the preedit (XIM "spot" point) for + complex language input handling. The font \a f is a rendering hint to the currently active input method. If \a f is 0 the widget's font is used. @@ -1192,22 +1261,15 @@ TQPoint TQWidget::mapFromGlobal( const TQPoint &pos ) const void TQWidget::setMicroFocusHint(int x, int y, int width, int height, bool text, TQFont *f ) { -#ifndef TQT_NO_XIM +#ifndef TQT_NO_IM if ( text ) { - TQWidget* tlw = tqtopLevelWidget(); - TQTLWExtra *topdata = tlw->topData(); - // trigger input context creation if it hasn't happened already createInputContext(); - TQInputContext *qic = (TQInputContext *) topdata->xic; - - if ( qt_xim && qic ) { - TQPoint p( x, y ); - TQPoint p2 = mapTo( tqtopLevelWidget(), TQPoint( 0, 0 ) ); - p = mapTo( tqtopLevelWidget(), p); - qic->setXFontSet( f ? *f : fnt ); - qic->setComposePosition(p.x(), p.y() + height); - qic->setComposeArea(p2.x(), p2.y(), this->width(), this->height()); + + TQInputContext *qic = getInputContext(); + if(qic) { + TQPoint gp = mapToGlobal( TQPoint( x, y ) ); + qic->setMicroFocus(gp.x(), gp.y(), width, height, f); } } #endif @@ -2659,13 +2721,21 @@ void TQWidget::deleteSysExtra() void TQWidget::createTLSysExtra() { +#if defined(TQT_NO_IM_EXTENSIONS) // created lazily extra->topextra->xic = 0; +#endif +#ifndef TQT_NO_XSYNC + extra->topextra->syncCounter = 0; + extra->topextra->syncRequestValue[0] = 0; + extra->topextra->syncRequestValue[1] = 0; +#endif } void TQWidget::deleteTLSysExtra() { - destroyInputContext(); + // don't destroy input context here. it will be destroyed in + // TQWidget::destroy() destroyInputContext(); } /* @@ -2706,6 +2776,51 @@ void TQWidget::checkChildrenDnd() } } + +#ifndef TQT_NO_XSYNC +// create a window's XSyncCounter +void TQWidget::createSyncCounter() +{ + if( !qt_use_xsync || !isTopLevel() || topData()->syncCounter ) + return; + XSyncValue zero; + XSyncIntToValue( &zero, 0 ); + topData()->syncCounter = XSyncCreateCounter( x11Display(), zero ); +} + +// destroy a window's XSyncCounter +void TQWidget::destroySyncCounter() +{ + if( !qt_use_xsync || !extra || !extra->topextra + || !extra->topextra->syncCounter ) + return; + XSyncDestroyCounter( x11Display(), extra->topextra->syncCounter ); + extra->topextra->syncCounter = 0; +} + +// increment a window's XSyncCounter +void TQWidget::incrementSyncCounter() +{ + if( qt_use_xsync && topData()->syncCounter && + !(topData()->syncRequestValue[0] == 0 && + topData()->syncRequestValue[1] == 0) ) { + XSyncValue val; + XSyncIntsToValue( &val, topData()->syncRequestValue[ 0 ], topData()->syncRequestValue[ 1 ] ); + XSyncSetCounter( x11Display(), topData()->syncCounter, val ); + topData()->syncRequestValue[0] = topData()->syncRequestValue[1] = 0; + } +} + +// handle _NET_WM_SYNC_REQUEST +void TQWidget::handleSyncRequest( void* ev ) +{ + XEvent* xev = (XEvent*)ev; + topData()->syncRequestValue[ 0 ] = xev->xclient.data.l[ 2 ]; + topData()->syncRequestValue[ 1 ] = xev->xclient.data.l[ 3 ]; +} +#endif // TQT_NO_XSYNC + + /*! \property TQWidget::acceptDrops \brief whether drop events are enabled for this widget @@ -2897,76 +3012,256 @@ void TQWidget::updateFrameStrut() const } +/*! + This function returns the widget holding the TQInputContext + instance for this widget. The instance is used for text input to + this widget, switching input method, etc. + + By default, this function delegates the role of returning input + context holder widget to TQApplication::locateICHolderWidget(). + + This definition enables application developer to change the + mapping of widgets to TQInputContext instance simply by overriding + TQApplication::locateICHolderWidget(). + + \sa TQApplication::locateICHolderWidget() +*/ +TQWidget *TQWidget::icHolderWidget() +{ + return tqApp->locateICHolderWidget(this); +} + + +/*! + This function returns the TQInputContext instance for this widget. + This instance is used for text input to this widget, etc. + It is simply the accessor function. +*/ +TQInputContext *TQWidget::getInputContext() +{ + TQInputContext *qic = 0; + +// #if !defined(TQT_NO_IM_EXTENSIONS) + if ( isInputMethodEnabled() ) { +#if !defined(TQT_NO_IM_EXTENSIONS) + qic = icHolderWidget()->ic; +#else +// { + // icHolderWidget is always tqtopLevelWidget + TQTLWExtra *topdata = icHolderWidget()->topData(); + qic = (TQInputContext *)topdata->xic; +#endif + } + + return qic; +} + + +/*! + This function replaces the TQInputContext instance used for text + input to this widget. The \a identifierName is the identifier name + of newly choosed input method. +*/ +void TQWidget::changeInputContext( const TQString& identifierName ) +{ + TQWidget *icWidget = icHolderWidget(); +#if !defined(TQT_NO_IM_EXTENSIONS) + TQInputContext **qicp = &icWidget->ic; +#else + TQInputContext **qicp = (TQInputContext **)&icWidget->topData()->xic; +#endif + + if( *qicp ) + delete *qicp; + // an input context that has the identifierName is generated. + TQInputContext *qic = TQInputContextFactory::create( identifierName, icWidget ); + *qicp = qic; + if ( qic ) { + TQObject::connect( qic, TQT_SIGNAL(imEventGenerated(TQObject *,TQIMEvent *)), + tqApp, TQT_SLOT(postIMEvent(TQObject *,TQIMEvent *)) ); + TQObject::connect( qic, TQT_SIGNAL(deletionRequested()), + icWidget, TQT_SLOT(destroyInputContext()) ); + } +} + + +/*! + \internal + This is an internal function, you should never call this. + + This function is called to generate an input context + according to a configuration for default input method + + When TQT_NO_IM_EXTENSIONS is not set, input context is + generated only when isInputMethodEnabled() returns TRUE. +*/ void TQWidget::createInputContext() { - TQWidget *tlw = tqtopLevelWidget(); - TQTLWExtra *topdata = tlw->topData(); +// #if !defined(TQT_NO_IM_EXTENSIONS) + if( !isInputMethodEnabled() || TQApplication::closingDown() ) + return; +// #endif -#ifndef TQT_NO_XIM - if (qt_xim) { - if (! topdata->xic) { - TQInputContext *qic = new TQInputContext(tlw); - topdata->xic = (void *) qic; - } - } else -#endif // TQT_NO_XIM - { - // qDebug("TQWidget::createInputContext: no xim"); - topdata->xic = 0; - } + TQWidget *icWidget = icHolderWidget(); +#ifndef TQT_NO_IM +#if !defined(TQT_NO_IM_EXTENSIONS) + TQInputContext **qicp = &icWidget->ic; +#else + TQInputContext **qicp = (TQInputContext **)&icWidget->topData()->xic; +#endif + + if ( ! *qicp ) { + // an input context of the default input method is generated. + TQInputContext *qic = TQInputContextFactory::create( TQApplication::defaultInputMethod(), icWidget ); + + *qicp = qic; + if ( qic ) { + TQObject::connect( qic, TQT_SIGNAL(imEventGenerated(TQObject *,TQIMEvent *)), + tqApp, TQT_SLOT(postIMEvent(TQObject *,TQIMEvent *)) ); + TQObject::connect( qic, TQT_SIGNAL(deletionRequested()), + icWidget, TQT_SLOT(destroyInputContext()) ); + } + } +#endif // TQT_NO_IM } +/*! + \internal + + This slot is used to destroy the input context that belonging + to the widget itself, so icHolderWidget()->ic is not fetched. + + \sa TQInputContext::deletionRequested() +*/ void TQWidget::destroyInputContext() { -#ifndef TQT_NO_XIM - TQInputContext *qic = (TQInputContext *) extra->topextra->xic; - delete qic; -#endif // TQT_NO_XIM - extra->topextra->xic = 0; +#ifndef TQT_NO_IM +#if !defined(TQT_NO_IM_EXTENSIONS) + TQInputContext **qicp = ⁣ +#else + if ( ! extra || ! extra->topextra ) + return; + + TQInputContext **qicp = (TQInputContext **)&extra->topextra->xic; +#endif + + if( *qicp ) + delete *qicp; + + *qicp = 0; +#endif // TQT_NO_IM } /*! - This function is called when the user finishes input composition, - e.g. changes focus to another widget, moves the cursor, etc. + This function is called when text widgets need to be neutral state to + execute text operations properly. See qlineedit.cpp and qtextedit.cpp as + example. + + Ordinary reset that along with changing focus to another widget, + moving the cursor, etc, is implicitly handled via + unfocusInputContext() because whether reset or not when such + situation is a responsibility of input methods. So we delegate the + responsibility to the input context via unfocusInputContext(). See + 'Preedit preservation' section of the class description of + TQInputContext for further information. + + \sa TQInputContext, unfocusInputContext(), TQInputContext::unsetFocus() */ void TQWidget::resetInputContext() { -#ifndef TQT_NO_XIM - if ((qt_xim_style & XIMPreeditCallbacks) && hasFocus()) { - TQWidget *tlw = tqtopLevelWidget(); - TQTLWExtra *topdata = tlw->topData(); +#ifndef TQT_NO_IM + // trigger input context creation if it hasn't happened already + createInputContext(); + + TQInputContext *qic = getInputContext(); + if( qic ) + qic->reset(); +#endif // TQT_NO_IM +} + + +/*! + \internal + This is an internal function, you should never call this. + + This function is called to focus associated input context. The + code intends to eliminate duplicate focus for the context even if + the context is shared between widgets + + \sa TQInputContext::setFocus() + */ +void TQWidget::focusInputContext() +{ +#ifndef TQT_NO_IM + TQWidget* tlw = tqtopLevelWidget(); + if (!tlw->isPopup() || isInputMethodEnabled()) { // trigger input context creation if it hasn't happened already createInputContext(); - if (topdata->xic) { - TQInputContext *qic = (TQInputContext *) topdata->xic; - qic->reset(); + TQInputContext *qic = getInputContext(); + if ( qic ) { + if( qic->tqfocusWidget() != this ) { + qic->setFocusWidget( this ); + qic->setFocus(); + } } } -#endif // TQT_NO_XIM +#endif // TQT_NO_IM } -void TQWidget::focusInputContext() -{ -#ifndef TQT_NO_XIM - TQWidget *tlw = tqtopLevelWidget(); - if (!tlw->isPopup() || isInputMethodEnabled()) { - TQTLWExtra *topdata = tlw->topData(); +/*! + \internal + This is an internal function, you should never call this. - // trigger input context creation if it hasn't happened already - createInputContext(); + This function is called to remove focus from associated input + context. - if (topdata->xic) { - TQInputContext *qic = (TQInputContext *) topdata->xic; - qic->setFocus(); - } + \sa TQInputContext::unsetFocus() + */ +void TQWidget::unfocusInputContext() +{ +#ifndef TQT_NO_IM + // trigger input context creation if it hasn't happened already + createInputContext(); + + TQInputContext *qic = getInputContext(); + if ( qic ) { + // may be caused reset() in some input methods + qic->unsetFocus(); + qic->setFocusWidget( 0 ); } -#endif // TQT_NO_XIM +#endif // TQT_NO_IM } + + +/*! + This function is called to send mouse event to associated input + context by derived text widgets. A derived text widget must be + calculate \a x as character offset at the mouse cursor in the + preedit. + + \sa TQInputContext::mouseHandler() + */ +void TQWidget::sendMouseEventToInputContext( int x, TQEvent::Type type, + TQt::ButtonState button, + TQt::ButtonState state ) +{ +#ifndef TQT_NO_IM + // trigger input context creation if it hasn't happened already + createInputContext(); + + TQInputContext *qic = getInputContext(); + if ( qic ) { + // may be causing reset() in some input methods + qic->mouseHandler( x, type, button, state ); + } +#endif // TQT_NO_IM +} + void TQWidget::setWindowOpacity(double) { |