[PATCH v4 1/2] dm: vdisplay: multi-local-mornitor support.


Sun, Peng
 

From: Sun Peng <peng.p.sun@...>

To support full screen mode on one of multi-local-mornitor which
connected to SOS by monitor ID that customer specify. The monitor ID is
specified in acrn-dm's parameter like this:

virtio-gpu,geometry=fullscreen:monitor_id

For window mode, the vdisplay window always be shown on monitor 0,
because the customer can drag the window to anyone monitor. Besides, the
customer can set the monitor by x_off and y_off parameter like this:

virtio-gpu,geometry=<width>x<height>+<x_off>+<y_off>

v1->v2: Add note about zoom to pscreen width & height in fullscreen.

Signed-off-by: Sun Peng <peng.p.sun@...>
---
devicemodel/hw/vdisplay_sdl.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/devicemodel/hw/vdisplay_sdl.c b/devicemodel/hw/vdisplay_sdl.c
index 65fd78d93..cea26d3ee 100644
--- a/devicemodel/hw/vdisplay_sdl.c
+++ b/devicemodel/hw/vdisplay_sdl.c
@@ -52,6 +52,8 @@ struct egl_display_ops {
};

static struct display {
+ int pscreen_id;
+ SDL_Rect pscreen_rect;
struct display_info info;
struct state s;
SDL_Texture *dpy_texture;
@@ -62,7 +64,6 @@ static struct display {
int width, height; // Width/height of dpy_win
int org_x, org_y;
int guest_width, guest_height;
- int screen;
struct surface surf;
struct cursor cur;
SDL_Texture *cursor_tex;
@@ -933,11 +934,14 @@ vdpy_sdl_display_thread(void *data)
SDL_WINDOW_ALWAYS_ON_TOP |
SDL_WINDOW_SHOWN;
if (vdpy.s.is_fullscreen) {
- win_flags |= SDL_WINDOW_FULLSCREEN;
+ win_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ vdpy.org_x = vdpy.pscreen_rect.x;
+ vdpy.org_y = vdpy.pscreen_rect.y;
}
vdpy.dpy_win = NULL;
vdpy.dpy_renderer = NULL;
vdpy.dpy_img = NULL;
+ // Zoom to width and height of pscreen is fullscreen enabled
vdpy.dpy_win = SDL_CreateWindow("ACRN_DM",
vdpy.org_x, vdpy.org_y,
vdpy.width, vdpy.height,
@@ -946,6 +950,9 @@ vdpy_sdl_display_thread(void *data)
pr_err("Failed to Create SDL_Window\n");
goto sdl_fail;
}
+ pr_info("SDL display bind to screen %d: [%d,%d,%d,%d].\n", vdpy.pscreen_id,
+ vdpy.org_x, vdpy.org_y, vdpy.width, vdpy.height);
+
vdpy.dpy_renderer = SDL_CreateRenderer(vdpy.dpy_win, -1, 0);
if (vdpy.dpy_renderer == NULL) {
pr_err("Failed to Create GL_Renderer \n");
@@ -1134,7 +1141,6 @@ int
gfx_ui_init()
{
SDL_SysWMinfo info;
- SDL_Rect disp_rect;

setenv("SDL_VIDEO_X11_FORCE_EGL", "1", 1);
setenv("SDL_OPENGL_ES_DRIVER", "1", 1);
@@ -1146,10 +1152,10 @@ gfx_ui_init()
return -1;
}

- SDL_GetDisplayBounds(0, &disp_rect);
+ SDL_GetDisplayBounds(vdpy.pscreen_id, &vdpy.pscreen_rect);

- if (disp_rect.w < VDPY_MIN_WIDTH ||
- disp_rect.h < VDPY_MIN_HEIGHT) {
+ if (vdpy.pscreen_rect.w < VDPY_MIN_WIDTH ||
+ vdpy.pscreen_rect.h < VDPY_MIN_HEIGHT) {
pr_err("Too small resolutions. Please check the "
" graphics system\n");
SDL_Quit();
@@ -1198,9 +1204,9 @@ int vdpy_parse_cmd_option(const char *opts)

str = strcasestr(opts, "geometry=");
if (opts && strcasestr(opts, "geometry=fullscreen")) {
- snum = sscanf(str, "geometry=fullscreen:%d", &vdpy.screen);
+ snum = sscanf(str, "geometry=fullscreen:%d", &vdpy.pscreen_id);
if (snum != 1) {
- vdpy.screen = 0;
+ vdpy.pscreen_id = 0;
}
vdpy.width = VDPY_MAX_WIDTH;
vdpy.height = VDPY_MAX_HEIGHT;
--
2.25.1


Zhao, Yakui
 

On 2022/8/10 18:01, peng.p.sun@... wrote:
From: Sun Peng <peng.p.sun@...>
To support full screen mode on one of multi-local-mornitor which
connected to SOS by monitor ID that customer specify. The monitor ID is
specified in acrn-dm's parameter like this:
virtio-gpu,geometry=fullscreen:monitor_id
For window mode, the vdisplay window always be shown on monitor 0,
because the customer can drag the window to anyone monitor. Besides, the
customer can set the monitor by x_off and y_off parameter like this:
virtio-gpu,geometry=<width>x<height>+<x_off>+<y_off>
v1->v2: Add note about zoom to pscreen width & height in fullscreen.
Signed-off-by: Sun Peng <peng.p.sun@...>
---
devicemodel/hw/vdisplay_sdl.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/devicemodel/hw/vdisplay_sdl.c b/devicemodel/hw/vdisplay_sdl.c
index 65fd78d93..cea26d3ee 100644
--- a/devicemodel/hw/vdisplay_sdl.c
+++ b/devicemodel/hw/vdisplay_sdl.c
@@ -52,6 +52,8 @@ struct egl_display_ops {
};
static struct display {
+ int pscreen_id;
+ SDL_Rect pscreen_rect;
struct display_info info;
struct state s;
SDL_Texture *dpy_texture;
@@ -62,7 +64,6 @@ static struct display {
int width, height; // Width/height of dpy_win
int org_x, org_y;
int guest_width, guest_height;
- int screen;
struct surface surf;
struct cursor cur;
SDL_Texture *cursor_tex;
@@ -933,11 +934,14 @@ vdpy_sdl_display_thread(void *data)
SDL_WINDOW_ALWAYS_ON_TOP |
SDL_WINDOW_SHOWN;
if (vdpy.s.is_fullscreen) {
- win_flags |= SDL_WINDOW_FULLSCREEN;
+ win_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ vdpy.org_x = vdpy.pscreen_rect.x;
+ vdpy.org_y = vdpy.pscreen_rect.y;
}
vdpy.dpy_win = NULL;
vdpy.dpy_renderer = NULL;
vdpy.dpy_img = NULL;
+ // Zoom to width and height of pscreen is fullscreen enabled
vdpy.dpy_win = SDL_CreateWindow("ACRN_DM",
vdpy.org_x, vdpy.org_y,
vdpy.width, vdpy.height,
In previous version it seems that the vdpy.width/height is checked against with the pscreen_rect.w/h and the VDPY_MAX_WIDTH/HEIGHT.
IMO this can be kept.
But if the pscreen_rect.w/h is not 1920x1080, maybe the cursor coord conversion will have some problems.
Please double check it.


@@ -946,6 +950,9 @@ vdpy_sdl_display_thread(void *data)
pr_err("Failed to Create SDL_Window\n");
goto sdl_fail;
}
+ pr_info("SDL display bind to screen %d: [%d,%d,%d,%d].\n", vdpy.pscreen_id,
+ vdpy.org_x, vdpy.org_y, vdpy.width, vdpy.height);
+
vdpy.dpy_renderer = SDL_CreateRenderer(vdpy.dpy_win, -1, 0);
if (vdpy.dpy_renderer == NULL) {
pr_err("Failed to Create GL_Renderer \n");
@@ -1134,7 +1141,6 @@ int
gfx_ui_init()
{
SDL_SysWMinfo info;
- SDL_Rect disp_rect;
setenv("SDL_VIDEO_X11_FORCE_EGL", "1", 1);
setenv("SDL_OPENGL_ES_DRIVER", "1", 1);
@@ -1146,10 +1152,10 @@ gfx_ui_init()
return -1;
}
- SDL_GetDisplayBounds(0, &disp_rect);
+ SDL_GetDisplayBounds(vdpy.pscreen_id, &vdpy.pscreen_rect);
- if (disp_rect.w < VDPY_MIN_WIDTH ||
- disp_rect.h < VDPY_MIN_HEIGHT) {
+ if (vdpy.pscreen_rect.w < VDPY_MIN_WIDTH ||
+ vdpy.pscreen_rect.h < VDPY_MIN_HEIGHT) {
pr_err("Too small resolutions. Please check the "
" graphics system\n");
SDL_Quit();
@@ -1198,9 +1204,9 @@ int vdpy_parse_cmd_option(const char *opts)
str = strcasestr(opts, "geometry=");
if (opts && strcasestr(opts, "geometry=fullscreen")) {
- snum = sscanf(str, "geometry=fullscreen:%d", &vdpy.screen);
+ snum = sscanf(str, "geometry=fullscreen:%d", &vdpy.pscreen_id);
if (snum != 1) {
- vdpy.screen = 0;
+ vdpy.pscreen_id = 0;
}
vdpy.width = VDPY_MAX_WIDTH;
vdpy.height = VDPY_MAX_HEIGHT;