summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Lee <llyzs@163.com>2012-07-30 14:32:09 -0400
committerKeith Packard <keithp@keithp.com>2012-08-06 15:03:46 -0700
commit8843aed82e7d69422e7763a35832a2be8f26723f (patch)
tree6ac1e6fe395a1015ed58ae13a58de224c18bda02
parentb46bbafae6d0a8b3f2f7853d5c1475fc223b1ed6 (diff)
ephyr: Resize screen automatically when parent window is resized
Bugzilla: https://bugs.freedesktop.org/25804 Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Vic Lee <llyzs@163.com> Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--hw/kdrive/ephyr/ephyr.c47
-rw-r--r--hw/kdrive/ephyr/hostx.c33
-rw-r--r--hw/kdrive/ephyr/hostx.h10
3 files changed, 82 insertions, 8 deletions
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index a5225dc7d..4247d7b03 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -558,6 +558,8 @@ ephyrRandRSetConfig(ScreenPtr pScreen,
if (wasEnabled)
KdEnableScreen(pScreen);
+ RRScreenSizeNotify(pScreen);
+
return TRUE;
bail4:
@@ -590,6 +592,43 @@ ephyrRandRInit(ScreenPtr pScreen)
pScrPriv->rrSetConfig = ephyrRandRSetConfig;
return TRUE;
}
+
+static Bool
+ephyrResizeScreen (ScreenPtr pScreen,
+ int newwidth,
+ int newheight)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ RRScreenSize size = {0};
+ Bool ret;
+ int t;
+
+ if (screen->randr & (RR_Rotate_90|RR_Rotate_270)) {
+ t = newwidth;
+ newwidth = newheight;
+ newheight = t;
+ }
+
+ if (newwidth == screen->width && newheight == screen->height) {
+ return FALSE;
+ }
+
+ size.width = newwidth;
+ size.height = newheight;
+
+ ret = ephyrRandRSetConfig (pScreen, screen->randr, 0, &size);
+ if (ret) {
+ RROutputPtr output;
+
+ output = RRFirstOutput(pScreen);
+ if (!output)
+ return FALSE;
+ RROutputSetModes(output, NULL, 0, 0);
+ }
+
+ return ret;
+}
#endif
Bool
@@ -930,6 +969,14 @@ ephyrPoll(void)
break;
#endif /* XF86DRI */
+#ifdef RANDR
+ case EPHYR_EV_CONFIGURE:
+ ephyrResizeScreen(screenInfo.screens[ev.data.configure.screen],
+ ev.data.configure.width,
+ ev.data.configure.height);
+ break;
+#endif /* RANDR */
+
default:
break;
}
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index e13910b72..02729d6f6 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -348,7 +348,8 @@ hostx_init(void)
| PointerMotionMask
| KeyPressMask
| KeyReleaseMask
- | ExposureMask;
+ | ExposureMask
+ | StructureNotifyMask;
EPHYR_DBG("mark");
@@ -696,12 +697,14 @@ hostx_screen_init(EphyrScreenInfo screen,
XResizeWindow(HostX.dpy, host_screen->win, width, height);
/* Ask the WM to keep our size static */
- size_hints = XAllocSizeHints();
- size_hints->max_width = size_hints->min_width = width;
- size_hints->max_height = size_hints->min_height = height;
- size_hints->flags = PMinSize | PMaxSize;
- XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
- XFree(size_hints);
+ if (host_screen->win_pre_existing == None) {
+ size_hints = XAllocSizeHints();
+ size_hints->max_width = size_hints->min_width = width;
+ size_hints->max_height = size_hints->min_height = height;
+ size_hints->flags = PMinSize | PMaxSize;
+ XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
+ XFree(size_hints);
+ }
XMapWindow(HostX.dpy, host_screen->win);
@@ -1004,6 +1007,22 @@ hostx_get_event(EphyrHostXEvent * ev)
ev->data.key_up.scancode = xev.xkey.keycode;
return 1;
+ case ConfigureNotify:
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window(xev.xconfigure.window);
+
+ if (host_screen && host_screen->win_pre_existing != None) {
+ ev->type = EPHYR_EV_CONFIGURE;
+ ev->data.configure.width = xev.xconfigure.width;
+ ev->data.configure.height = xev.xconfigure.height;
+ ev->data.configure.window = xev.xconfigure.window;
+ ev->data.configure.screen = host_screen->mynum;
+ return 1;
+ }
+
+ return 0;
+ }
default:
break;
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index d6217119a..31c4053aa 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -47,7 +47,8 @@ typedef enum EphyrHostXEventType {
EPHYR_EV_MOUSE_RELEASE,
EPHYR_EV_KEY_PRESS,
EPHYR_EV_KEY_RELEASE,
- EPHYR_EV_EXPOSE
+ EPHYR_EV_EXPOSE,
+ EPHYR_EV_CONFIGURE,
} EphyrHostXEventType;
/* I can't believe it's not a KeySymsRec. */
@@ -89,6 +90,13 @@ struct EphyrHostXEvent {
int window;
} expose;
+ struct configure {
+ int width;
+ int height;
+ int screen;
+ int window;
+ } configure;
+
} data;
int key_state;