[PATCH 7/8] Store desktop dimensions in screenInfo.

Peter Hutterer peter.hutterer at who-t.net
Thu Sep 8 21:20:52 PDT 2011


For Zaphod mode screen crossing handling we need to know the size of all
screens together (i.e. the desktop size). Store that in the screenInfo to
have it readily available in events.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/dispatch.c                 |    2 ++
 dix/inpututils.c               |   18 ++++++++++++++++++
 hw/xfree86/common/xf86Cursor.c |    2 ++
 hw/xfree86/common/xf86RandR.c  |    3 +++
 hw/xfree86/modes/xf86RandR12.c |    2 ++
 include/input.h                |    1 +
 include/scrnintstr.h           |    2 ++
 7 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 192c8c3..a644c5c 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3911,6 +3911,8 @@ AddScreen(
 	return -1;
     }
 
+    update_desktop_dimensions();
+
     dixRegisterPrivateKey(&cursorScreenDevPriv[i], PRIVATE_CURSOR, 0);
 
     return i;
diff --git a/dix/inpututils.c b/dix/inpututils.c
index eeae2a7..2a2b543 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -628,6 +628,24 @@ point_on_screen(ScreenPtr pScreen, int x, int y)
 }
 
 /**
+ * Update desktop dimensions on the screenInfo struct.
+ */
+void
+update_desktop_dimensions(void)
+{
+    int i;
+    int w = 0, h = 0;
+    for (i = 0; i < screenInfo.numScreens; i++) {
+        ScreenPtr screen = screenInfo.screens[i];
+        w = max(w, screen->x + screen->width);
+        h = max(h, screen->y + screen->height);
+    }
+
+    screenInfo.width = w;
+    screenInfo.height = h;
+}
+
+/*
  * Delete the element with the key from the list, freeing all memory
  * associated with the element..
  */
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 929f047..6f5d726 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -838,6 +838,8 @@ xf86InitOrigins(void)
 		FillOutEdge(pLayout->down, pScreen->width);
 	}
     }
+
+    update_desktop_dimensions();
 }
 
 void
diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index 4663d03..d0e4784 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -313,6 +313,9 @@ xf86RandRSetConfig (ScreenPtr		pScreen,
 	return FALSE;
     }
 
+
+    update_desktop_dimensions();
+
     /*
      * Move the cursor back where it belongs; SwitchMode repositions it
      * FIXME: duplicated code, see modes/xf86RandR12.c
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index cb20d1c..d5031a2 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -736,6 +736,8 @@ xf86RandR12ScreenSetSize (ScreenPtr	pScreen,
     xf86SetViewport (pScreen, 0, 0);
 
 finish:
+    update_desktop_dimensions();
+
     if (pRoot && pScrn->vtSema)
 	(*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
 #if RANDR_12_INTERFACE
diff --git a/include/input.h b/include/input.h
index b7de5ca..2544996 100644
--- a/include/input.h
+++ b/include/input.h
@@ -609,5 +609,6 @@ extern _X_EXPORT void input_option_set_key(InputOption *opt, const char* key);
 extern _X_EXPORT void input_option_set_value(InputOption *opt, const char* value);
 
 extern _X_HIDDEN Bool point_on_screen(ScreenPtr pScreen, int x, int y);
+extern _X_HIDDEN void update_desktop_dimensions(void);
 
 #endif /* INPUT_H */
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index a9357e8..8ac48b7 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -561,6 +561,8 @@ typedef struct _ScreenInfo {
 		formats[MAXFORMATS];
     int		numScreens;
     ScreenPtr	screens[MAXSCREENS];
+    int		width;  /* total width of all screens together */
+    int		height; /* total height of all screens together */
 } ScreenInfo;
 
 extern _X_EXPORT ScreenInfo screenInfo;
-- 
1.7.6



More information about the xorg-devel mailing list