commit 9ccfa62fb43ff35094141c3c4e5a06c86abadc24
parent 50ff0cb04aed72db5facf19a264608b13da26937
Author: Michael Forney <mforney@mforney.org>
Date: Sun, 2 Feb 2014 19:38:41 -0800
Make sure framebuffer and cursor planes are positioned correctly
Diffstat:
5 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/libswc/cursor_plane.c b/libswc/cursor_plane.c
@@ -26,6 +26,7 @@
#include "drm.h"
#include "internal.h"
#include "launch.h"
+#include "screen.h"
#include "util.h"
#include <errno.h>
@@ -75,7 +76,9 @@ static bool move(struct swc_view * view, int32_t x, int32_t y)
{
struct swc_cursor_plane * plane = CONTAINER_OF(view, typeof(*plane), view);
- if (drmModeMoveCursor(swc.drm->fd, plane->crtc, x, y) != 0)
+ if (drmModeMoveCursor(swc.drm->fd, plane->crtc,
+ x - view->screen->base.geometry.x,
+ y - view->screen->base.geometry.y) != 0)
{
ERROR("Could not move cursor: %s\n", strerror(errno));
return false;
diff --git a/libswc/framebuffer_plane.c b/libswc/framebuffer_plane.c
@@ -142,9 +142,15 @@ static bool attach(struct swc_view * view, struct swc_buffer * buffer)
return true;
}
+static bool move(struct swc_view * view, int32_t x, int32_t y)
+{
+ return true;
+}
+
const static struct swc_view_impl view_impl = {
.update = &update,
- .attach = &attach
+ .attach = &attach,
+ .move = &move
};
static void handle_page_flip(struct swc_drm_handler * handler, uint32_t time)
@@ -192,6 +198,8 @@ bool swc_framebuffer_plane_initialize(struct swc_framebuffer_plane * plane,
plane->drm_handler.page_flip = &handle_page_flip;
plane->need_modeset = true;
swc_view_initialize(&plane->view, &view_impl);
+ plane->view.geometry.width = mode->width;
+ plane->view.geometry.height = mode->height;
plane->mode = *mode;
return true;
diff --git a/libswc/pointer.c b/libswc/pointer.c
@@ -135,8 +135,7 @@ static void handle_view_event(struct wl_listener * listener, void * data)
wl_list_for_each(screen, &swc.screens, link)
{
swc_view_move(&screen->planes.cursor.view,
- view->geometry.x - screen->base.geometry.x,
- view->geometry.y - screen->base.geometry.y);
+ view->geometry.x, view->geometry.y);
if (view->screens & swc_screen_mask(screen))
{
diff --git a/libswc/screen.c b/libswc/screen.c
@@ -68,11 +68,6 @@ struct swc_screen_internal * swc_screen_new(uint32_t crtc,
if (!(screen = malloc(sizeof *screen)))
goto error0;
- screen->base.geometry.x = x;
- screen->base.geometry.y = 0;
- screen->base.geometry.width = output->preferred_mode->width;
- screen->base.geometry.height = output->preferred_mode->height;
- screen->base.usable_geometry = screen->base.geometry;
wl_signal_init(&screen->base.event_signal);
wl_list_init(&screen->outputs);
wl_list_insert(&INTERNAL(screen)->outputs, &output->link);
@@ -92,6 +87,13 @@ struct swc_screen_internal * swc_screen_new(uint32_t crtc,
goto error2;
}
+ screen->planes.framebuffer.view.screen = screen;
+ screen->planes.cursor.view.screen = screen;
+
+ swc_view_move(&screen->planes.framebuffer.view, x, 0);
+ screen->base.geometry = screen->planes.framebuffer.view.geometry;
+ screen->base.usable_geometry = screen->base.geometry;
+
swc.manager->new_screen(&screen->base);
return screen;
diff --git a/libswc/view.h b/libswc/view.h
@@ -86,6 +86,13 @@ struct swc_view
uint32_t screens;
struct swc_rectangle geometry;
+
+ /**
+ * The screen that the view belongs to (for example if framebuffer or
+ * cursor plane), or NULL.
+ */
+ struct screen * screen;
+
struct swc_buffer * buffer;
struct wl_listener buffer_destroy_listener;
};