}
if (event->button() == Qt::LeftButton) {
- QWidget *win = ((QWidget *)parent->parent());
+ QWidget *win = parent->parentWidget();
grabPos = event->globalPos();
eventPos = event->pos();
/* Some part of QGLWidget's surface might be lost on Windows when view changing.
* So, we need an additional updating for display. */
display->update();
+
+#ifdef CONFIG_LINUX
+ popupMenu->slotTopMost(getUIState()->isOnTop());
+#endif
}
void MainWindow::closeController()
#define URL_TIZEN_ORG "<a href=\"https://developer.tizen.org\">https://developer.tizen.org</a>";
AboutDialog::AboutDialog(QWidget *parent) :
- QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
+ QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint)
{
setWindowTitle("About Emulator");
{
Q_UNUSED(event)
- QWidget *win = ((QWidget *)this->parent());
+ QWidget *win = parentWidget();
move(win->geometry().center().x() - (geometry().size().width() / 2),
win->geometry().center().y() - (geometry().size().height() / 2));
}
#include "contextmenu.h"
#include "emulator_common.h"
#include "mainwindow.h"
+#include "uiutil.h"
#include "menu/advancedmenuitem.h"
#include "menu/scalemenuitem.h"
-#ifdef CONFIG_WIN32
-#include <windows.h>
-#elif defined (CONFIG_LINUX)
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#endif
-
ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent)
{
this->parent = (MainWindow *)parent;
}
infoDialog->show();
+
+#ifdef CONFIG_LINUX
+ slotTopMost(parent->getUIState()->isOnTop());
+#endif
}
void ContextMenu::slotTopMost(bool on)
{
qDebug("stays on top : %s", on? "on" : "off");
-#ifdef CONFIG_WIN32
- HWND hWnd = (HWND)parent->winId();
- HWND hWndInsertAfter = ((on == true) ? HWND_TOPMOST : HWND_NOTOPMOST);
- SetWindowPos(hWnd, hWndInsertAfter, parent->pos().x(), parent->pos().y(), 0, 0, SWP_NOSIZE);
-#elif defined(CONFIG_LINUX)
- Display* display = XOpenDisplay(NULL);
- if (display == NULL) {
- qDebug("Error: XOpenDisplay() Failed. Always on top failed.");
- return;
- }
+#ifdef CONFIG_LINUX
+ /* On Ubuntu, all of the child windows which are higher than parent window in z-order
+ * should be getting a "ABOVE" state. */
- XClientMessageEvent event;
- memset(&event, 0, sizeof(event));
- event.type = ClientMessage;
- event.window = parent->winId();
- event.message_type = XInternAtom(display, "_NET_WM_STATE", False);
- event.format = 32;
- event.data.l[0] = on ? 1 : 0; /* 1:_NET_WM_STATE_ADD, 0:_NET_WM_STATE_REMOVE */
- event.data.l[1] = XInternAtom(display, "_NET_WM_STATE_ABOVE", False);
- event.data.l[2] = 0; /* unused */
- event.data.l[3] = 0;
- event.data.l[4] = 0;
-
- XSendEvent(display, DefaultRootWindow(display), False,
- SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&event);
- XFlush(display);
-
- XCloseDisplay(display);
-#elif defined(CONFIG_DARWIN)
- if (on == true) {
- parent->setWindowFlags(parent->windowFlags() | Qt::WindowStaysOnTopHint);
- } else {
- parent->setWindowFlags(parent->windowFlags() & ~(Qt::WindowStaysOnTopHint));
+ QWidgetList list = QApplication::topLevelWidgets();
+ QWidget *widget = NULL;
+ for (int i = 0; i < list.count(); i++) {
+ widget = list.at(i);
+ if (widget->isWindow() && widget->parentWidget() == parent) {
+ UIUtil::setTopMost(widget, on);
+ }
}
-
- parent->show();
#endif
+ UIUtil::setTopMost(parent, on);
+
actionTopMost->setChecked(on);
parent->getUIState()->setOnTop(on);
}
}
aboutDialog->show();
+
+#ifdef CONFIG_LINUX
+ slotTopMost(parent->getUIState()->isOnTop());
+#endif
}
void ContextMenu::slotForceClose()
#include <QtWidgets>
+#include "emulator_common.h"
#include "detailedinfodialog.h"
#include "aboutdialog.h"
#include "screenshotdialog.h"
{
Q_UNUSED(event)
- QWidget *win = ((QWidget *)this->parent());
+ QWidget *win = parentWidget();
move(win->geometry().center().x() - (geometry().size().width() / 2),
win->geometry().center().y() - (geometry().size().height() / 2));
}
if (event->button() == Qt::LeftButton) {
//qDebug("grab");
- QWidget *win = ((QWidget *) this->parent());
- grabWinPos = win->pos();
+ grabWinPos = parentWidget()->pos();
grabPos = event->globalPos();
}
return QApplication::screens().at(
QApplication::desktop()->primaryScreen())->virtualGeometry();
}
+
+void UIUtil::setTopMost(QWidget *widget, bool on)
+{
+ if (widget == NULL) {
+ return;
+ }
+
+#ifdef CONFIG_WIN32
+ HWND hWnd = (HWND)widget->winId();
+ HWND hWndInsertAfter = ((on == true) ? HWND_TOPMOST : HWND_NOTOPMOST);
+ SetWindowPos(hWnd, hWndInsertAfter, widget->pos().x(), widget->pos().y(), 0, 0, SWP_NOSIZE);
+#elif defined(CONFIG_LINUX)
+ Display* display = XOpenDisplay(NULL);
+ if (display == NULL) {
+ qDebug("Error: XOpenDisplay() Failed. Always on top failed.");
+ return;
+ }
+
+ XClientMessageEvent event;
+ memset(&event, 0, sizeof(event));
+ event.type = ClientMessage;
+ event.window = widget->winId();
+ event.message_type = XInternAtom(display, "_NET_WM_STATE", False);
+ event.format = 32;
+ event.data.l[0] = on ? 1 : 0; /* 1:_NET_WM_STATE_ADD, 0:_NET_WM_STATE_REMOVE */
+ event.data.l[1] = XInternAtom(display, "_NET_WM_STATE_ABOVE", False);
+ event.data.l[2] = 0; /* unused */
+ event.data.l[3] = 0;
+ event.data.l[4] = 0;
+
+ XSendEvent(display, DefaultRootWindow(display), False,
+ SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&event);
+ XFlush(display);
+
+ XCloseDisplay(display);
+#elif defined(CONFIG_DARWIN)
+ if (on == true) {
+ widget->setWindowFlags(widget->windowFlags() | Qt::WindowStaysOnTopHint);
+ } else {
+ widget->setWindowFlags(widget->windowFlags() & ~(Qt::WindowStaysOnTopHint));
+ }
+
+ widget->show();
+#endif
+}
#include <QScreen>
#include <QRect>
+#include "emulator_common.h"
+
+#ifdef CONFIG_WIN32
+#include <windows.h>
+#elif defined (CONFIG_LINUX)
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#endif
+
class UIUtil
{
public:
UIUtil();
static QRect getHostScreenBounds();
+ static void setTopMost(QWidget *widget, bool on);
};
#endif // UIUTIL_H