- Timestamp:
- May 8, 2007 4:06:27 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 20981
- Location:
- trunk/src/VBox
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r2463 r2540 38 38 #include <X11/cursorfont.h> /* for XC_left_ptr */ 39 39 #include <X11/Xcursor/Xcursor.h> 40 #endif 41 40 42 #include <SDL_syswm.h> /* for SDL_GetWMInfo() */ 41 #endif42 43 43 44 #include "VBoxSDL.h" … … 506 507 if (!canShow) 507 508 return E_POINTER; 508 /* @todo return TRUE if gConsole is not NULL */ 509 #if defined (__LINUX__) 510 /// @todo see the big comment in Frontends/VirtualBox/src/VBoxVMListBoxItem::switchTo() 509 511 *canShow = FALSE; 512 #else 513 SDL_SysWMinfo info; 514 SDL_VERSION(&info.version); 515 *canShow = !!SDL_GetWMInfo(&info); 516 #endif 510 517 return S_OK; 511 518 } 512 519 513 STDMETHOD(OnShowWindow)() 514 { 515 /* @todo implement */ 516 return E_NOTIMPL; 520 STDMETHOD(OnShowWindow) (ULONG64 *winId) 521 { 522 SDL_SysWMinfo info; 523 SDL_VERSION(&info.version); 524 if (SDL_GetWMInfo(&info)) 525 { 526 #if defined (__LINUX__) 527 *winId = (ULONG64) info.info.x11.window; 528 #elif defined (__WIN__) 529 *winId = (ULONG64) info.window; 530 #else 531 AssertFailed(); 532 return E_FAIL; 533 #endif 534 return S_OK; 535 } 536 AssertFailed(); 537 return E_FAIL; 517 538 } 518 539 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxVMListBox.h
r1718 r2540 133 133 ULONG snapshotCount() const { return mSnapshotCount; } 134 134 135 /// @todo see comments in #switchTo() in VBoxVMListBox.cpp 136 #if 0 135 137 bool canSwitchTo() const { return mWinId != (WId) ~0; } 138 #endif 139 bool canSwitchTo() const; 136 140 bool switchTo(); 137 141 … … 161 165 162 166 ULONG mPid; 167 /// @todo see comments in #switchTo() in VBoxVMListBox.cpp 168 #if 0 163 169 WId mWinId; 170 #endif 164 171 }; 165 172 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r2463 r2540 280 280 VBoxConsoleCallback (VBoxConsoleView *v) { 281 281 #if defined (Q_WS_WIN) 282 refcnt = 0;283 #endif 284 view = v;282 mRefCnt = 0; 283 #endif 284 mView = v; 285 285 } 286 286 … … 291 291 #if defined (Q_WS_WIN) 292 292 STDMETHOD_(ULONG, AddRef)() { 293 return ::InterlockedIncrement (& refcnt);293 return ::InterlockedIncrement (&mRefCnt); 294 294 } 295 295 STDMETHOD_(ULONG, Release)() 296 296 { 297 long cnt = ::InterlockedDecrement (& refcnt);297 long cnt = ::InterlockedDecrement (&mRefCnt); 298 298 if (cnt == 0) 299 299 delete this; … … 322 322 BYTE *shape) 323 323 { 324 QApplication::postEvent ( 325 view, new MousePointerChangeEvent (visible, alpha, xhot, yhot, 326 width, height, 327 shape) 328 ); 324 QApplication::postEvent (mView, 325 new MousePointerChangeEvent (visible, alpha, 326 xhot, yhot, 327 width, height, shape)); 329 328 return S_OK; 330 329 } … … 332 331 STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL needsHostCursor) 333 332 { 334 QApplication::postEvent (view, new MouseCapabilityEvent (supportsAbsolute, needsHostCursor)); 333 QApplication::postEvent (mView, 334 new MouseCapabilityEvent (supportsAbsolute, 335 needsHostCursor)); 335 336 return S_OK; 336 337 } … … 339 340 { 340 341 LogFlowFunc (("machineState=%d\n", machineState)); 341 QApplication::postEvent ( 342 view, new StateChangeEvent ((CEnums::MachineState) machineState)); 342 QApplication::postEvent (mView, 343 new StateChangeEvent ( 344 (CEnums::MachineState) machineState)); 343 345 return S_OK; 344 346 } … … 346 348 STDMETHOD(OnAdditionsStateChange)() 347 349 { 348 CGuest guest = view->console().GetGuest();350 CGuest guest = mView->console().GetGuest(); 349 351 LogFlowFunc (("ver=%s, active=%d\n", 350 352 guest.GetAdditionsVersion().latin1(), … … 356 358 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock) 357 359 { 358 QApplication::postEvent ( 359 view, new ModifierKeyChangeEvent (fNumLock, fCapsLock, fScrollLock)); 360 QApplication::postEvent (mView, 361 new ModifierKeyChangeEvent (fNumLock, fCapsLock, 362 fScrollLock)); 360 363 return S_OK; 361 364 } … … 363 366 STDMETHOD(OnRuntimeError)(BOOL fatal, IN_BSTRPARAM id, IN_BSTRPARAM message) 364 367 { 365 QApplication::postEvent ( 366 view, new RuntimeErrorEvent (!!fatal, QString::fromUcs2 (id), 367 QString::fromUcs2 (message))); 368 QApplication::postEvent (mView, 369 new RuntimeErrorEvent (!!fatal, 370 QString::fromUcs2 (id), 371 QString::fromUcs2 (message))); 368 372 return S_OK; 369 373 } 370 374 371 STDMETHOD(OnCanShowWindow) (BOOL *canShow)375 STDMETHOD(OnCanShowWindow) (BOOL *canShow) 372 376 { 373 377 if (!canShow) 374 378 return E_POINTER; 375 /* @todo return TRUE... */ 379 380 #if defined (Q_WS_X11) 381 /// @todo see the big comment in VBoxVMListBoxItem::switchTo() 376 382 *canShow = FALSE; 383 #else 384 *canShow = TRUE; 385 #endif 377 386 return S_OK; 378 387 } 379 388 380 STDMETHOD(OnShowWindow)() 381 { 382 /* @todo implement */ 383 return E_NOTIMPL; 389 STDMETHOD(OnShowWindow) (ULONG64 *winId) 390 { 391 if (!winId) 392 return E_POINTER; 393 394 /* Return the ID of the top-level console window. */ 395 *winId = (ULONG64) mView->topLevelWidget()->winId(); 396 397 return S_OK; 384 398 } 385 399 386 400 protected: 387 401 388 VBoxConsoleView * view;402 VBoxConsoleView *mView; 389 403 390 404 #if defined (Q_WS_WIN) 391 405 private: 392 long refcnt;406 long mRefCnt; 393 407 #endif 394 408 }; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMListBox.cpp
r2139 r2540 34 34 #include <qfileinfo.h> 35 35 36 #if defined (Q_WS_MAC) 36 #if defined (Q_WS_X11) 37 # include <X11/Xlib.h> 38 #elif defined (Q_WS_MAC) 37 39 # include <Carbon/Carbon.h> 38 40 #endif … … 42 44 // Helpers 43 45 //////////////////////////////////////////////////////////////////////////////// 46 47 /// @todo Remove. See @c todo in #switchTo() below. 48 #if 0 44 49 45 50 #if defined (Q_WS_WIN32) … … 136 141 } 137 142 143 #endif 144 138 145 //////////////////////////////////////////////////////////////////////////////// 139 146 // VBoxVMListBoxItem class … … 367 374 { 368 375 mPid = mMachine.GetSessionPid(); 376 /// @todo Remove. See @c todo in #switchTo() below. 377 #if 0 369 378 mWinId = FindWindowIdFromPid (mPid); 379 #endif 370 380 } 371 381 else 372 382 { 373 383 mPid = (ULONG) ~0; 384 /// @todo Remove. See @c todo in #switchTo() below. 385 #if 0 374 386 mWinId = (WId) ~0; 387 #endif 375 388 } 376 389 } … … 393 406 394 407 mPid = (ULONG) ~0; 408 /// @todo Remove. See @c todo in #switchTo() below. 409 #if 0 395 410 mWinId = (WId) ~0; 411 #endif 396 412 } 397 413 … … 507 523 508 524 /** 525 * Returns @a true if we can activate and bring the VM console window to 526 * foreground, and @a false otherwise. 527 */ 528 bool VBoxVMListBoxItem::canSwitchTo() const 529 { 530 return const_cast <CMachine &> (mMachine).CanShowConsoleWindow(); 531 532 /// @todo Remove. See @c todo in #switchTo() below. 533 #if 0 534 return mWinId != (WId) ~0; 535 #endif 536 } 537 538 /** 509 539 * Tries to switch to the main window of the VM process. 510 540 * … … 513 543 bool VBoxVMListBoxItem::switchTo() 514 544 { 545 WId id = (WId) mMachine.ShowConsoleWindow(); 546 AssertWrapperOk (mMachine); 547 if (!mMachine.isOk()) 548 return false; 549 550 /* winId = 0 it means the console window has already done everything 551 * necessary to implement the "show window" semantics. */ 552 if (id == 0) 553 return true; 554 555 #if defined (Q_WS_WIN32) 556 557 if (IsIconic (id)) 558 ShowWindow (id, SW_RESTORE); 559 else if (!IsWindowVisible (id)) 560 ShowWindow (id, SW_SHOW); 561 562 return SetForegroundWindow (id); 563 564 #elif defined (Q_WS_X11) 565 566 /// @todo I've tried XRaiseWindow, XConfigureWindow, XRestackWindows and 567 /// XSetInputFocus here but couldn't get a useless result under 568 /// metacity/Ubuntu-7.04. XSetInputFocus works, but XRaiseWindow and 569 /// friends don't -- when it comes to bringing the window represented by 570 /// the given id (or its parent) to front, on top of all other top-level 571 /// windows. As a result, we would get input focus to a possibly invisible 572 /// (obscured by others) window!.. I've found one way to steal raise 573 /// window events from Metacity and prevent it from applying focus 574 /// stealing prevention (by settings override_redirect to True on the id's 575 /// parent using using XChangeWindowAttributes), but the result didn't 576 /// satisfy me: the raised console window started to behave like an 577 /// always-on-top window until moved or minimized which is wrong. Also, 578 /// there is little hope that this approach will work for other window 579 /// managers with "strong" focus stealing prevention algorithms, so I 580 /// decided to completely disable this feature on X11 -- Until someone has 581 /// enough time to find an acceptable solution that will work constantly 582 /// well under at least selected window managers, and will be simply 583 /// disabled on those where it doesn't work. 584 585 return false; 586 587 #elif defined (Q_WS_MAC) 588 589 /// @todo (r=dmik) Knut, everything you have to do here is to raise the 590 /// given window over all other top-level windows and give it focus. Ah, 591 /// and deiconify/show it first if it is minimized/hidden. I really hope 592 /// it's better on Mac than on X11. If not, feel free to revert to the 593 /// previous pid-based behavior. 594 595 return false; 596 597 #endif 598 599 return false; 600 601 /// @todo Below is the old method of switching to the console window 602 // based on the process ID of the console process. It should go away 603 // after the new (callback-based) method is fully tested. 604 #if 0 605 515 606 if (!canSwitchTo()) 516 607 return false; … … 575 666 576 667 return false; 668 669 #endif 577 670 578 671 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r2354 r2540 135 135 136 136 QIApplication a (argc, argv); 137 138 /* weird palette test */ 139 #if 0 140 QPalette pal = a.palette(); 141 pal.setColor (QColorGroup::Background, Qt::red); 142 pal.setBrush (QColorGroup::Background, 143 QBrush (QColor(), 144 QPixmap::fromMimeSource ("about_16px.png"))); 145 a.setPalette (pal); 146 #endif 137 147 138 148 #ifdef Q_WS_X11 -
trunk/src/VBox/Main/ConsoleImpl.cpp
r2527 r2540 3546 3546 * @note Locks this object for reading. 3547 3547 */ 3548 HRESULT Console::onShowWindow (BOOL aCheck, BOOL *aCanShow )3548 HRESULT Console::onShowWindow (BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId) 3549 3549 { 3550 3550 AssertReturn (aCanShow, E_POINTER); 3551 AssertReturn (aWinId, E_POINTER); 3551 3552 3552 3553 *aCanShow = FALSE; 3554 *aWinId = 0; 3553 3555 3554 3556 AutoCaller autoCaller (this); … … 3576 3578 while (it != mCallbacks.end()) 3577 3579 { 3578 rc = (*it++)->OnShowWindow(); 3580 ULONG64 winId = 0; 3581 rc = (*it++)->OnShowWindow (&winId); 3582 AssertComRC (rc); 3579 3583 if (FAILED (rc)) 3580 3584 return rc; 3585 /* only one callback may return non-null winId */ 3586 Assert (*aWinId == 0 || winId == 0); 3587 if (*aWinId == 0) 3588 *aWinId = winId; 3581 3589 } 3582 3590 } -
trunk/src/VBox/Main/MachineImpl.cpp
r2463 r2540 2301 2301 2302 2302 /* start with No */ 2303 aCanShow = FALSE;2303 *aCanShow = FALSE; 2304 2304 2305 2305 AutoCaller autoCaller (this); … … 2322 2322 return S_OK; 2323 2323 2324 return directControl->OnShowWindow (TRUE /* aCheck */, aCanShow); 2325 } 2326 2327 STDMETHODIMP Machine::ShowConsoleWindow() 2328 { 2324 ULONG64 dummy; 2325 return directControl->OnShowWindow (TRUE /* aCheck */, aCanShow, &dummy); 2326 } 2327 2328 STDMETHODIMP Machine::ShowConsoleWindow (ULONG64 *aWinId) 2329 { 2330 if (!aWinId) 2331 return E_POINTER; 2332 2329 2333 AutoCaller autoCaller (this); 2330 2334 AssertComRCReturn (autoCaller.rc(), autoCaller.rc()); … … 2347 2351 2348 2352 BOOL dummy; 2349 return directControl->OnShowWindow (FALSE /* aCheck */, &dummy );2353 return directControl->OnShowWindow (FALSE /* aCheck */, &dummy, aWinId); 2350 2354 } 2351 2355 -
trunk/src/VBox/Main/SessionImpl.cpp
r2463 r2540 590 590 } 591 591 592 STDMETHODIMP Session::OnShowWindow (BOOL aCheck, BOOL *aCanShow )592 STDMETHODIMP Session::OnShowWindow (BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId) 593 593 { 594 594 AutoCaller autoCaller (this); … … 599 599 mType == SessionType_DirectSession, E_FAIL); 600 600 601 return mConsole->onShowWindow (aCheck, aCanShow );601 return mConsole->onShowWindow (aCheck, aCanShow, aWinId); 602 602 } 603 603 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r2519 r2540 2585 2585 <method name="showConsoleWindow"> 2586 2586 <desc> 2587 Returns @c true if the VM console process can activate the 2588 console window and bring it to foreground on the desktop of 2589 the host PC. 2587 Activates the console window and brings it to foreground on 2588 the desktop of the host PC. Many modern window managers on 2589 many platforms implement some sort of focus stealing 2590 prevention logic, so that it may be impossible to activate 2591 a window without the help of the currently active 2592 application. In this case, this method will return a non-zero 2593 identifier that represents the top-level window of the VM 2594 console process. The caller, if it represents a currently 2595 active process, is responsible to use this identifier (in a 2596 platform-dependent manner) to perform actual window 2597 activation. 2590 2598 <note> 2591 2599 This method will fail if a session for this machine is not … … 2593 2601 </note> 2594 2602 </desc> 2603 <param name="winId" type="unsigned long long" dir="return"> 2604 <desc> 2605 Platform-dependent identifier of the top-level VM console 2606 window, or zero if this method has performed all actions 2607 necessary to implement the <i>show window</i> semantics for 2608 the given platform and/or VirtualBox front-end. 2609 </desc> 2610 </param> 2595 2611 </method> 2596 2612 … … 2819 2835 method should return a failure. 2820 2836 2837 Note that many modern window managers on many platforms 2838 implement some sort of focus stealing prevention logic, so 2839 that it may be impossible to activate a window without the 2840 help of the currently active application (which is supposedly 2841 an initiator of this notification). In this case, this method 2842 must return a non-zero identifier that represents the 2843 top-level window of the VM console process. The caller, if it 2844 represents a currently active process, is responsible to use 2845 this identifier (in a platform-dependent manner) to perform 2846 actual window activation. 2847 2848 This method must set @a winId to zero if it has performed all 2849 actions necessary to complete the request and the console 2850 window is now active and in foreground, to indicate that no 2851 further action is required on the caller's side. 2852 2821 2853 <note> 2822 2854 This notification is not designed to be implemented by … … 2828 2860 </note> 2829 2861 </desc> 2862 <param name="winId" type="unsigned long long" dir="return"> 2863 <desc> 2864 Platform-dependent identifier of the top-level VM console 2865 window, or zero if this method has performed all actions 2866 necessary to implement the <i>show window</i> semantics for 2867 the given platform and/or this VirtualBox front-end. 2868 </desc> 2869 </param> 2830 2870 </method> 2831 2871 … … 7415 7455 <param name="check" type="boolean" dir="in"/> 7416 7456 <param name="canShow" type="boolean" dir="out"/> 7457 <param name="winId" type="unsigned long long" dir="out"/> 7417 7458 </method> 7418 7459 -
trunk/src/VBox/Main/include/ConsoleImpl.h
r2527 r2540 199 199 void onKeyboardLedsChange (bool fNumLock, bool fCapsLock, bool fScrollLock); 200 200 void onRuntimeError (BOOL aFatal, INPTR BSTR aErrorID, INPTR BSTR aMessage); 201 HRESULT onShowWindow (BOOL aCheck, BOOL *aCanShow );201 HRESULT onShowWindow (BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId); 202 202 203 203 static const PDMDRVREG DrvStatusReg; -
trunk/src/VBox/Main/include/DisplayImpl.h
r2463 r2540 115 115 } 116 116 117 STDMETHOD(OnShowWindow)() 118 { 117 STDMETHOD(OnShowWindow)(ULONG64 *winId) 118 { 119 if (winId) 120 *winId = 0; 119 121 return S_OK; 120 122 } -
trunk/src/VBox/Main/include/MachineImpl.h
r2463 r2540 367 367 STDMETHOD(RemoveSharedFolder) (INPTR BSTR aName); 368 368 STDMETHOD(CanShowConsoleWindow) (BOOL *aCanShow); 369 STDMETHOD(ShowConsoleWindow) ();369 STDMETHOD(ShowConsoleWindow) (ULONG64 *aWinId); 370 370 371 371 // public methods only for internal purposes -
trunk/src/VBox/Main/include/SessionImpl.h
r2463 r2540 102 102 STDMETHOD(OnUSBDeviceAttach) (IUSBDevice *aDevice); 103 103 STDMETHOD(OnUSBDeviceDetach) (INPTR GUIDPARAM aId); 104 STDMETHOD(OnShowWindow) (BOOL aCheck, BOOL *aCanShow );104 STDMETHOD(OnShowWindow) (BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId); 105 105 106 106 // for VirtualBoxSupportErrorInfoImpl
Note:
See TracChangeset
for help on using the changeset viewer.