Changeset 57099 in vbox
- Timestamp:
- Jul 27, 2015 3:01:49 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r57080 r57099 3337 3337 1 /* Source indication (1 = normal application) */); 3338 3338 } 3339 3340 /* static */ 3341 QVector<Atom> VBoxGlobal::flagsNetWmState(QWidget *pWidget) 3342 { 3343 /* Get display: */ 3344 Display *pDisplay = pWidget->x11Info().display(); 3345 3346 /* Prepare atoms: */ 3347 QVector<Atom> resultNetWmState; 3348 Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */); 3349 3350 /* Get the size of the property data: */ 3351 Atom actual_type; 3352 int iActualFormat; 3353 ulong uPropertyLength; 3354 ulong uBytesLeft; 3355 uchar *pPropertyData = 0; 3356 if (XGetWindowProperty(pDisplay, pWidget->window()->winId(), 3357 net_wm_state, 0, 0, False, XA_ATOM, &actual_type, &iActualFormat, 3358 &uPropertyLength, &uBytesLeft, &pPropertyData) == Success && 3359 actual_type == XA_ATOM && iActualFormat == 32) 3360 { 3361 resultNetWmState.resize(uBytesLeft / 4); 3362 XFree((char*)pPropertyData); 3363 pPropertyData = 0; 3364 3365 /* Fetch all data: */ 3366 if (XGetWindowProperty(pDisplay, pWidget->window()->winId(), 3367 net_wm_state, 0, resultNetWmState.size(), False, XA_ATOM, &actual_type, &iActualFormat, 3368 &uPropertyLength, &uBytesLeft, &pPropertyData) != Success) 3369 resultNetWmState.clear(); 3370 else if (uPropertyLength != (ulong)resultNetWmState.size()) 3371 resultNetWmState.resize(uPropertyLength); 3372 3373 /* Put it into resultNetWmState: */ 3374 if (!resultNetWmState.isEmpty()) 3375 memcpy(resultNetWmState.data(), pPropertyData, resultNetWmState.size() * sizeof(Atom)); 3376 if (pPropertyData) 3377 XFree((char*)pPropertyData); 3378 } 3379 3380 /* Return result: */ 3381 return resultNetWmState; 3382 } 3383 3384 /* static */ 3385 bool VBoxGlobal::isFullScreenFlagSet(QWidget *pWidget) 3386 { 3387 /* Get display: */ 3388 Display *pDisplay = pWidget->x11Info().display(); 3389 3390 /* Prepare atoms: */ 3391 Atom net_wm_state_fullscreen = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", True /* only if exists */); 3392 3393 /* Check if flagsNetWmState(pWidget) contains full-screen flag: */ 3394 return flagsNetWmState(pWidget).contains(net_wm_state_fullscreen); 3395 } 3396 3397 /* static */ 3398 void VBoxGlobal::setFullScreenFlag(QWidget *pWidget) 3399 { 3400 /* Get display: */ 3401 Display *pDisplay = pWidget->x11Info().display(); 3402 3403 /* Prepare atoms: */ 3404 QVector<Atom> resultNetWmState = flagsNetWmState(pWidget); 3405 Atom net_wm_state = XInternAtom(pDisplay, "_NET_WM_STATE", True /* only if exists */); 3406 Atom net_wm_state_fullscreen = XInternAtom(pDisplay, "_NET_WM_STATE_FULLSCREEN", True /* only if exists */); 3407 3408 /* Append resultNetWmState with full-screen flag if necessary: */ 3409 if (!resultNetWmState.contains(net_wm_state_fullscreen)) 3410 { 3411 resultNetWmState.append(net_wm_state_fullscreen); 3412 /* Apply property to widget again: */ 3413 XChangeProperty(pDisplay, pWidget->window()->winId(), 3414 net_wm_state, XA_ATOM, 32, PropModeReplace, 3415 (unsigned char*)resultNetWmState.data(), resultNetWmState.size()); 3416 } 3417 } 3339 3418 #endif /* Q_WS_X11 */ 3340 3419 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r57080 r57099 46 46 #include "CSession.h" 47 47 #include "CGuestOSType.h" 48 49 /* Other includes: */ 50 #ifdef Q_WS_X11 51 # include <X11/Xdefs.h> 52 #endif /* Q_WS_X11 */ 48 53 49 54 /* Forward declarations: */ … … 376 381 /** X11: Performs mapping of the passed @a pWidget to host-screen with passed @a uScreenId. */ 377 382 static bool setFullScreenMonitorX11(QWidget *pWidget, ulong uScreenId); 383 384 /** X11: Returns a list of current _NET_WM_STATE flags for passed @a pWidget. */ 385 static QVector<Atom> flagsNetWmState(QWidget *pWidget); 386 /** X11: Check whether _NET_WM_STATE_FULLSCREEN flag is set for passed @a pWidget. */ 387 static bool isFullScreenFlagSet(QWidget *pWidget); 388 /** X11: Sets _NET_WM_STATE_FULLSCREEN flag for passed @a pWidget. */ 389 static void setFullScreenFlag(QWidget *pWidget); 378 390 #endif /* Q_WS_X11 */ 379 391
Note:
See TracChangeset
for help on using the changeset viewer.