Merge lp:~cyphermox/unity/multimonitor into lp:unity

Proposed by Mathieu Trudel-Lapierre
Status: Merged
Merged at revision: 893
Proposed branch: lp:~cyphermox/unity/multimonitor
Merge into: lp:unity
Diff against target: 111 lines (+70/-0)
2 files modified
src/unityshell.cpp (+64/-0)
src/unityshell.h (+6/-0)
To merge this branch: bzr merge lp:~cyphermox/unity/multimonitor
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Needs Fixing
Alex Launi (community) Approve
Review via email: mp+50234@code.launchpad.net

Description of the change

I've been testing this code on a laptop with an external screen and it seems to work fine with most resolution changes (all secondary screen res changes, most res changes of the primary screen with the notable exception of 800x600 by my test on my hardware).

This has already been working just fine when first starting unity, whichever resolution that happens to be with.

To post a comment you must log in.
Revision history for this message
Alex Launi (alexlauni) wrote :

This looks pretty good to me. I can't test until nvidia drivers, but the code looks clean.

review: Approve
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Hi Mathieu,

Great initiative here - just nitpicking a few things before we merge this:

1) You've got merge markers in the source (eg <<<<<<< TREE MERGE SOURCE), you need to remove them or it won't build :p
2) You have strutHackTimeout in UnityScreen::Relayout - this means that on init you'll have strutHackTimeout being called twice. Remove it from UnityScreen::Relayout
3) s/g_warning/g_debug/ The screen size change is *not* a warning
4) you've got:

+ g_signal_connect_swapped (gdk_screen_get_default (), "monitors-changed", G_CALLBACK (&UnityScreen::Relayout), (void*) this);
+ g_signal_connect_swapped (gdk_screen_get_default (), "size-changed", G_CALLBACK (&UnityScreen::Relayout), (void*) this);

That is going to cause UnityScreen::Relayout to be called twice in cases where the monitors changed and the size changed. That's bad

5) This is probably going to be a point of contention between me and the other developers, but I'd actually prefer it if we hooked up this ::outputChangeNotify wrappable function in compiz. The reason why is because outputs are user-configurable in compiz in case your graphics driver is horribly broken or you need to do multihead testing. In addition, it means that we're reacting to the output change once the window manager has done everything it needs to do, meaning racy weirdness when compiz reshuffles windows about to handle the output change and we've already moved before that.

review: Needs Fixing
Revision history for this message
Mirco Müller (macslow) wrote :

I fixed all but 5.) of the issues Sam raised. I've pushed the corrected branch (and re-merged with trunk) to lp:~canonical-dx-team/unity/unity.fix-675862

This is to avoid messing with other people's personal branches.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unityshell.cpp'
2--- src/unityshell.cpp 2011-02-21 13:21:49 +0000
3+++ src/unityshell.cpp 2011-02-21 17:09:08 +0000
4@@ -38,6 +38,7 @@
5 #include <dbus/dbus-glib.h>
6 #include <glib/gi18n-lib.h>
7 #include <gtk/gtk.h>
8+#include <gdk/gdk.h>
9
10 #include <core/atoms.h>
11
12@@ -543,6 +544,64 @@
13 }
14 }
15
16+void
17+UnityScreen::Relayout ()
18+{
19+ GdkScreen *scr;
20+ GdkRectangle rect;
21+ nux::Geometry lCurGeom, pCurGeom;
22+ gint primary_monitor;
23+
24+ scr = gdk_screen_get_default ();
25+ primary_monitor = gdk_screen_get_primary_monitor (scr);
26+ gdk_screen_get_monitor_geometry (scr, primary_monitor, &rect);
27+
28+ pCurGeom = panelWindow->GetGeometry();
29+ lCurGeom = launcherWindow->GetGeometry();
30+
31+ panelWindow->EnableInputWindow(false);
32+ launcherWindow->EnableInputWindow(false);
33+
34+ panelView->SetMaximumWidth(rect.width);
35+ launcher->SetMaximumHeight(rect.height - pCurGeom.height);
36+
37+ g_warning ("setting to primary screen rect: x=%d y=%d w=%d h=%d",
38+ rect.x, rect.y, rect.width, rect.height );
39+
40+ panelWindow->SetGeometry(nux::Geometry(rect.x,
41+ rect.y,
42+ rect.width,
43+ pCurGeom.height));
44+ panelView->SetGeometry(nux::Geometry(rect.x,
45+ rect.y,
46+ rect.width,
47+ pCurGeom.height));
48+
49+ launcherWindow->SetGeometry(nux::Geometry(rect.x,
50+ rect.y + pCurGeom.height,
51+ lCurGeom.width,
52+ rect.height - pCurGeom.height));
53+ launcher->SetGeometry(nux::Geometry(rect.x,
54+ rect.y + pCurGeom.height,
55+ lCurGeom.width,
56+ rect.height - pCurGeom.height));
57+
58+ panelWindow->EnableInputWindow(true);
59+ launcherWindow->EnableInputWindow(true);
60+
61+ strutHackTimeout(this);
62+}
63+
64+gboolean
65+UnityScreen::RelayoutTimeout (gpointer data)
66+{
67+ UnityScreen *uScr = (UnityScreen*) data;
68+
69+ uScr->Relayout();
70+
71+ return FALSE;
72+}
73+
74 /* Handle changes in the number of workspaces by showing the switcher
75 * or not showing the switcher */
76 bool
77@@ -651,6 +710,10 @@
78
79 g_timeout_add (0, &UnityScreen::initPluginActions, this);
80 g_timeout_add (5000, (GSourceFunc) write_logger_data_to_disk, NULL);
81+
82+ g_signal_connect_swapped (gdk_screen_get_default (), "monitors-changed", G_CALLBACK (&UnityScreen::Relayout), (void*) this);
83+ g_signal_connect_swapped (gdk_screen_get_default (), "size-changed", G_CALLBACK (&UnityScreen::Relayout), (void*) this);
84+
85 END_FUNCTION ();
86 }
87
88@@ -749,6 +812,7 @@
89 self->launcher->SetLaunchAnimation (Launcher::LAUNCH_ANIMATION_PULSE);
90 self->launcher->SetUrgentAnimation (Launcher::URGENT_ANIMATION_WIGGLE);
91 g_timeout_add (2000, &UnityScreen::strutHackTimeout, self);
92+ g_timeout_add (2000, &UnityScreen::RelayoutTimeout, self);
93
94 END_FUNCTION ();
95 }
96
97=== modified file 'src/unityshell.h'
98--- src/unityshell.h 2011-02-21 11:34:16 +0000
99+++ src/unityshell.h 2011-02-21 17:09:08 +0000
100@@ -148,6 +148,12 @@
101 void
102 onRedrawRequested ();
103
104+ void
105+ Relayout ();
106+
107+ static gboolean
108+ RelayoutTimeout (gpointer data);
109+
110 static void
111 launcherWindowConfigureCallback(int WindowWidth, int WindowHeight, nux::Geometry& geo, void* user_data);
112