[Spice-commits] client/application.cpp client/application.h client/screen.cpp client/screen.h
Yonit Halperin
yhalperi at kemper.freedesktop.org
Thu Jul 21 02:50:46 PDT 2011
client/application.cpp | 95 +++++++++++++++++++++++++------------------------
client/application.h | 4 +-
client/screen.cpp | 4 --
client/screen.h | 2 +
4 files changed, 55 insertions(+), 50 deletions(-)
New commits:
commit 419222f0f3de82b14960938263d06cc36b9e1a84
Author: Yonit Halperin <yhalperi at redhat.com>
Date: Tue Jul 19 17:14:54 2011 +0300
client: fix endless recursion in rearrange_monitors, RHBZ #692976
The endless recursion happens due to Application::prepare_monitors calling RedScreen::resize
calling Application::rearrange_monitors calling Application::prepare_monitors
I changed RedScreen::resize not to call rearrange_monitors. Instead,
the monitor should be configured correctly from Application, before
calling resize.
In addition, I made some cleanups to allow reusing rearrange_monitors code.
diff --git a/client/application.cpp b/client/application.cpp
index bf0af02..d605aec 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -670,25 +670,9 @@ RedScreen* Application::get_screen(int id)
if (id != 0) {
if (_full_screen) {
- bool capture;
-
mon = get_monitor(id);
- capture = release_capture();
screen->set_monitor(mon);
- prepare_monitors();
- position_screens();
- screen->show_full_screen();
- if (screen->is_out_of_sync()) {
- _out_of_sync = true;
- /* If the client monitor cannot handle the guest resolution
- drop back to windowed mode */
- exit_full_screen();
- }
-
- if (capture) {
- _main_screen->activate();
- _main_screen->capture_mouse();
- }
+ rearrange_monitors(false, true, screen);
} else {
screen->show(false, _main_screen);
}
@@ -776,13 +760,7 @@ void Application::on_screen_destroyed(int id, bool was_captured)
}
_screens[id] = NULL;
if (reposition) {
- bool capture = was_captured || release_capture();
- prepare_monitors();
- position_screens();
- if (capture) {
- _main_screen->activate();
- _main_screen->capture_mouse();
- }
+ rearrange_monitors(was_captured, false);
}
}
@@ -1393,20 +1371,51 @@ void Application::on_screen_unlocked(RedScreen& screen)
screen.resize(SCREEN_INIT_WIDTH, SCREEN_INIT_HEIGHT);
}
-bool Application::rearrange_monitors(RedScreen& screen)
+void Application::rearrange_monitors(bool force_capture,
+ bool enter_full_screen,
+ RedScreen* screen)
{
- if (!_full_screen) {
- return false;
+ bool capture;
+ bool toggle_full_screen;
+
+ if (!_full_screen && !enter_full_screen) {
+ return;
}
- bool capture = release_capture();
+
+ toggle_full_screen = enter_full_screen && !screen;
+ capture = release_capture();
+#ifndef WIN32
+ if (toggle_full_screen) {
+ /* performing hide during resolution changes resulted in
+ missing WM_KEYUP events */
+ hide();
+ }
+#endif
prepare_monitors();
position_screens();
- if (capture && _main_screen != &screen) {
- capture = false;
- _main_screen->activate();
+ if (enter_full_screen) {
+ // toggling to full screen
+ if (toggle_full_screen) {
+ show_full_screen();
+ _main_screen->activate();
+
+ } else { // already in full screen mode and a new screen is displayed
+ screen->show_full_screen();
+ if (screen->is_out_of_sync()) {
+ _out_of_sync = true;
+ /* If the client monitor cannot handle the guest resolution
+ drop back to windowed mode */
+ exit_full_screen();
+ }
+ }
+ }
+
+ if (force_capture || capture) {
+ if (!toggle_full_screen) {
+ _main_screen->activate();
+ }
_main_screen->capture_mouse();
}
- return capture;
}
Monitor* Application::find_monitor(int id)
@@ -1523,20 +1532,8 @@ void Application::enter_full_screen()
{
LOG_INFO("");
_changing_screens = true;
- bool capture = release_capture();
assign_monitors();
-#ifndef WIN32
- /* performing hide during resolution changes resulted in
- missing WM_KEYUP events */
- hide();
-#endif
- prepare_monitors();
- position_screens();
- show_full_screen();
- _main_screen->activate();
- if (capture) {
- _main_screen->capture_mouse();
- }
+ rearrange_monitors(false, true);
_changing_screens = false;
_full_screen = true;
/* If the client monitor cannot handle the guest resolution drop back
@@ -1598,7 +1595,15 @@ bool Application::toggle_full_screen()
void Application::resize_screen(RedScreen *screen, int width, int height)
{
+ Monitor* mon;
+
+ if (_full_screen) {
+ if ((mon = screen->get_monitor())) {
+ mon->set_mode(width, height);
+ }
+ }
screen->resize(width, height);
+ rearrange_monitors(false, false);
if (screen->is_out_of_sync()) {
_out_of_sync = true;
/* If the client monitor cannot handle the guest resolution
diff --git a/client/application.h b/client/application.h
index a08da13..acb116e 100644
--- a/client/application.h
+++ b/client/application.h
@@ -216,7 +216,6 @@ public:
void on_disconnecting();
void on_visibility_start(int screen_id);
- bool rearrange_monitors(RedScreen& screen);
void enter_full_screen();
void exit_full_screen();
bool toggle_full_screen();
@@ -308,6 +307,9 @@ private:
void assign_monitors();
void restore_monitors();
void prepare_monitors();
+ void rearrange_monitors(bool force_capture,
+ bool enter_full_screen,
+ RedScreen* screen = NULL);
void position_screens();
void show_full_screen();
void send_key_down(RedKey key);
diff --git a/client/screen.cpp b/client/screen.cpp
index 7259ed4..b4b640c 100644
--- a/client/screen.cpp
+++ b/client/screen.cpp
@@ -189,11 +189,7 @@ void RedScreen::resize(int width, int height)
_size.y = height;
create_composit_area();
if (_full_screen) {
- bool cuptur = _owner.rearrange_monitors(*this);
__show_full_screen();
- if (cuptur) {
- capture_mouse();
- }
} else {
bool cuptur = is_mouse_captured();
if (cuptur) {
diff --git a/client/screen.h b/client/screen.h
index 1d40e6c..8fbc10a 100644
--- a/client/screen.h
+++ b/client/screen.h
@@ -62,6 +62,8 @@ public:
void attach_layer(ScreenLayer& layer);
void detach_layer(ScreenLayer& layer);
void on_layer_changed(ScreenLayer& layer);
+ /* When resizing on full screen mode, the monitor must be configured
+ * correctly before calling resize*/
void resize(int width, int height);
void set_name(const std::string& name);
uint64_t invalidate(const SpiceRect& rect, bool urgent);
More information about the Spice-commits
mailing list