/** \brief Retrieve info from window, needed for accel layer */ void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo) { ADM_assert(videoWindow); QWidget* widget = videoWindow->parentWidget(); xinfo->widget = videoWindow; xinfo->systemWindowId = 0; #if defined(_WIN32) xinfo->display=(void *)videoWindow->winId(); xinfo->systemWindowId=videoWindow->winId(); #elif defined(__APPLE__) #if defined(ADM_CPU_X86_64) xinfo->display = (void*)videoWindow->winId(); xinfo->systemWindowId=videoWindow->winId(); #else xinfo->display = HIViewGetWindow(HIViewRef(widget->winId())); xinfo->systemWindowId= HIViewGetWindow(HIViewRef(widget->winId())); #endif #else #if QT_VERSION < QT_VERSION_CHECK(5,0,0) const QX11Info &info=videoWindow->x11Info(); xinfo->display=info.display(); #else xinfo->display=XOpenDisplay(NULL); #endif xinfo->systemWindowId=videoWindow->winId(); #endif QPoint localPoint(0,0); QPoint windowPoint = videoWindow->mapToGlobal(localPoint); xinfo->x = windowPoint.x(); xinfo->y = windowPoint.y(); xinfo->width = displayW; xinfo->height = displayH; }
/**************************************************************************** Hacks to glue AGL to an HIView ***************************************************************************/ QRegion qt_mac_get_widget_rgn(const QWidget *widget) { if(!widget->isVisible() || widget->isMinimized()) return QRegion(); const QRect wrect = QRect(qt_mac_posInWindow(widget), widget->size()); if(!wrect.isValid()) return QRegion(); RgnHandle macr = qt_mac_get_rgn(); GetControlRegion((HIViewRef)widget->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, wrect.x(), wrect.y()); QRegion ret = qt_mac_convert_mac_region(macr); QPoint clip_pos = wrect.topLeft(); for(const QWidget *last_clip = 0, *clip = widget; clip; last_clip = clip, clip = clip->parentWidget()) { if(clip != widget) { GetControlRegion((HIViewRef)clip->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, clip_pos.x(), clip_pos.y()); ret &= qt_mac_convert_mac_region(macr); } const QObjectList &children = clip->children(); for(int i = children.size()-1; i >= 0; --i) { if(QWidget *child = qobject_cast<QWidget*>(children.at(i))) { if(child == last_clip) break; // This check may seem weird, but when we are using a unified toolbar // The widget is actually being owned by that toolbar and not by Qt. // This means that the geometry it reports will be wrong // and will accidentally cause problems when calculating the region // So, it is better to skip these widgets since they aren't the hierarchy // anyway. if (HIViewGetSuperview(HIViewRef(child->winId())) != HIViewRef(clip->winId())) continue; if(child->isVisible() && !child->isMinimized() && !child->isTopLevel()) { const QRect childRect = QRect(clip_pos+child->pos(), child->size()); if(childRect.isValid() && wrect.intersects(childRect)) { GetControlRegion((HIViewRef)child->winId(), kControlStructureMetaPart, macr); OffsetRgn(macr, childRect.x(), childRect.y()); ret -= qt_mac_convert_mac_region(macr); } } } } if(clip->isWindow()) break; clip_pos -= clip->pos(); } qt_mac_dispose_rgn(macr); return ret; }
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) { Q_Q(QDockWidget); if (!floating && parent) { QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea) return; // this dockwidget can't be redocked } bool wasFloating = q->isFloating(); bool hidden = q->isHidden(); if (q->isVisible()) q->hide(); Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget; QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout); const bool nativeDeco = dwLayout->nativeWindowDeco(floating); if (nativeDeco) { flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; if (hasFeature(this, QDockWidget::DockWidgetClosable)) flags |= Qt::WindowCloseButtonHint; } else { flags |= Qt::FramelessWindowHint; } if (unplug) flags |= Qt::X11BypassWindowManagerHint; q->setWindowFlags(flags); #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) { ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0); } #endif if (!rect.isNull()) q->setGeometry(rect); updateButtons(); if (!hidden) q->show(); if (floating != wasFloating) { emit q->topLevelChanged(floating); if (!floating && parent) { QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (mwlayout) emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); } } resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco); }
void getMainWindowHandles(intptr_t *handle, intptr_t *nativeHandle) { *handle = (intptr_t)QuiMainWindows; #if defined(__APPLE__) && !defined(ADM_CPU_X86_64) *nativeHandle = (intptr_t)HIViewGetWindow(HIViewRef(QuiMainWindows->winId())); #else *nativeHandle = (intptr_t)QuiMainWindows->winId(); #endif }
void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect) { Q_Q(QDockWidget); bool wasFloating = q->isFloating(); bool hidden = q->isHidden(); if (q->isVisible()) q->hide(); Qt::WindowFlags flags = floating ? Qt::Tool : Qt::Widget; QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout()); bool nativeDeco = floating && layout->widget(QDockWidgetLayout::TitleBar) == 0; #if defined(Q_WS_X11) || defined(Q_WS_QWS) nativeDeco = false; #endif if (nativeDeco) { flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint; if (hasFeature(q, QDockWidget::DockWidgetClosable)) flags |= Qt::WindowSystemMenuHint; } else { flags |= Qt::FramelessWindowHint; } if (unplug) flags |= Qt::X11BypassWindowManagerHint; q->setWindowFlags(flags); #ifdef Q_WS_MAC if (floating && nativeDeco && (q->features() & QDockWidget::DockWidgetVerticalTitleBar)) { ChangeWindowAttributes(HIViewGetWindow(HIViewRef(q->winId())), kWindowSideTitlebarAttribute, 0); } #endif if (!rect.isNull()) q->setGeometry(rect); updateButtons(); if (!hidden) q->show(); if (floating != wasFloating) emit q->topLevelChanged(floating); resizer->setActive(QWidgetResizeHandler::Resize, !unplug && floating && !nativeDeco); }
/** \brief Retrieve info from window, needed for accel layer */ void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo) { #if defined(__WIN32) xinfo->display=videoWindow->winId(); #elif defined(__APPLE__) QWidget* widget = videoWindow->parentWidget(); xinfo->display = HIViewGetWindow(HIViewRef(widget->winId())); xinfo->window = 0; xinfo->x = widget->x(); xinfo->y = widget->parentWidget()->height() - (widget->y() + displayH); xinfo->width = displayW; xinfo->height = displayH; #else const QX11Info &info=videoWindow->x11Info(); xinfo->display=info.display(); xinfo->window=videoWindow->winId(); #endif }
void QGLContext::updatePaintDevice() { Q_D(QGLContext); d->update = false; #if 0 //(MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { if(d->paintDevice->devType() == QInternal::Widget) { QWidget *w = (QWidget *)d->paintDevice; aglSetHIViewRef((AGLContext)d->cx, (HIViewRef)w->winId()); } else if(d->paintDevice->devType() == QInternal::Pixmap) { QPixmap *pm = (QPixmap *)d->paintDevice; aglSetOffScreen((AGLContext)d->cx, pm->width(), pm->height(), qt_mac_pixmap_get_bytes_per_line(pm), qt_mac_pixmap_get_base(pm)); } else { qWarning("QGLContext::updatePaintDevice(): Not sure how to render OpenGL on this device!"); } } else #endif { #ifndef Q_OS_MAC64 if(d->paintDevice->devType() == QInternal::Widget) { //get control information QWidget *w = (QWidget *)d->paintDevice; HIViewRef hiview = (HIViewRef)w->winId(); WindowPtr window = qt_mac_window_for(hiview); #ifdef DEBUG_OPENGL_REGION_UPDATE static int serial_no_gl = 0; qDebug("[%d] %p setting on %s::%s %p/%p [%s]", ++serial_no_gl, w, w->metaObject()->className(), w->objectName().toLatin1().constData(), hiview, window, w->handle() ? "Inside" : "Outside"); #endif //update drawable if(0 && w->isWindow() && w->isFullScreen()) { aglSetDrawable((AGLContext)d->cx, 0); aglSetFullScreen((AGLContext)d->cx, w->width(), w->height(), 0, QApplication::desktop()->screenNumber(w)); w->hide(); } else { AGLDrawable old_draw = aglGetDrawable((AGLContext)d->cx), new_draw = GetWindowPort(window); if(old_draw != new_draw) aglSetDrawable((AGLContext)d->cx, new_draw); } if(!w->isWindow()) { QRegion clp = qt_mac_get_widget_rgn(w); //get drawable area #ifdef DEBUG_OPENGL_REGION_UPDATE if(clp.isEmpty()) { qDebug(" Empty area!"); } else { QVector<QRect> rs = clp.rects(); for(int i = 0; i < rs.count(); i++) qDebug(" %d %d %d %d", rs[i].x(), rs[i].y(), rs[i].width(), rs[i].height()); } #endif //update the clip if(!aglIsEnabled((AGLContext)d->cx, AGL_BUFFER_RECT)) aglEnable((AGLContext)d->cx, AGL_BUFFER_RECT); if(clp.isEmpty()) { GLint offs[4] = { 0, 0, 0, 0 }; aglSetInteger((AGLContext)d->cx, AGL_BUFFER_RECT, offs); if(aglIsEnabled((AGLContext)d->cx, AGL_CLIP_REGION)) aglDisable((AGLContext)d->cx, AGL_CLIP_REGION); } else { HIPoint origin = { 0., 0. }; HIViewConvertPoint(&origin, HIViewRef(w->winId()), 0); const GLint offs[4] = { qRound(origin.x), w->window()->frameGeometry().height() - (qRound(origin.y) + w->height()), w->width(), w->height() }; aglSetInteger((AGLContext)d->cx, AGL_BUFFER_RECT, offs); aglSetInteger((AGLContext)d->cx, AGL_CLIP_REGION, (const GLint *)clp.handle(true)); if(!aglIsEnabled((AGLContext)d->cx, AGL_CLIP_REGION)) aglEnable((AGLContext)d->cx, AGL_CLIP_REGION); } } } else if(d->paintDevice->devType() == QInternal::Pixmap) { QPixmap *pm = (QPixmap *)d->paintDevice; PixMapHandle mac_pm = GetGWorldPixMap((GWorldPtr)pm->macQDHandle()); aglSetOffScreen((AGLContext)d->cx, pm->width(), pm->height(), GetPixRowBytes(mac_pm), GetPixBaseAddr(mac_pm)); } else { qWarning("QGLContext::updatePaintDevice(): Not sure how to render OpenGL on this device!"); } #endif // Q_OS_MAC64 } aglUpdateContext((AGLContext)d->cx); }