+ /* The Qt4 UI needs a fixed a widget ("this"), so that the parent layout is
+ * not messed up when we the video is reparented. Hence, we create an extra
+ * reparentable widget, that will be within the VideoWidget in windowed
+ * mode, and within the root window (NULL parent) in full-screen mode.
+ */
+ reparentable = new ReparentableWidget( this );
+ QLayout *innerLayout = new QHBoxLayout( reparentable );
+ innerLayout->setContentsMargins( 0, 0, 0, 0 );
+
+ /* The owner of the video window needs a stable handle (WinId). Reparenting
+ * in Qt4-X11 changes the WinId of the widget, so we need to create another
+ * dummy widget that stays within the reparentable widget. */
+ QWidget *stable = new QWidget();
+ QPalette plt = palette();
+ plt.setColor( QPalette::Window, Qt::black );
+ stable->setPalette( plt );
+ stable->setAutoFillBackground(true);
+ /* Indicates that the widget wants to draw directly onto the screen.
+ Widgets with this attribute set do not participate in composition
+ management */
+ stable->setAttribute( Qt::WA_PaintOnScreen, true );
+
+ innerLayout->addWidget( stable );
+
+ layout->addWidget( reparentable );
+
+#ifdef Q_WS_X11
+ /* HACK: Only one X11 client can subscribe to mouse button press events.
+ * VLC currently handles those in the video display.
+ * Force Qt4 to unsubscribe from mouse press and release events. */
+ Display *dpy = QX11Info::display();
+ Window w = stable->winId();
+ XWindowAttributes attr;
+
+ XGetWindowAttributes( dpy, w, &attr );
+ attr.your_event_mask &= ~(ButtonPressMask|ButtonReleaseMask);
+ XSelectInput( dpy, w, attr.your_event_mask );
+#endif
+ videoSync();