From fa3c2459186f3fcfd32977b811855e7592852848 Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Sun, 27 Jun 2004 18:53:04 +0000 Subject: [PATCH] sys/: Trying to fix the random behaviour of window decorations. Original commit message from CVS: 2004-06-27 Julien Moutte * sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_decorate), (gst_ximagesink_xwindow_new): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_decorate), (gst_xvimagesink_xwindow_new): Trying to fix the random behaviour of window decorations. --- ChangeLog | 8 +++++++ sys/ximage/ximagesink.c | 46 +++++++++++++++++++++++++++++++++++++++ sys/xvimage/xvimagesink.c | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) diff --git a/ChangeLog b/ChangeLog index f8d844cdb8..8411ea182f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-06-27 Julien Moutte + + * sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_decorate), + (gst_ximagesink_xwindow_new): + * sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_decorate), + (gst_xvimagesink_xwindow_new): Trying to fix the random behaviour of + window decorations. + 2004-06-27 Wim Taymans * ext/dv/gstdvdec.c: (gst_dvdec_class_init), (gst_dvdec_init), diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index 20c1316638..fe09d10261 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -33,6 +33,18 @@ GST_DEBUG_CATEGORY_STATIC (gst_debug_ximagesink); #define GST_CAT_DEFAULT gst_debug_ximagesink +typedef struct +{ + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; +} +MotifWmHints, MwmHints; + +#define MWM_HINTS_DECORATIONS (1L << 1) + static void gst_ximagesink_buffer_free (GstBuffer * buffer); /* ElementFactory information */ @@ -287,6 +299,38 @@ gst_ximagesink_ximage_put (GstXImageSink * ximagesink, GstXImage * ximage) g_mutex_unlock (ximagesink->x_lock); } +static gboolean +gst_ximagesink_xwindow_decorate (GstXImageSink * ximagesink, + GstXWindow * window) +{ + Atom hints_atom = None; + MotifWmHints *hints; + + g_return_val_if_fail (GST_IS_XIMAGESINK (ximagesink), FALSE); + g_return_val_if_fail (window != NULL, FALSE); + + hints_atom = XInternAtom (ximagesink->xcontext->disp, "_MOTIF_WM_HINTS", 1); + + hints = g_malloc0 (sizeof (MotifWmHints)); + + if (!hints) { + return FALSE; + } + + hints->flags |= MWM_HINTS_DECORATIONS; + hints->decorations = 1 << 0; + + XChangeProperty (ximagesink->xcontext->disp, window->win, + hints_atom, hints_atom, 32, PropModeReplace, + (guchar *) hints, sizeof (MotifWmHints) / sizeof (long)); + + XSync (ximagesink->xcontext->disp, FALSE); + + g_free (hints); + + return TRUE; +} + /* This function handles a GstXWindow creation */ static GstXWindow * gst_ximagesink_xwindow_new (GstXImageSink * ximagesink, gint width, gint height) @@ -315,6 +359,8 @@ gst_ximagesink_xwindow_new (GstXImageSink * ximagesink, gint width, gint height) XMapRaised (ximagesink->xcontext->disp, xwindow->win); + gst_ximagesink_xwindow_decorate (ximagesink, xwindow); + XSync (ximagesink->xcontext->disp, FALSE); g_mutex_unlock (ximagesink->x_lock); diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index fbb6999ba2..7720493a95 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -34,6 +34,18 @@ GST_DEBUG_CATEGORY_STATIC (gst_debug_xvimagesink); #define GST_CAT_DEFAULT gst_debug_xvimagesink +typedef struct +{ + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; +} +MotifWmHints, MwmHints; + +#define MWM_HINTS_DECORATIONS (1L << 1) + static void gst_xvimagesink_buffer_free (GstBuffer * buffer); /* ElementFactory information */ @@ -298,6 +310,38 @@ gst_xvimagesink_xvimage_put (GstXvImageSink * xvimagesink, GstXvImage * xvimage) g_mutex_unlock (xvimagesink->x_lock); } +static gboolean +gst_xvimagesink_xwindow_decorate (GstXvImageSink * xvimagesink, + GstXWindow * window) +{ + Atom hints_atom = None; + MotifWmHints *hints; + + g_return_val_if_fail (GST_IS_XVIMAGESINK (xvimagesink), FALSE); + g_return_val_if_fail (window != NULL, FALSE); + + hints_atom = XInternAtom (xvimagesink->xcontext->disp, "_MOTIF_WM_HINTS", 1); + + hints = g_malloc0 (sizeof (MotifWmHints)); + + if (!hints) { + return FALSE; + } + + hints->flags |= MWM_HINTS_DECORATIONS; + hints->decorations = 1 << 0; + + XChangeProperty (xvimagesink->xcontext->disp, window->win, + hints_atom, hints_atom, 32, PropModeReplace, + (guchar *) hints, sizeof (MotifWmHints) / sizeof (long)); + + XSync (xvimagesink->xcontext->disp, FALSE); + + g_free (hints); + + return TRUE; +} + /* This function handles a GstXWindow creation */ static GstXWindow * gst_xvimagesink_xwindow_new (GstXvImageSink * xvimagesink, @@ -330,6 +374,8 @@ gst_xvimagesink_xwindow_new (GstXvImageSink * xvimagesink, XMapRaised (xvimagesink->xcontext->disp, xwindow->win); + gst_xvimagesink_xwindow_decorate (xvimagesink, xwindow); + XSync (xvimagesink->xcontext->disp, FALSE); g_mutex_unlock (xvimagesink->x_lock);