VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp@ 27064

Last change on this file since 27064 was 27064, checked in by vboxsync, 15 years ago

FE/Qt4: new core: Mac fixes for r58372

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* $Id: UIMachineWindowFullscreen.cpp 27064 2010-03-05 10:05:45Z vboxsync $ */
2/** @file
3 *
4 * VBox frontends: Qt GUI ("VirtualBox"):
5 * UIMachineWindowFullscreen class implementation
6 */
7
8/*
9 * Copyright (C) 2010 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24/* Global includes */
25#include <QDesktopWidget>
26#ifdef Q_WS_MAC
27# include <QMenuBar>
28#endif /* Q_WS_MAC */
29
30/* Local includes */
31#include "VBoxGlobal.h"
32
33#ifdef Q_WS_MAC
34#include "UISession.h"
35#endif /* Q_WS_MAC */
36#include "UIMachineLogic.h"
37#include "UIMachineView.h"
38#include "UIMachineWindowFullscreen.h"
39
40UIMachineWindowFullscreen::UIMachineWindowFullscreen(UIMachineLogic *pMachineLogic, ulong uScreenId)
41 : QIWithRetranslateUI2<QIMainDialog>(0, Qt::FramelessWindowHint)
42 , UIMachineWindow(pMachineLogic, uScreenId)
43{
44 /* "This" is machine window: */
45 m_pMachineWindow = this;
46
47 /* Prepare window icon: */
48 prepareWindowIcon();
49
50 /* Prepare console connections: */
51 prepareConsoleConnections();
52
53#ifdef Q_WS_MAC
54 /* Prepare menu: */
55 prepareMenu();
56#endif /* Q_WS_MAC */
57
58 /* Retranslate normal window finally: */
59 retranslateUi();
60
61 /* Prepare machine view container: */
62 prepareMachineViewContainer();
63
64 /* Prepare normal machine view: */
65 prepareMachineView();
66
67 /* Update all the elements: */
68 updateAppearanceOf(UIVisualElement_AllStuff);
69
70 /* Show window: */
71 showFullScreen();
72
73#ifdef Q_WS_MAC
74 /* Make sure it is really on the right place (especially on the Mac) */
75 move(0, 0);
76#endif /* Q_WS_MAC */
77}
78
79UIMachineWindowFullscreen::~UIMachineWindowFullscreen()
80{
81 /* Cleanup normal machine view: */
82 cleanupMachineView();
83}
84
85void UIMachineWindowFullscreen::sltMachineStateChanged()
86{
87 UIMachineWindow::sltMachineStateChanged();
88}
89
90void UIMachineWindowFullscreen::sltTryClose()
91{
92 UIMachineWindow::sltTryClose();
93}
94
95void UIMachineWindowFullscreen::retranslateUi()
96{
97 /* Translate parent class: */
98 UIMachineWindow::retranslateUi();
99
100#ifdef Q_WS_MAC
101 // TODO_NEW_CORE
102// m_pDockSettingsMenu->setTitle(tr("Dock Icon"));
103// m_pDockDisablePreview->setText(tr("Show Application Icon"));
104// m_pDockEnablePreviewMonitor->setText(tr("Show Monitor Preview"));
105#endif /* Q_WS_MAC */
106}
107
108#ifdef Q_WS_X11
109bool UIMachineWindowFullscreen::x11Event(XEvent *pEvent)
110{
111 /* Qt bug: when the console view grabs the keyboard, FocusIn, FocusOut,
112 * WindowActivate and WindowDeactivate Qt events are not properly sent
113 * on top level window (i.e. this) deactivation. The fix is to substiute
114 * the mode in FocusOut X11 event structure to NotifyNormal to cause
115 * Qt to process it as desired. */
116 if (pEvent->type == FocusOut)
117 {
118 if (pEvent->xfocus.mode == NotifyWhileGrabbed &&
119 (pEvent->xfocus.detail == NotifyAncestor ||
120 pEvent->xfocus.detail == NotifyInferior ||
121 pEvent->xfocus.detail == NotifyNonlinear))
122 {
123 pEvent->xfocus.mode = NotifyNormal;
124 }
125 }
126 return false;
127}
128#endif
129
130void UIMachineWindowFullscreen::closeEvent(QCloseEvent *pEvent)
131{
132 return UIMachineWindow::closeEvent(pEvent);
133}
134
135#ifdef Q_WS_MAC
136void UIMachineWindowFullscreen::prepareMenu()
137{
138 setMenuBar(uisession()->newMenuBar());
139}
140#endif /* Q_WS_MAC */
141
142void UIMachineWindowFullscreen::prepareMachineView()
143{
144#ifdef VBOX_WITH_VIDEOHWACCEL
145 /* Need to force the QGL framebuffer in case 2D Video Acceleration is supported & enabled: */
146 bool bAccelerate2DVideo = session().GetMachine().GetAccelerate2DVideoEnabled() && VBoxGlobal::isAcceleration2DVideoAvailable();
147#endif
148
149 /* Set central widget: */
150 setCentralWidget(new QWidget);
151
152 /* Set central widget layout: */
153 centralWidget()->setLayout(m_pMachineViewContainer);
154
155 m_pMachineView = UIMachineView::create( this
156 , vboxGlobal().vmRenderMode()
157#ifdef VBOX_WITH_VIDEOHWACCEL
158 , bAccelerate2DVideo
159#endif
160 , machineLogic()->visualStateType()
161 , m_uScreenId);
162
163 /* Add machine view into layout: */
164 m_pMachineViewContainer->addWidget(m_pMachineView, 1, 1, Qt::AlignVCenter | Qt::AlignHCenter);
165
166 /* The background has to go black: */
167 QPalette palette(centralWidget()->palette());
168 palette.setColor(centralWidget()->backgroundRole(), Qt::black);
169 centralWidget()->setPalette(palette);
170 centralWidget()->setAutoFillBackground(true);
171 setAutoFillBackground(true);
172}
173
174void UIMachineWindowFullscreen::cleanupMachineView()
175{
176 /* Do not cleanup machine view if it is not present: */
177 if (!machineView())
178 return;
179
180 UIMachineView::destroy(m_pMachineView);
181 m_pMachineView = 0;
182}
183
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette