[PATCH xwayland 2/3] xwayland: Refactor surface creation into a separate function

2019-01-15 Thread Carlos Garnacho
This is just called from xwl_window_realize() ATM, but will be useful in
future commits.

Signed-off-by: Carlos Garnacho 
---
 hw/xwayland/xwayland.c | 65 ++
 1 file changed, 40 insertions(+), 25 deletions(-)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 7f70b950d..279358e07 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -522,7 +522,7 @@ send_surface_id_event(struct xwl_window *xwl_window)
 }
 
 static Bool
-xwl_realize_window(WindowPtr window)
+create_surface_for_window(WindowPtr window)
 {
 ScreenPtr screen = window->drawable.pScreen;
 struct xwl_screen *xwl_screen;
@@ -530,29 +530,10 @@ xwl_realize_window(WindowPtr window)
 struct wl_region *region;
 Bool ret;
 
-xwl_screen = xwl_screen_get(screen);
-
-screen->RealizeWindow = xwl_screen->RealizeWindow;
-ret = (*screen->RealizeWindow) (window);
-xwl_screen->RealizeWindow = screen->RealizeWindow;
-screen->RealizeWindow = xwl_realize_window;
-
-if (xwl_screen->rootless && !window->parent) {
-BoxRec box = { 0, 0, xwl_screen->width, xwl_screen->height };
-
-RegionReset(>winSize, );
-RegionNull(>clipList);
-RegionNull(>borderClip);
-}
+if (xwl_window_get(window))
+return TRUE;
 
-if (xwl_screen->rootless) {
-if (window->redirectDraw != RedirectDrawManual)
-return ret;
-}
-else {
-if (window->parent)
-return ret;
-}
+xwl_screen = xwl_screen_get(screen);
 
 xwl_window = calloc(1, sizeof *xwl_window);
 if (xwl_window == NULL)
@@ -599,8 +580,6 @@ xwl_realize_window(WindowPtr window)
 
 compRedirectWindow(serverClient, window, CompositeRedirectManual);
 
-register_damage(window);
-
 dixSetPrivate(>devPrivates, _window_private_key, xwl_window);
 xorg_list_init(_window->link_damage);
 
@@ -617,6 +596,42 @@ err:
 return FALSE;
 }
 
+static Bool
+xwl_realize_window(WindowPtr window)
+{
+ScreenPtr screen = window->drawable.pScreen;
+struct xwl_screen *xwl_screen;
+Bool ret;
+
+xwl_screen = xwl_screen_get(screen);
+
+screen->RealizeWindow = xwl_screen->RealizeWindow;
+ret = (*screen->RealizeWindow) (window);
+xwl_screen->RealizeWindow = screen->RealizeWindow;
+screen->RealizeWindow = xwl_realize_window;
+
+if (xwl_screen->rootless && !window->parent) {
+BoxRec box = { 0, 0, xwl_screen->width, xwl_screen->height };
+
+RegionReset(>winSize, );
+RegionNull(>clipList);
+RegionNull(>borderClip);
+}
+
+register_damage(window);
+
+if (xwl_screen->rootless) {
+if (window->redirectDraw != RedirectDrawManual)
+return ret;
+}
+else {
+if (window->parent)
+return ret;
+}
+
+return create_surface_for_window(window);
+}
+
 static Bool
 xwl_unrealize_window(WindowPtr window)
 {
-- 
2.19.2

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xwayland 1/3] xwayland: Separate DamagePtr into separate window data

2019-01-15 Thread Carlos Garnacho
This will be dissociated in future commits to handle the cases
where windows are being realized before there is a compositor
handling redirection.

In that case, we still want the DamagePtr to be registered upfront
on RealizeWindowProc before a corresponding xwl_window might be
created. Most notably, it cannot be lazily created on
SetWindowPixmapProc as damage accounting gets broken. The downside
of this is that we may create no-op DamagePtrs for windows that are
not redirected eventually.

Signed-off-by: Carlos Garnacho 
---
 hw/xwayland/xwayland.c | 69 --
 hw/xwayland/xwayland.h |  1 -
 2 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 289683b6e..7f70b950d 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -132,6 +132,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
 static DevPrivateKeyRec xwl_window_private_key;
 static DevPrivateKeyRec xwl_screen_private_key;
 static DevPrivateKeyRec xwl_pixmap_private_key;
+static DevPrivateKeyRec xwl_damage_private_key;
 
 static struct xwl_window *
 xwl_window_get(WindowPtr window)
@@ -374,8 +375,14 @@ xwl_cursor_confined_to(DeviceIntPtr device,
 static void
 damage_report(DamagePtr pDamage, RegionPtr pRegion, void *data)
 {
-struct xwl_window *xwl_window = data;
-struct xwl_screen *xwl_screen = xwl_window->xwl_screen;
+WindowPtr window = data;
+struct xwl_window *xwl_window = xwl_window_get(window);
+struct xwl_screen *xwl_screen;
+
+if (!xwl_window)
+return;
+
+xwl_screen = xwl_window->xwl_screen;
 
 #ifdef GLAMOR_HAS_GBM
 if (xwl_window->present_flipped) {
@@ -397,6 +404,44 @@ damage_destroy(DamagePtr pDamage, void *data)
 {
 }
 
+static Bool
+register_damage(WindowPtr window)
+{
+DamagePtr damage;
+
+damage = DamageCreate(damage_report, damage_destroy, DamageReportNonEmpty,
+  FALSE, window->drawable.pScreen, window);
+if (damage == NULL) {
+ErrorF("Failed creating damage\n");
+return FALSE;
+}
+
+DamageRegister(>drawable, damage);
+DamageSetReportAfterOp(damage, TRUE);
+
+dixSetPrivate(>devPrivates, _damage_private_key, damage);
+
+return TRUE;
+}
+
+static void
+unregister_damage(WindowPtr window)
+{
+DamagePtr damage;
+
+damage = dixLookupPrivate(>devPrivates, _damage_private_key);
+DamageUnregister(damage);
+DamageDestroy(damage);
+
+dixSetPrivate(>devPrivates, _damage_private_key, NULL);
+}
+
+static DamagePtr
+window_get_damage(WindowPtr window)
+{
+return dixLookupPrivate(>devPrivates, _damage_private_key);
+}
+
 static void
 shell_surface_ping(void *data,
struct wl_shell_surface *shell_surface, uint32_t serial)
@@ -552,18 +597,9 @@ xwl_realize_window(WindowPtr window)
 
 wl_surface_set_user_data(xwl_window->surface, xwl_window);
 
-xwl_window->damage =
-DamageCreate(damage_report, damage_destroy, DamageReportNonEmpty,
- FALSE, screen, xwl_window);
-if (xwl_window->damage == NULL) {
-ErrorF("Failed creating damage\n");
-goto err_surf;
-}
-
 compRedirectWindow(serverClient, window, CompositeRedirectManual);
 
-DamageRegister(>drawable, xwl_window->damage);
-DamageSetReportAfterOp(xwl_window->damage, TRUE);
+register_damage(window);
 
 dixSetPrivate(>devPrivates, _window_private_key, xwl_window);
 xorg_list_init(_window->link_damage);
@@ -627,8 +663,7 @@ xwl_unrealize_window(WindowPtr window)
 
 wl_surface_destroy(xwl_window->surface);
 xorg_list_del(_window->link_damage);
-DamageUnregister(xwl_window->damage);
-DamageDestroy(xwl_window->damage);
+unregister_damage(window);
 if (xwl_window->frame_callback)
 wl_callback_destroy(xwl_window->frame_callback);
 
@@ -690,7 +725,7 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
 
 assert(!xwl_window->frame_callback);
 
-region = DamageRegion(xwl_window->damage);
+region = DamageRegion(window_get_damage(xwl_window->window));
 pixmap = (*xwl_screen->screen->GetWindowPixmap) (xwl_window->window);
 
 #ifdef XWL_HAS_GLAMOR
@@ -727,7 +762,7 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
 wl_callback_add_listener(xwl_window->frame_callback, _listener, 
xwl_window);
 
 wl_surface_commit(xwl_window->surface);
-DamageEmpty(xwl_window->damage);
+DamageEmpty(window_get_damage(xwl_window->window));
 
 xorg_list_del(_window->link_damage);
 }
@@ -960,6 +995,8 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
 return FALSE;
 if (!dixRegisterPrivateKey(_pixmap_private_key, PRIVATE_PIXMAP, 0))
 return FALSE;
+if (!dixRegisterPrivateKey(_damage_private_key, PRIVATE_WINDOW, 0))
+return FALSE;
 
 dixSetPrivate(>devPrivates, _screen_private_key, xwl_screen);
 xwl_screen->screen = pScreen;
diff --git a/hw/xwayland/xwayland.h 

[PATCH xwayland 3/3] xwayland: Handle the case of windows being realized before redirection

2019-01-15 Thread Carlos Garnacho
If Xwayland gets to realize a window meant for composition before the
compositor redirected windows (i.e. redirect mode is not RedirectDrawManual
yet), the window would stay "invisible" as we wouldn't create a
wl_surface/wl_shell_surface for it at any later point.

This scenario may happen if the wayland compositor raises Xwayland on
demand for a X11 client being started. In this case the first data on
the socket is the client's, the compositor can hardly beat that in
order to redirect subwindows before the client realizes a Window.

In order to handle this case, allow the late creation of a matching
(shell) surface for the WindowPtr on SetWindowPixmapProc, so it is ensured
to be created after the compositor set up redirection.

Signed-off-by: Carlos Garnacho 
---
 hw/xwayland/xwayland.c | 37 +
 hw/xwayland/xwayland.h |  1 +
 2 files changed, 38 insertions(+)

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 279358e07..6f7d64ca8 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -688,6 +688,40 @@ xwl_unrealize_window(WindowPtr window)
 return ret;
 }
 
+static void
+xwl_set_window_pixmap(WindowPtr window,
+  PixmapPtr pixmap)
+{
+ScreenPtr screen = window->drawable.pScreen;
+struct xwl_screen *xwl_screen;
+struct xwl_window *xwl_window;
+
+xwl_screen = xwl_screen_get(screen);
+
+screen->SetWindowPixmap = xwl_screen->SetWindowPixmap;
+(*screen->SetWindowPixmap) (window, pixmap);
+xwl_screen->SetWindowPixmap = screen->SetWindowPixmap;
+screen->SetWindowPixmap = xwl_set_window_pixmap;
+
+if (!RegionNotEmpty(>winSize))
+return;
+
+xwl_window = xwl_window_get(window);
+if (xwl_window)
+return;
+
+if (xwl_screen->rootless) {
+if (window->redirectDraw != RedirectDrawManual)
+return;
+}
+else {
+if (window->parent)
+return;
+}
+
+create_surface_for_window(window);
+}
+
 static void
 frame_callback(void *data,
struct wl_callback *callback,
@@ -1147,6 +1181,9 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
 xwl_screen->CloseScreen = pScreen->CloseScreen;
 pScreen->CloseScreen = xwl_close_screen;
 
+xwl_screen->SetWindowPixmap = pScreen->SetWindowPixmap;
+pScreen->SetWindowPixmap = xwl_set_window_pixmap;
+
 pScreen->CursorWarpedTo = xwl_cursor_warped_to;
 pScreen->CursorConfinedTo = xwl_cursor_confined_to;
 
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
index 1559b114d..65f12d478 100644
--- a/hw/xwayland/xwayland.h
+++ b/hw/xwayland/xwayland.h
@@ -130,6 +130,7 @@ struct xwl_screen {
 UnrealizeWindowProcPtr UnrealizeWindow;
 DestroyWindowProcPtr DestroyWindow;
 XYToWindowProcPtr XYToWindow;
+SetWindowPixmapProcPtr SetWindowPixmap;
 
 struct xorg_list output_list;
 struct xorg_list seat_list;
-- 
2.19.2

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Bug in xrandr gammas

2019-01-15 Thread crawlman
Hi!

So, I have a rare neurological condition, and it is very important to me that I 
can have control over color outputs from my monitor screen. After searching for 
months, I have come to xrandr as the only available solution for linux to 
change the behaviour of rgb channels. The problem is, it does not allow to 
change directly the intensity of different rgb channels. It only allows to 
change "gamma", whatever that is. When I set blue and green gamma all the way 
down, grey colors turn into red. This is what I wanted. But the "gamma" option 
does not make any difference for white. White is completely unaffected by 
xrandr. Every other color get's filtered, except by white.

I am not sure whether this is a bug in xrandr gamma handling, or if the 
technical definition of "gamma", which I cannot understand, implies that white 
should in fact be unaffected. But it would be very important, then, to have an 
option to directly control the intensities of output of each rgb channel. So, 
if I wanted to shut down green and blue output entirely, I could.

Hope someone can help with this problem!

Thanks for your patience.

Sent with [ProtonMail](https://protonmail.com) Secure Email.___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel