1From b5eed6c97c71e1be0defd8827422dedfa06a1edc Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Fri, 28 Apr 2023 17:09:54 +0800
4Subject: [PATCH 15/16] xvimagesink: Allow disabling decorations
5
6Tested on RK3588 EVB with:
7gst-launch-1.0 videotestsrc ! xvimagesink decorations=0
8
9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
10---
11 sys/xvimage/xvcontext.c   |  5 +++--
12 sys/xvimage/xvcontext.h   |  3 ++-
13 sys/xvimage/xvimagesink.c | 17 ++++++++++++++++-
14 sys/xvimage/xvimagesink.h |  2 ++
15 4 files changed, 23 insertions(+), 4 deletions(-)
16
17diff --git a/sys/xvimage/xvcontext.c b/sys/xvimage/xvcontext.c
18index 975c3a9..97962d9 100644
19--- a/sys/xvimage/xvcontext.c
20+++ b/sys/xvimage/xvcontext.c
21@@ -1048,7 +1048,8 @@ gst_xv_touchdevice_free (GstXvTouchDevice * device)
22 #endif
23
24 GstXWindow *
25-gst_xvcontext_create_xwindow (GstXvContext * context, gint width, gint height)
26+gst_xvcontext_create_xwindow (GstXvContext * context, gint width, gint height,
27+    gboolean decorations)
28 {
29   GstXWindow *window;
30   Atom wm_delete;
31@@ -1098,7 +1099,7 @@ gst_xvcontext_create_xwindow (GstXvContext * context, gint width, gint height)
32     hints = g_malloc0 (sizeof (MotifWmHints));
33
34     hints->flags |= MWM_HINTS_DECORATIONS;
35-    hints->decorations = 1 << 0;
36+    hints->decorations = decorations ? 1 << 0 : 0;
37
38     XChangeProperty (context->disp, window->win,
39         hints_atom, hints_atom, 32, PropModeReplace,
40diff --git a/sys/xvimage/xvcontext.h b/sys/xvimage/xvcontext.h
41index e515fcc..1fb7614 100644
42--- a/sys/xvimage/xvcontext.h
43+++ b/sys/xvimage/xvcontext.h
44@@ -287,7 +287,8 @@ struct _GstXvTouchDevice {
45 G_END_DECLS
46
47 GstXWindow *   gst_xvcontext_create_xwindow     (GstXvContext * context,
48-                                                 gint width, gint height);
49+                                                 gint width, gint height,
50+                                                 gboolean decorations);
51 GstXWindow *   gst_xvcontext_create_xwindow_from_xid (GstXvContext * context, XID xid);
52
53 void           gst_xwindow_destroy              (GstXWindow * window);
54diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c
55index fea70a5..a0fa468 100644
56--- a/sys/xvimage/xvimagesink.c
57+++ b/sys/xvimage/xvimagesink.c
58@@ -200,6 +200,7 @@ enum
59   PROP_DRAW_BORDERS,
60   PROP_WINDOW_WIDTH,
61   PROP_WINDOW_HEIGHT,
62+  PROP_DECORATIONS,
63   PROP_LAST
64 };
65
66@@ -557,7 +558,8 @@ gst_xv_image_sink_xwindow_new (GstXvImageSink * xvimagesink,
67
68   context = xvimagesink->context;
69
70-  xwindow = gst_xvcontext_create_xwindow (context, width, height);
71+  xwindow = gst_xvcontext_create_xwindow (context, width, height,
72+      xvimagesink->decorations);
73
74   /* set application name as a title */
75   gst_xv_image_sink_xwindow_set_title (xvimagesink, xwindow, NULL);
76@@ -2057,6 +2059,9 @@ gst_xv_image_sink_set_property (GObject * object, guint prop_id,
77     case PROP_DRAW_BORDERS:
78       xvimagesink->draw_borders = g_value_get_boolean (value);
79       break;
80+    case PROP_DECORATIONS:
81+      xvimagesink->decorations = g_value_get_boolean (value);
82+      break;
83     default:
84       if (!gst_video_overlay_set_property (object, PROP_LAST, prop_id, value))
85         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
86@@ -2147,6 +2152,9 @@ gst_xv_image_sink_get_property (GObject * object, guint prop_id,
87       else
88         g_value_set_uint64 (value, 0);
89       break;
90+    case PROP_DECORATIONS:
91+      g_value_set_boolean (value, xvimagesink->decorations);
92+      break;
93     default:
94       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
95       break;
96@@ -2310,6 +2318,8 @@ gst_xv_image_sink_init (GstXvImageSink * xvimagesink)
97
98   /* HACK: Use a non-zero initial ID to detect overlay mode */
99   xvimagesink->xwindow_id = -1;
100+
101+  xvimagesink->decorations = TRUE;
102 }
103
104 static void
105@@ -2446,6 +2456,11 @@ gst_xv_image_sink_class_init (GstXvImageSinkClass * klass)
106           "Height of the window", 0, G_MAXUINT64, 0,
107           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
108
109+  g_object_class_install_property (gobject_class, PROP_DECORATIONS,
110+      g_param_spec_boolean ("decorations", "decorations",
111+          "Allow window decorations", TRUE,
112+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
113+
114   gobject_class->finalize = gst_xv_image_sink_finalize;
115
116   gst_element_class_set_static_metadata (gstelement_class,
117diff --git a/sys/xvimage/xvimagesink.h b/sys/xvimage/xvimagesink.h
118index c84eeea..2e7182c 100644
119--- a/sys/xvimage/xvimagesink.h
120+++ b/sys/xvimage/xvimagesink.h
121@@ -136,6 +136,8 @@ struct _GstXvImageSink
122   GstVideoRectangle render_rect;
123
124   guintptr xwindow_id;
125+
126+  gboolean decorations;
127 };
128
129 struct _GstXvImageSinkClass
130--
1312.20.1
132
133