49 #include <tqapplication.h>
50 #include <tqptrlist.h>
51 #include <tqptrdict.h>
52 #include <tqguardedptr.h>
53 #include <tqwhatsthis.h>
54 #include <tqfocusdata.h>
60 # include <X11/Xlib.h>
61 # include <X11/Xutil.h>
62 # include <X11/Xatom.h>
63 # define XK_MISCELLANY
65 # include <X11/keysymdef.h>
67 # include <kxerrorhandler.h>
74 # define USLEEP(x) usleep(x)
76 # define USLEEP(x) sleep(0)
79 # define USLEEP(x) sleep(0)
85 # ifndef XK_ISO_Left_Tab
86 # define XK_ISO_Left_Tab 0xFE20
90 const int XFocusOut = FocusOut;
91 const int XFocusIn = FocusIn;
92 const int XKeyPress = KeyPress;
93 const int XKeyRelease = KeyRelease;
100 extern Atom tqt_wm_protocols;
101 extern Atom tqt_wm_delete_window;
102 extern Atom tqt_wm_take_focus;
103 extern Atom tqt_wm_state;
106 static Atom xembed = 0;
107 static Atom context_help = 0;
110 #define XEMBED_EMBEDDED_NOTIFY 0
111 #define XEMBED_WINDOW_ACTIVATE 1
112 #define XEMBED_WINDOW_DEACTIVATE 2
113 #define XEMBED_REQUEST_FOCUS 3
114 #define XEMBED_FOCUS_IN 4
115 #define XEMBED_FOCUS_OUT 5
116 #define XEMBED_FOCUS_NEXT 6
117 #define XEMBED_FOCUS_PREV 7
121 #define XEMBED_FOCUS_CURRENT 0
122 #define XEMBED_FOCUS_FIRST 1
123 #define XEMBED_FOCUS_LAST 2
135 mapAfterRelease =
false;
136 lastPos = TQPoint(0,0);
143 bool mapAfterRelease;
144 TQWidget* focusProxy;
152 class QXEmbedAppFilter :
public TQObject
155 QXEmbedAppFilter() { tqApp->installEventFilter(
this ); }
156 ~QXEmbedAppFilter() { }
157 bool eventFilter( TQObject *, TQEvent * );
162 static QXEmbedAppFilter* filter = 0;
164 static TQPtrDict<TQGuardedPtr<TQWidget> > *focusMap = 0;
166 static XKeyEvent last_key_event;
176 class QPublicWidget :
public TQWidget
179 TQTLWExtra* topData() {
return TQWidget::topData(); }
180 TQFocusData *focusData(){
return TQWidget::focusData(); }
181 bool focusNextPrev(
bool b) {
return focusNextPrevChild(b); }
186 typedef int (*QX11EventFilter) (XEvent*);
187 extern QX11EventFilter tqt_set_x11_event_filter (QX11EventFilter filter);
188 static QX11EventFilter oldFilter = 0;
192 static void sendXEmbedMessage( WId window,
long message,
long detail = 0,
193 long data1 = 0,
long data2 = 0)
197 memset(&ev, 0,
sizeof(ev));
198 ev.xclient.type = ClientMessage;
199 ev.xclient.window = window;
200 ev.xclient.message_type = xembed;
201 ev.xclient.format = 32;
202 ev.xclient.data.l[0] = GET_QT_X_TIME();
203 ev.xclient.data.l[1] = message;
204 ev.xclient.data.l[2] = detail;
205 ev.xclient.data.l[3] = data1;
206 ev.xclient.data.l[4] = data2;
207 XSendEvent(tqt_xdisplay(), window,
false, NoEventMask, &ev);
212 static void sendClientMessage(Window window, Atom a,
long x)
216 memset(&ev, 0,
sizeof(ev));
217 ev.xclient.type = ClientMessage;
218 ev.xclient.window = window;
219 ev.xclient.message_type = a;
220 ev.xclient.format = 32;
221 ev.xclient.data.l[0] = x;
222 ev.xclient.data.l[1] = GET_QT_X_TIME();
223 XSendEvent(tqt_xdisplay(), window,
false, NoEventMask, &ev);
228 static void sendFocusMessage(Window window,
int type,
int mode,
int detail)
232 memset(&ev, 0,
sizeof(ev));
233 ev.xfocus.type = type;
234 ev.xfocus.window = window;
235 ev.xfocus.mode = mode;
236 ev.xfocus.detail = detail;
237 XSendEvent(tqt_xdisplay(), window,
false, FocusChangeMask, &ev);
299 bool QXEmbedAppFilter::eventFilter( TQObject *o, TQEvent * e)
301 static bool obeyFocus =
false;
302 switch ( e->type() ) {
303 case TQEvent::MouseButtonPress:
305 if ( !((TQWidget*)o)->isActiveWindow() )
308 case TQEvent::FocusIn:
313 if ( TQT_BASE_OBJECT(tqApp->focusWidget()) == TQT_BASE_OBJECT(o) &&
314 ((QPublicWidget*)tqApp->focusWidget()->topLevelWidget())->topData()->embedded ) {
315 TQFocusEvent* fe = (TQFocusEvent*) e;
316 if ( obeyFocus || fe->reason() != TQFocusEvent::ActiveWindow
323 WId window = ((QPublicWidget*)tqApp->focusWidget()->topLevelWidget())->effectiveWinId();
325 WId window = ((QPublicWidget*)tqApp->focusWidget()->topLevelWidget())->topData()->parentWinId;
327 focusMap->remove( tqApp->focusWidget()->topLevelWidget() );
328 sendXEmbedMessage( window, XEMBED_REQUEST_FOCUS );
329 }
else if ( fe->reason() == TQFocusEvent::ActiveWindow ) {
335 focusMap->remove( tqApp->focusWidget()->topLevelWidget() );
336 focusMap->insert( tqApp->focusWidget()->topLevelWidget(),
337 new TQGuardedPtr<TQWidget>(tqApp->focusWidget()->topLevelWidget()->focusWidget() ) );
340 tqApp->focusWidget()->clearFocus();
346 case TQEvent::KeyPress:
347 if (TQT_BASE_OBJECT(tqApp->focusWidget()) == TQT_BASE_OBJECT(o) &&
348 ((QPublicWidget*)tqApp->focusWidget()->topLevelWidget())->topData()->embedded ) {
361 TQKeyEvent *k = (TQKeyEvent *)e;
362 TQWidget *w = tqApp->focusWidget();
365 bool tabForward =
true;
366 if ( !(k->state() & ControlButton || k->state() & AltButton) ) {
367 if ( k->key() == Key_Backtab || (k->key() == Key_Tab && (k->state() & ShiftButton)) ) {
369 res = ((QPublicWidget*)w)->focusNextPrev( tabForward =
false );
371 TQFocusEvent::setReason( TQFocusEvent::Backtab );
372 res = ((QPublicWidget*)w)->focusNextPrev( tabForward =
false );
373 TQFocusEvent::resetReason();
375 }
else if ( k->key() == Key_Tab ) {
377 res = ((QPublicWidget*)w)->focusNextPrev( tabForward =
true );
379 TQFocusEvent::setReason( TQFocusEvent::Tab );
380 res = ((QPublicWidget*)w)->focusNextPrev( tabForward =
true );
381 TQFocusEvent::resetReason();
388 TQFocusData *fd = ((QPublicWidget*)w)->focusData();
390 WId window = ((QPublicWidget*)w->topLevelWidget())->effectiveWinId();
392 WId window = ((QPublicWidget*)w->topLevelWidget())->topData()->parentWinId;
395 TQWidget *fw = fd->home();
396 if (tabForward && window) {
397 while (cw != w && cw != fw && cw != w->topLevelWidget())
400 sendXEmbedMessage( window, XEMBED_FOCUS_NEXT );
402 while (cw != w && cw != fw && cw != w->topLevelWidget())
405 sendXEmbedMessage( window, XEMBED_FOCUS_PREV );
421 static int qxembed_x11_event_filter( XEvent* e)
427 last_key_event = e->xkey;
431 if ( e->xclient.message_type == xembed ) {
434 Time msgtime = (Time) e->xclient.data.l[0];
435 long message = e->xclient.data.l[1];
436 long detail = e->xclient.data.l[2];
438 if ( msgtime > GET_QT_X_TIME() )
439 SET_QT_X_TIME(msgtime);
440 TQWidget* w = TQT_TQWIDGET(TQWidget::find( e->xclient.window ));
444 case XEMBED_EMBEDDED_NOTIFY: {
446 TQTLWExtra *extra = ((QPublicWidget*)w->topLevelWidget())->topData();
450 printf(
"[FIXME] WId not set in tdelibs/tdeui/qxembed.cpp\n");
452 extra->parentWinId = e->xclient.data.l[3];
454 w->topLevelWidget()->show();
457 case XEMBED_WINDOW_ACTIVATE: {
464 memset(&ev, 0,
sizeof(ev));
465 ev.xfocus.display = tqt_xdisplay();
466 ev.xfocus.type = XFocusIn;
467 ev.xfocus.window = w->topLevelWidget()->winId();
468 ev.xfocus.mode = NotifyNormal;
469 ev.xfocus.detail = NotifyAncestor;
470 tqApp->x11ProcessEvent( &ev );
473 case XEMBED_WINDOW_DEACTIVATE: {
478 memset(&ev, 0,
sizeof(ev));
479 ev.xfocus.display = tqt_xdisplay();
480 ev.xfocus.type = XFocusOut;
481 ev.xfocus.window = w->topLevelWidget()->winId();
482 ev.xfocus.mode = NotifyNormal;
483 ev.xfocus.detail = NotifyAncestor;
484 tqApp->x11ProcessEvent( &ev );
487 case XEMBED_FOCUS_IN:
491 TQWidget* focusCurrent = 0;
492 TQGuardedPtr<TQWidget>* fw = focusMap->find( w->topLevelWidget() );
496 focusMap->remove( w->topLevelWidget() );
499 case XEMBED_FOCUS_CURRENT:
501 if ( focusCurrent ) {
502 focusCurrent->setFocus();
503 if( QXEmbed* emb = tqt_dynamic_cast< QXEmbed* >( focusCurrent ))
504 emb->updateEmbeddedFocus(
true );
506 else if ( !w->topLevelWidget()->focusWidget() )
507 w->topLevelWidget()->setFocus();
509 case XEMBED_FOCUS_FIRST:
513 w->topLevelWidget()->setFocus();
514 ((QPublicWidget*)w->topLevelWidget())->focusNextPrev(
true);
516 TQFocusEvent::setReason( TQFocusEvent::Tab );
517 w->topLevelWidget()->setFocus();
518 ((QPublicWidget*)w->topLevelWidget())->focusNextPrev(
true);
519 TQFocusEvent::resetReason();
523 case XEMBED_FOCUS_LAST:
527 w->topLevelWidget()->setFocus();
528 ((QPublicWidget*)w->topLevelWidget())->focusNextPrev(
false);
530 TQFocusEvent::setReason( TQFocusEvent::Backtab );
531 w->topLevelWidget()->setFocus();
532 ((QPublicWidget*)w->topLevelWidget())->focusNextPrev(
false);
533 TQFocusEvent::resetReason();
542 case XEMBED_FOCUS_OUT:
546 if ( w->topLevelWidget()->focusWidget() ) {
547 if( QXEmbed* emb = tqt_dynamic_cast< QXEmbed* >( w->topLevelWidget()->focusWidget()))
548 emb->updateEmbeddedFocus(
false );
549 focusMap->insert( w->topLevelWidget(),
550 new TQGuardedPtr<TQWidget>(w->topLevelWidget()->focusWidget() ) );
551 w->topLevelWidget()->focusWidget()->clearFocus();
557 }
else if ( e->xclient.format == 32 && e->xclient.message_type ) {
558 if ( e->xclient.message_type == tqt_wm_protocols ) {
559 TQWidget* w = TQT_TQWIDGET(TQWidget::find( e->xclient.window ));
569 Atom a = e->xclient.data.l[0];
570 if ( a == tqt_wm_take_focus ) {
572 if ( (ulong) e->xclient.data.l[1] > GET_QT_X_TIME() )
573 SET_QT_X_TIME(e->xclient.data.l[1]);
578 if ( w->isActiveWindow() ) {
579 TQEvent e( TQEvent::WindowActivate );
580 TQApplication::sendEvent( w, &e );
591 return oldFilter( e );
603 void QXEmbed::initialize()
605 static bool is_initialized =
false;
606 if ( is_initialized )
610 xembed = XInternAtom( tqt_xdisplay(),
"_XEMBED",
false );
612 oldFilter = tqt_set_x11_event_filter( qxembed_x11_event_filter );
614 focusMap =
new TQPtrDict<TQGuardedPtr<TQWidget> >;
615 focusMap->setAutoDelete(
true );
617 filter =
new QXEmbedAppFilter;
619 is_initialized =
true;
643 QXEmbed::QXEmbed(TQWidget *parent,
const char *name, WFlags f)
644 : TQWidget(parent, name, f)
654 d->focusProxy =
new TQWidget( topLevelWidget(),
"xembed_focus" );
655 d->focusProxy->setGeometry( -1, -1, 1, 1 );
656 d->focusProxy->show();
658 TQApplication::sendPostedEvents( d->focusProxy, 0 );
664 setFocusPolicy(TQ_StrongFocus);
665 setKeyCompression(
false );
673 XSelectInput(tqt_xdisplay(), winId(),
674 KeyPressMask | KeyReleaseMask |
675 ButtonPressMask | ButtonReleaseMask |
679 EnterWindowMask | LeaveWindowMask |
682 StructureNotifyMask |
683 SubstructureRedirectMask |
684 SubstructureNotifyMask
689 topLevelWidget()->installEventFilter(
this );
690 tqApp->installEventFilter(
this );
694 if ( tqApp->activeWindow() == topLevelWidget() )
695 if ( !((QPublicWidget*) topLevelWidget())->topData()->embedded )
696 XSetInputFocus( tqt_xdisplay(), d->focusProxy->winId(),
697 RevertToParent, GET_QT_X_TIME() );
699 setAcceptDrops(
true );
707 XUngrabButton( tqt_xdisplay(), AnyButton, AnyModifier, winId() );
708 if ( window && ( autoDelete() || !d->xplain ))
726 XUnmapWindow( tqt_xdisplay(), window );
728 XReparentWindow(tqt_xdisplay(), window, tqt_xrootwin(), 0, 0);
730 XRemoveFromSaveSet( tqt_xdisplay(), window );
731 if( d->mapAfterRelease )
732 XMapWindow( tqt_xdisplay(), window );
733 XSync(tqt_xdisplay(),
false);
747 XGetInputFocus( tqt_xdisplay(), &focus, &revert );
748 if( focus == d->focusProxy->winId())
749 XSetInputFocus( tqt_xdisplay(), topLevelWidget()->winId(), RevertToParent, GET_QT_X_TIME() );
758 void QXEmbed::sendDelete(
void )
762 sendClientMessage(window, tqt_wm_protocols, tqt_wm_delete_window);
763 XFlush( tqt_xdisplay() );
774 void QXEmbed::setProtocol( Protocol proto )
784 QXEmbed::Protocol QXEmbed::protocol()
793 void QXEmbed::resizeEvent(TQResizeEvent*)
796 XResizeWindow(tqt_xdisplay(), window, width(), height());
800 void QXEmbed::showEvent(TQShowEvent*)
803 XMapRaised(tqt_xdisplay(), window);
808 bool QXEmbed::eventFilter( TQObject *o, TQEvent * e)
811 switch ( e->type() ) {
812 case TQEvent::WindowActivate:
813 if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(topLevelWidget()) ) {
816 if ( !((QPublicWidget*) topLevelWidget())->topData()->embedded )
818 XSetInputFocus( tqt_xdisplay(), d->focusProxy->winId(),
819 RevertToParent, GET_QT_X_TIME() );
825 sendXEmbedMessage( window, XEMBED_WINDOW_ACTIVATE );
828 case TQEvent::WindowDeactivate:
829 if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(topLevelWidget()) ) {
835 sendXEmbedMessage( window, XEMBED_WINDOW_DEACTIVATE );
840 TQWidget* pos =
this;
841 while( TQT_BASE_OBJECT(pos) != TQT_BASE_OBJECT(o) && TQT_BASE_OBJECT(pos) != TQT_BASE_OBJECT(topLevelWidget()))
842 pos = pos->parentWidget();
843 if( TQT_BASE_OBJECT(pos) == TQT_BASE_OBJECT(o) ) {
846 TQPoint globalPos = mapToGlobal(TQPoint(0,0));
847 if (globalPos != d->lastPos) {
848 d->lastPos = globalPos;
849 sendSyntheticConfigureNotifyEvent();
861 bool QXEmbed::event( TQEvent * e)
863 return TQWidget::event( e );
872 void QXEmbed::keyPressEvent( TQKeyEvent *)
876 last_key_event.window = window;
877 XSendEvent(tqt_xdisplay(), window,
false, KeyPressMask, (XEvent*)&last_key_event);
883 void QXEmbed::keyReleaseEvent( TQKeyEvent *)
887 last_key_event.window = window;
888 XSendEvent(tqt_xdisplay(), window,
false, KeyReleaseMask, (XEvent*)&last_key_event);
892 void QXEmbed::focusInEvent( TQFocusEvent * e ){
897 if ( !((QPublicWidget*) topLevelWidget())->topData()->embedded )
898 if ( tqApp->activeWindow() == topLevelWidget() )
902 XSetInputFocus( tqt_xdisplay(), d->focusProxy->winId(),
903 RevertToParent, GET_QT_X_TIME() );
910 sendFocusMessage(window, XFocusIn, NotifyNormal, NotifyPointer );
914 int detail = XEMBED_FOCUS_CURRENT;
918 if ( e->reason() == TQFocusEvent::Tab )
919 detail = XEMBED_FOCUS_FIRST;
920 else if ( e->reason() == TQFocusEvent::Backtab )
921 detail = XEMBED_FOCUS_LAST;
922 sendXEmbedMessage( window, XEMBED_FOCUS_IN, detail);
927 void QXEmbed::focusOutEvent( TQFocusEvent * ){
934 sendFocusMessage(window, XFocusOut, NotifyNormal, NotifyPointer );
937 sendXEmbedMessage( window, XEMBED_FOCUS_OUT );
946 if ( !((QPublicWidget*) topLevelWidget())->topData()->embedded )
947 if ( tqApp->activeWindow() == topLevelWidget() )
952 XSetInputFocus( tqt_xdisplay(), d->focusProxy->winId(),
953 RevertToParent, GET_QT_X_TIME() );
959 void QXEmbed::updateEmbeddedFocus(
bool hasfocus ){
960 if (!window || d->xplain)
963 sendXEmbedMessage( window, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT);
965 sendXEmbedMessage( window, XEMBED_FOCUS_OUT);
970 static bool wstate_withdrawn( WId winid )
974 unsigned long length, after;
976 int r = XGetWindowProperty( tqt_xdisplay(), winid, tqt_wm_state, 0, 2,
977 false, AnyPropertyType, &type, &format,
978 &length, &after, &data );
979 bool withdrawn =
true;
982 if ( r == Success && data && format == 32 ) {
983 TQ_UINT32 *wstate = (TQ_UINT32*)data;
984 withdrawn = (*wstate == WithdrawnState );
985 XFree( (
char *)data );
992 static int get_parent(WId winid, Window *out_parent)
994 Window root, *children=0;
995 unsigned int nchildren;
996 int st = XQueryTree(tqt_xdisplay(), winid, &root, out_parent, &children, &nchildren);
1004 void QXEmbed::embed(WId w)
1006 kdDebug() <<
"*** Embed " << w <<
" into " << winId() <<
". window=" << window <<
endl;
1011 bool has_window = (w == window);
1013 if ( !has_window ) {
1018 if ( !wstate_withdrawn(window) ) {
1019 XWithdrawWindow(tqt_xdisplay(), window, tqt_xscreen());
1020 TQApplication::flushX();
1022 for (
int i=0; i < 10000; ++i) {
1023 if (wstate_withdrawn(window)) {
1025 get_parent(w, &parent);
1026 if (parent == tqt_xrootwin())
break;
1036 get_parent(w, &parent);
1037 kdDebug() << TQString(TQString(
"> before reparent: parent=0x%1").arg(parent,0,16)) <<
endl;
1038 for (
int i = 0; i < 50; i++) {
1042 XAddToSaveSet( tqt_xdisplay(), w );
1043 XReparentWindow(tqt_xdisplay(), w, winId(), 0, 0);
1044 if (get_parent(w, &parent) && parent == winId()) {
1045 kdDebug() << TQString(TQString(
"> Loop %1: ").arg(i))
1046 << TQString(TQString(
"> reparent of 0x%1").arg(w,0,16))
1047 << TQString(TQString(
" into 0x%1").arg(winId(),0,16))
1048 << TQString(
" successful") <<
endl;
1051 kdDebug() << TQString(TQString(
"> Loop %1: ").arg(i))
1052 << TQString(TQString(
"> reparent of 0x%1").arg(w,0,16))
1053 << TQString(TQString(
" into 0x%1").arg(winId(),0,16))
1054 << TQString(
" failed") <<
endl;
1057 if( parent != winId())
1064 void QXEmbed::handleEmbed()
1069 XAddToSaveSet( tqt_xdisplay(), window );
1070 XResizeWindow(tqt_xdisplay(), window, width(), height());
1071 XMapRaised(tqt_xdisplay(), window);
1073 sendSyntheticConfigureNotifyEvent();
1075 extraData()->xDndProxy = window;
1079 TQEvent * layoutHint =
new TQEvent( TQEvent::LayoutHint );
1080 TQApplication::postEvent( parent(), layoutHint );
1082 windowChanged( window );
1088 sendFocusMessage(window, XFocusIn, NotifyNormal, NotifyPointer );
1091 sendXEmbedMessage( window, XEMBED_EMBEDDED_NOTIFY, 0, (
long) winId() );
1092 if (isActiveWindow())
1093 sendXEmbedMessage( window, XEMBED_WINDOW_ACTIVATE);
1095 sendXEmbedMessage( window, XEMBED_WINDOW_DEACTIVATE);
1097 sendXEmbedMessage( window, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT );
1102 WId QXEmbed::embeddedWinId()
const
1110 bool QXEmbed::focusNextPrevChild(
bool next )
1122 return TQWidget::focusNextPrevChild( next );
1127 bool QXEmbed::x11Event( XEvent* e)
1129 switch ( e->type ) {
1131 if ( e->xdestroywindow.window == window ) {
1134 windowChanged( window );
1135 emit embeddedWindowDestroyed();
1141 window = e->xcreatewindow.window;
1145 case ReparentNotify:
1146 if ( e->xreparent.window == d->focusProxy->winId() )
1148 if ( window && e->xreparent.window == window &&
1149 e->xreparent.parent != winId() ) {
1152 windowChanged( window );
1153 emit embeddedWindowDestroyed();
1158 XRemoveFromSaveSet( tqt_xdisplay(), window );
1159 }
else if ( e->xreparent.parent == winId()){
1161 window = e->xreparent.window;
1163 if( e->xreparent.window == window )
1168 if (d->xplain && d->xgrab) {
1174 TQFocusEvent::setReason( TQFocusEvent::Mouse );
1176 TQFocusEvent::resetReason();
1179 XAllowEvents(tqt_xdisplay(), ReplayPointer, CurrentTime);
1185 if (d->xplain && d->xgrab) {
1187 XAllowEvents(tqt_xdisplay(), SyncPointer, CurrentTime);
1193 if ( window && e->xmaprequest.window == window )
1194 XMapRaised(tqt_xdisplay(), window );
1199 if ( e->xclient.format == 32 && e->xclient.message_type == xembed ) {
1200 long message = e->xclient.data.l[1];
1201 switch ( message ) {
1205 case XEMBED_FOCUS_NEXT:
1206 TQWidget::focusNextPrevChild(
true );
1208 case XEMBED_FOCUS_PREV:
1209 TQWidget::focusNextPrevChild(
false );
1212 case XEMBED_REQUEST_FOCUS:
1213 if( ((QPublicWidget*)topLevelWidget())->topData()->embedded ) {
1214 focusMap->remove( topLevelWidget() );
1215 focusMap->insert( topLevelWidget(),
new TQGuardedPtr<TQWidget>(
this ));
1217 WId window = ((QPublicWidget*)topLevelWidget())->effectiveWinId();
1219 WId window = ((QPublicWidget*)topLevelWidget())->topData()->parentWinId;
1221 sendXEmbedMessage( window, XEMBED_REQUEST_FOCUS );
1226 TQFocusEvent::setReason( TQFocusEvent::Mouse );
1228 TQFocusEvent::resetReason();
1238 case ConfigureRequest:
1241 if (e->xconfigurerequest.window == window)
1243 sendSyntheticConfigureNotifyEvent();
1250 if ( TQWhatsThis::inWhatsThisMode() )
1251 enterWhatsThisMode();
1262 void QXEmbed::enterWhatsThisMode()
1268 TQWhatsThis::leaveWhatsThisMode();
1269 if ( !context_help )
1270 context_help = XInternAtom( x11Display(),
"_NET_WM_CONTEXT_HELP",
false );
1271 sendClientMessage(window , tqt_wm_protocols, context_help );
1276 void QXEmbed::windowChanged( WId )
1283 bool QXEmbed::processClientCmdline( TQWidget* client,
int& argc,
char ** argv )
1290 for ( i=1; i<myargc; i++ ) {
1291 if ( argv[i] && *argv[i] !=
'-' ) {
1292 argv[j++] = argv[i];
1295 TQCString arg = argv[i];
1296 if ( !strcmp(arg,
"-embed") && i < myargc-1 ) {
1297 TQCString s = argv[++i];
1300 argv[j++] = argv[i];
1305 embedClientIntoWindow( client, window );
1315 void QXEmbed::embedClientIntoWindow(TQWidget* client, WId window)
1318 XReparentWindow(tqt_xdisplay(), client->winId(), window, 0, 0);
1320 ((QXEmbed*)client)->topData()->embedded =
true;
1323 printf(
"[FIXME] WId not set in tdelibs/tdeui/qxembed.cpp\n");
1325 ((QXEmbed*)client)->topData()->parentWinId = window;
1336 TQSizePolicy QXEmbed::sizePolicy()
const
1338 return TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Expanding );
1343 TQSize QXEmbed::sizeHint()
const
1345 return minimumSizeHint();
1349 TQSize QXEmbed::minimumSizeHint()
const
1356 if (XGetWMNormalHints(tqt_xdisplay(), window, &size, &msize)
1357 && ( size.flags & PMinSize) ) {
1358 minw = size.min_width;
1359 minh = size.min_height;
1363 return TQSize( minw, minh );
1368 void QXEmbed::setAutoDelete(
bool b)
1374 bool QXEmbed::autoDelete()
const
1376 return d->autoDelete;
1380 bool QXEmbed::customWhatsThis()
const
1390 void QXEmbed::checkGrab()
1392 if (d->xplain && isActiveWindow() && !hasFocus()) {
1394 XGrabButton(tqt_xdisplay(), AnyButton, AnyModifier, winId(),
1395 false, ButtonPressMask, GrabModeSync, GrabModeAsync,
1400 XUngrabButton( tqt_xdisplay(), AnyButton, AnyModifier, winId() );
1407 void QXEmbed::sendSyntheticConfigureNotifyEvent()
1412 TQPoint globalPos = mapToGlobal(TQPoint(0,0));
1416 memset(&c, 0,
sizeof(c));
1417 c.type = ConfigureNotify;
1418 c.display = tqt_xdisplay();
1419 c.send_event = True;
1422 c.x = globalPos.x();
1423 c.y = globalPos.y();
1425 c.height = height();
1428 c.override_redirect = 0;
1429 XSendEvent( tqt_xdisplay(), c.event,
true, StructureNotifyMask, (XEvent*)&c );
1432 XSetWindowBorderWidth( tqt_xdisplay(), window, 1 );
1433 XSetWindowBorderWidth( tqt_xdisplay(), window, 0 );
1438 void QXEmbed::reparent( TQWidget * parent, WFlags f,
const TQPoint & p,
bool showIt )
1444 Q_ASSERT( !window );
1445 TQWidget::reparent( parent, f, p, showIt );
1449 #include "qxembed.moc"
kdbgstream kdDebug(int area=0)
TDEAction * revert(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Revert the current document to the last saved version (essentially will undo all changes).
kndbgstream & endl(kndbgstream &s)