Opera 12.15 Source Code
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4; -*-
  2. **
  3. ** Copyright (C) 1995-2008 Opera Software AS. All rights reserved.
  4. **
  5. ** This file is part of the Opera web browser. It may not be distributed
  6. ** under any circumstances.
  7. **
  8. */
  9. #include "core/pch.h"
  10. #include "modules/display/vis_dev.h"
  11. #include "modules/doc/frm_doc.h"
  12. #include "modules/dochand/win.h"
  13. #include "modules/dochand/windowlistener.h"
  14. #include "modules/dochand/winman.h"
  15. #include "modules/pi/OpView.h"
  16. #ifdef GADGET_SUPPORT
  17. #include "modules/gadgets/OpGadget.h"
  18. #endif // GADGET_SUPPORT
  19. #ifdef SCOPE_WINDOW_MANAGER_SUPPORT
  20. # include "modules/scope/scope_window_listener.h"
  21. #endif // SCOPE_WINDOW_MANAGER_SUPPORT
  22. WindowListener::WindowListener(Window *window)
  23. : window(window)
  24. {
  25. }
  26. void WindowListener::OnResize(UINT32 width, UINT32 height)
  27. {
  28. #ifdef NEARBY_ELEMENT_DETECTION
  29. window->SetElementExpander(NULL);
  30. #endif // NEARBY_ELEMENT_DETECTION
  31. window->HandleNewWindowSize(width, height);
  32. }
  33. void WindowListener::OnMove()
  34. {
  35. #ifdef NEARBY_ELEMENT_DETECTION
  36. window->SetElementExpander(NULL);
  37. #endif // NEARBY_ELEMENT_DETECTION
  38. #ifdef _MACINTOSH_
  39. window->VisualDev()->UpdateScrollbars();
  40. #endif
  41. }
  42. void WindowListener::OnRenderingBufferSizeChanged(UINT32 width, UINT32 height)
  43. {
  44. if (width == 0 || height == 0)
  45. return;
  46. OpRect rendering_rect(0, 0, width, height);
  47. #ifdef _PRINT_SUPPORT_
  48. if (window->GetPreviewMode())
  49. if (VisualDevice* print_preview_vis_dev = window->DocManager()->GetPrintPreviewVD())
  50. print_preview_vis_dev->SetRenderingViewGeometryScreenCoords(rendering_rect);
  51. #endif // _PRINT_SUPPORT_
  52. if (VisualDevice* normal_vis_dev = window->VisualDev())
  53. normal_vis_dev->SetRenderingViewGeometryScreenCoords(rendering_rect);
  54. }
  55. void WindowListener::OnActivate(BOOL active)
  56. {
  57. #ifdef NEARBY_ELEMENT_DETECTION
  58. window->SetElementExpander(NULL);
  59. #endif // NEARBY_ELEMENT_DETECTION
  60. if (active)
  61. {
  62. FramesDocument * doc = window->GetActiveFrameDoc();
  63. VisualDevice *visdev;
  64. if (doc)
  65. visdev = doc->GetVisualDevice();
  66. else
  67. visdev = window->VisualDev();
  68. visdev->RestoreFocus(FOCUS_REASON_ACTIVATE);
  69. #ifdef DOM_JIL_API_SUPPORT
  70. if (window->GetType() == WIN_TYPE_GADGET && window->GetGadget())
  71. OpStatus::Ignore(window->GetGadget()->OnFocus());
  72. #endif // DOM_JIL_API_SUPPORT
  73. #ifdef SCOPE_WINDOW_MANAGER_SUPPORT
  74. OpScopeWindowListener::OnActiveWindowChanged(window);
  75. #endif // SCOPE_WINDOW_MANAGER_SUPPORT
  76. }
  77. else
  78. {
  79. window->VisualDev()->ReleaseFocus();
  80. }
  81. DocumentTreeIterator iterator(window);
  82. iterator.SetIncludeThis();
  83. while (iterator.Next())
  84. {
  85. FramesDocument* cur_doc = iterator.GetFramesDocument();
  86. OP_ASSERT(cur_doc);
  87. DOM_Environment* env = cur_doc->GetDOMEnvironment();
  88. if (env)
  89. if (active)
  90. env->OnWindowActivated();
  91. else
  92. env->OnWindowDeactivated();
  93. }
  94. }
  95. #ifdef GADGET_SUPPORT
  96. void WindowListener::OnShow(BOOL show)
  97. {
  98. if (window->GetType() == WIN_TYPE_GADGET)
  99. {
  100. if (show)
  101. window->GetGadget()->OnShow();
  102. else
  103. window->GetGadget()->OnHide();
  104. }
  105. }
  106. #endif // GADGET_SUPPORT
  107. void WindowListener::OnVisibilityChanged(BOOL vis)
  108. {
  109. #ifdef NEARBY_ELEMENT_DETECTION
  110. window->SetElementExpander(NULL);
  111. #endif // NEARBY_ELEMENT_DETECTION
  112. FramesDocument * doc = window->GetActiveFrameDoc();
  113. if (doc)
  114. {
  115. OpRect rendering_viewport = doc->GetVisualDevice()->GetRenderingViewport();
  116. if (!vis)
  117. rendering_viewport.width = rendering_viewport.height = 0;
  118. doc->OnRenderingViewportChanged(rendering_viewport);
  119. }
  120. window->SetVisibleOnScreen(vis);
  121. DocumentTreeIterator iterator(window);
  122. iterator.SetIncludeThis();
  123. while (iterator.Next())
  124. {
  125. FramesDocument* cur_doc = iterator.GetFramesDocument();
  126. cur_doc->OnVisibilityChanged();
  127. if (VisualDevice* visdev = cur_doc->GetVisualDevice())
  128. visdev->OnVisibilityChanged(vis);
  129. }
  130. }