- Timestamp:
- Jun 4, 2018 9:57:30 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 122897
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r72414 r72425 1590 1590 } 1591 1591 1592 /* static */1593 bool VBoxGlobal::activateWindow (WId aWId, bool aSwitchDesktop /* = true */)1594 {1595 RT_NOREF(aSwitchDesktop);1596 bool result = true;1597 1598 #if defined (VBOX_WS_WIN)1599 1600 HWND handle = (HWND)aWId;1601 1602 if (IsIconic (handle))1603 result &= !!ShowWindow (handle, SW_RESTORE);1604 else if (!IsWindowVisible (handle))1605 result &= !!ShowWindow (handle, SW_SHOW);1606 1607 result &= !!SetForegroundWindow (handle);1608 1609 #elif defined (VBOX_WS_X11)1610 1611 Display *dpy = QX11Info::display();1612 1613 if (aSwitchDesktop)1614 {1615 /* try to find the desktop ID using the NetWM property */1616 CARD32 *desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL,1617 "_NET_WM_DESKTOP");1618 if (desktop == NULL)1619 // WORKAROUND:1620 // if the NetWM properly is not supported try to find1621 // the desktop ID using the GNOME WM property.1622 desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL,1623 "_WIN_WORKSPACE");1624 1625 if (desktop != NULL)1626 {1627 Bool ok = XXSendClientMessage (dpy, DefaultRootWindow (dpy),1628 "_NET_CURRENT_DESKTOP",1629 *desktop);1630 if (!ok)1631 {1632 Log1WarningFunc(("Couldn't switch to desktop=%08X\n", desktop));1633 result = false;1634 }1635 XFree (desktop);1636 }1637 else1638 {1639 Log1WarningFunc(("Couldn't find a desktop ID for aWId=%08X\n", aWId));1640 result = false;1641 }1642 }1643 1644 Bool ok = XXSendClientMessage (dpy, aWId, "_NET_ACTIVE_WINDOW");1645 result &= !!ok;1646 1647 XRaiseWindow (dpy, aWId);1648 1649 #else1650 1651 NOREF (aWId);1652 NOREF (aSwitchDesktop);1653 AssertFailed();1654 result = false;1655 1656 #endif1657 1658 if (!result)1659 Log1WarningFunc(("Couldn't activate aWId=%08X\n", aWId));1660 1661 return result;1662 }1663 1664 1592 #if defined (VBOX_WS_X11) 1665 1593 … … 1716 1644 SubstructureRedirectMask, &ev) != 0; 1717 1645 } 1646 1647 #endif 1648 1649 /* static */ 1650 bool VBoxGlobal::activateWindow (WId aWId, bool aSwitchDesktop /* = true */) 1651 { 1652 RT_NOREF(aSwitchDesktop); 1653 bool result = true; 1654 1655 #if defined (VBOX_WS_WIN) 1656 1657 HWND handle = (HWND)aWId; 1658 1659 if (IsIconic (handle)) 1660 result &= !!ShowWindow (handle, SW_RESTORE); 1661 else if (!IsWindowVisible (handle)) 1662 result &= !!ShowWindow (handle, SW_SHOW); 1663 1664 result &= !!SetForegroundWindow (handle); 1665 1666 #elif defined (VBOX_WS_X11) 1667 1668 Display *dpy = QX11Info::display(); 1669 1670 if (aSwitchDesktop) 1671 { 1672 /* try to find the desktop ID using the NetWM property */ 1673 CARD32 *desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL, 1674 "_NET_WM_DESKTOP"); 1675 if (desktop == NULL) 1676 // WORKAROUND: 1677 // if the NetWM properly is not supported try to find 1678 // the desktop ID using the GNOME WM property. 1679 desktop = (CARD32 *) XXGetProperty (dpy, aWId, XA_CARDINAL, 1680 "_WIN_WORKSPACE"); 1681 1682 if (desktop != NULL) 1683 { 1684 Bool ok = XXSendClientMessage (dpy, DefaultRootWindow (dpy), 1685 "_NET_CURRENT_DESKTOP", 1686 *desktop); 1687 if (!ok) 1688 { 1689 Log1WarningFunc(("Couldn't switch to desktop=%08X\n", desktop)); 1690 result = false; 1691 } 1692 XFree (desktop); 1693 } 1694 else 1695 { 1696 Log1WarningFunc(("Couldn't find a desktop ID for aWId=%08X\n", aWId)); 1697 result = false; 1698 } 1699 } 1700 1701 Bool ok = XXSendClientMessage (dpy, aWId, "_NET_ACTIVE_WINDOW"); 1702 result &= !!ok; 1703 1704 XRaiseWindow (dpy, aWId); 1705 1706 #else 1707 1708 NOREF (aWId); 1709 NOREF (aSwitchDesktop); 1710 AssertFailed(); 1711 result = false; 1712 1713 #endif 1714 1715 if (!result) 1716 Log1WarningFunc(("Couldn't activate aWId=%08X\n", aWId)); 1717 1718 return result; 1719 } 1720 1721 #if defined (VBOX_WS_X11) 1718 1722 1719 1723 /* static */
Note:
See TracChangeset
for help on using the changeset viewer.