Changeset 2540 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- May 8, 2007 4:06:27 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 20981
- Location:
- trunk/src/VBox/Frontends
- Files:
-
- 5 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
Note:
See TracChangeset
for help on using the changeset viewer.