[marco] 03/04: debian/patches: Add 0003_xpresent.patch. Adds Present extension support.

Vangelis Mouhtsis gnugr-guest at moszumanska.debian.org
Tue Nov 14 08:18:33 UTC 2017


This is an automated email from the git hooks/post-receive script.

gnugr-guest pushed a commit to branch parrot/3.7
in repository marco.

commit d6156f0a1c25aa9ef1ba3cbbcfde59e7c6e3c280
Author: Martin Wimpress <martin.wimpress at ubuntu.com>
Date:   Mon Nov 13 22:25:24 2017 +0000

    debian/patches: Add 0003_xpresent.patch. Adds Present extension support.
---
 debian/patches/0003_xpresent.patch | 521 +++++++++++++++++++++++++++++++++++++
 debian/patches/series              |   1 +
 2 files changed, 522 insertions(+)

diff --git a/debian/patches/0003_xpresent.patch b/debian/patches/0003_xpresent.patch
new file mode 100644
index 0000000..c85f682
--- /dev/null
+++ b/debian/patches/0003_xpresent.patch
@@ -0,0 +1,521 @@
+Author: Victor Kareh <vkareh at vkareh.net>
+Description: XPresent extension support
+
+diff --git a/configure.ac b/configure.ac
+index f2ac9ba..f2dd2ea 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -415,7 +415,19 @@ if test "x$found_xsync" = "xyes"; then
+    AC_DEFINE(HAVE_XSYNC, , [Have the Xsync extension library])
+ fi
+ 
+-MARCO_LIBS="$MARCO_LIBS $XSYNC_LIBS $RANDR_LIBS $SHAPE_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lm"
++XPRESENT_LIBS=
++found_xpresent=no
++AC_CHECK_LIB(Xpresent, XPresentPixmap,
++               [AC_CHECK_HEADER(X11/extensions/Xpresent.h,
++                                XPRESENT_LIBS=-lXpresent found_xpresent=yes,,
++        [#include <X11/Xlib.h>])],
++               , $ALL_X_LIBS)
++
++if test "x$found_xpresent" = "xyes"; then
++   AC_DEFINE(HAVE_PRESENT, , [Have the Xpresent extension library])
++fi
++
++MARCO_LIBS="$MARCO_LIBS $XSYNC_LIBS $RANDR_LIBS $SHAPE_LIBS $XPRESENT_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lm"
+ MARCO_MESSAGE_LIBS="$MARCO_MESSAGE_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
+ MARCO_WINDOW_DEMO_LIBS="$MARCO_WINDOW_DEMO_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
+ MARCO_PROPS_LIBS="$MARCO_PROPS_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
+@@ -523,6 +535,7 @@ marco-$VERSION:
+ 	Shape extension:          ${found_shape}
+ 	Resize-and-rotate:        ${found_randr}
+ 	Xsync:                    ${found_xsync}
++	Xpresent:                 ${found_xpresent}
+ 	Render:                   ${have_xrender}
+ 	Xcursor:                  ${have_xcursor}
+ "
+diff --git a/src/compositor/compositor-xrender.c b/src/compositor/compositor-xrender.c
+index 04e89f6..75171cb 100644
+--- a/src/compositor/compositor-xrender.c
++++ b/src/compositor/compositor-xrender.c
+@@ -39,6 +39,7 @@
+ #include <cairo/cairo-xlib.h>
+ 
+ #include "display.h"
++#include "../core/display-private.h"
+ #include "screen.h"
+ #include "frame.h"
+ #include "errors.h"
+@@ -53,6 +54,10 @@
+ #include <X11/extensions/Xfixes.h>
+ #include <X11/extensions/Xrender.h>
+ 
++#ifdef HAVE_PRESENT
++#include <X11/extensions/Xpresent.h>
++#endif
++
+ #define USE_IDLE_REPAINT 1
+ 
+ typedef enum _MetaCompWindowType
+@@ -103,6 +108,11 @@ typedef struct _MetaCompositorXRender
+   guint enabled : 1;
+   guint show_redraw : 1;
+   guint debug : 1;
++
++#ifdef HAVE_PRESENT
++  guint has_present : 1;
++  int present_major;
++#endif /* HAVE_PRESENT */
+ } MetaCompositorXRender;
+ 
+ typedef struct _conv
+@@ -118,6 +128,7 @@ typedef struct _shadow
+   guchar *shadow_top;
+ } shadow;
+ 
++#define NUM_BUFFER      2
+ typedef struct _MetaCompScreen
+ {
+   MetaScreen *screen;
+@@ -132,11 +143,20 @@ typedef struct _MetaCompScreen
+   shadow *shadows[LAST_SHADOW_TYPE];
+ 
+   Picture root_picture;
+-  Picture root_buffer;
++  Picture root_buffers[NUM_BUFFER];
++  Pixmap  root_pixmaps[NUM_BUFFER];
++  int root_current;
+   Picture black_picture;
+   Picture trans_black_picture;
+   Picture root_tile;
+   XserverRegion all_damage;
++#ifdef HAVE_PRESENT
++  XserverRegion prev_damage;
++
++  XID present_eid;
++  gboolean use_present;
++  gboolean present_pending;
++#endif /* HAVE_PRESENT */
+ 
+   guint overlays;
+   gboolean compositor_active;
+@@ -675,6 +695,26 @@ find_window_for_child_window_in_display (MetaDisplay *display,
+   return NULL;
+ }
+ 
++#ifdef HAVE_PRESENT
++static MetaScreen *
++find_screen_from_output(MetaDisplay *display, Window output)
++{
++  int i;
++  Display *xdisplay = meta_display_get_xdisplay(display);
++
++  for (i = 0; i < ScreenCount(xdisplay); i++)
++    {
++      MetaScreen *screen = meta_display_screen_for_x_screen(display,
++                                                            ScreenOfDisplay(xdisplay, i));
++      MetaCompScreen *info = meta_screen_get_compositor_data(screen);
++
++      if (info->output == output)
++        return screen;
++    }
++  return NULL;
++}
++#endif /* HAVE_PRESENT */
++
+ static Picture
+ solid_picture (MetaDisplay *display,
+                MetaScreen  *screen,
+@@ -796,38 +836,56 @@ root_tile (MetaScreen *screen)
+   return picture;
+ }
+ 
++static Pixmap
++create_root_pixmap (MetaScreen *screen)
++{
++  MetaDisplay *display = meta_screen_get_display (screen);
++  Display *xdisplay = meta_display_get_xdisplay (display);
++  MetaCompScreen *info = meta_screen_get_compositor_data (screen);
++  Window xroot = meta_screen_get_xroot (screen);
++  Pixmap pixmap;
++  int depth, screen_width, screen_height, screen_number;
++
++  if (info == NULL)
++    {
++      return None;
++    }
++
++  meta_screen_get_size (screen, &screen_width, &screen_height);
++  screen_number = meta_screen_get_screen_number (screen);
++
++  depth = DefaultDepth (xdisplay, screen_number);
++  pixmap = XCreatePixmap (xdisplay, xroot,
++                          screen_width, screen_height,
++                          depth);
++
++  return pixmap;
++}
++
+ static Picture
+-create_root_buffer (MetaScreen *screen)
++create_root_buffer (MetaScreen *screen, Pixmap root_pixmap)
+ {
+   MetaDisplay *display = meta_screen_get_display (screen);
+   Display *xdisplay = meta_display_get_xdisplay (display);
+   MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+   Picture pict;
+   XRenderPictFormat *format;
+-  Pixmap root_pixmap;
+   Visual *visual;
+-  int depth, screen_width, screen_height, screen_number;
++  int screen_number;
+ 
+   if (info == NULL)
+     {
+       return None;
+     }
++  g_return_val_if_fail (root_pixmap != None, None);
+ 
+-  meta_screen_get_size (screen, &screen_width, &screen_height);
+   screen_number = meta_screen_get_screen_number (screen);
+   visual = DefaultVisual (xdisplay, screen_number);
+-  depth = DefaultDepth (xdisplay, screen_number);
+ 
+   format = XRenderFindVisualFormat (xdisplay, visual);
+   g_return_val_if_fail (format != NULL, None);
+ 
+-  root_pixmap = XCreatePixmap (xdisplay, info->output,
+-                               screen_width, screen_height, depth);
+-  g_return_val_if_fail (root_pixmap != None, None);
+-
+   pict = XRenderCreatePicture (xdisplay, root_pixmap, format, 0, NULL);
+-  XFreePixmap (xdisplay, root_pixmap);
+-
+   return pict;
+ }
+ 
+@@ -1106,10 +1164,57 @@ paint_dock_shadows (MetaScreen   *screen,
+     }
+ }
+ 
++#ifdef HAVE_PRESENT
++static gboolean
++present_flip (MetaScreen *screen, XserverRegion region, Pixmap pixmap)
++{
++  static uint32_t present_serial;
++  gboolean debug;
++
++  MetaCompScreen *info = meta_screen_get_compositor_data (screen);
++  MetaDisplay *display = meta_screen_get_display (screen);
++  Display *xdisplay = meta_display_get_xdisplay (display);
++
++  meta_error_trap_push (display);
++  XPresentPixmap(xdisplay,
++                 info->output,
++                 pixmap,
++                 present_serial,
++                 None,
++                 region,
++                 0, 0,
++                 None, None, None, PresentOptionNone,
++                 0, 1, 0, NULL, 0);
++
++  int error_code;
++  error_code = meta_error_trap_pop_with_return (display, FALSE);
++  if (error_code)
++    {
++      debug = DISPLAY_COMPOSITOR (display)->debug;
++
++      if (debug)
++        fprintf (stderr, "XPresentPixmap window %p pixmap %p error: %i\n",
++                 (void *)info->output, (void *)pixmap, error_code);
++
++      if (error_code == BadWindow)
++        g_warning ("XPresent is not compatible with your current system configuration.");
++
++      /* Disable the Present extension for this session to prevent frozen windows */
++      info->use_present = FALSE;
++      return FALSE;
++    }
++
++  present_serial++;
++
++  return TRUE;
++}
++#endif /* HAVE_PRESENT */
++
+ static void
+ paint_windows (MetaScreen   *screen,
+                GList        *windows,
+                Picture       root_buffer,
++               Pixmap        root_pixmap,
+                XserverRegion region)
+ {
+   MetaDisplay *display = meta_screen_get_display (screen);
+@@ -1301,21 +1406,35 @@ paint_windows (MetaScreen   *screen,
+         }
+     }
+ 
++
++  XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0, region);
++
++#ifdef HAVE_PRESENT
++  if (info->use_present)
++    info->present_pending = present_flip (screen, region, root_pixmap);
++
++  if (!info->use_present || !info->present_pending)
++#endif /* HAVE_PRESENT */
++    {
++      XRenderComposite (xdisplay, PictOpSrc, root_buffer, None,
++          info->root_picture, 0, 0, 0, 0, 0, 0,
++          screen_width, screen_height);
++    }
++
++  XFlush (xdisplay);
+   XFixesDestroyRegion (xdisplay, paint_region);
+ }
+ 
+ static void
+ paint_all (MetaScreen   *screen,
+-           XserverRegion region)
++           XserverRegion region,
++           int           b)
+ {
+   MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+   MetaDisplay *display = meta_screen_get_display (screen);
+   Display *xdisplay = meta_display_get_xdisplay (display);
+   int screen_width, screen_height;
+ 
+-  /* Set clipping to the given region */
+-  XFixesSetPictureClipRegion (xdisplay, info->root_picture, 0, 0, region);
+-
+   meta_screen_get_size (screen, &screen_width, &screen_height);
+ 
+   if (DISPLAY_COMPOSITOR (display)->show_redraw)
+@@ -1330,6 +1449,9 @@ paint_all (MetaScreen   *screen,
+                                ((double) (rand () % 100)) / 100.0,
+                                ((double) (rand () % 100)) / 100.0);
+ 
++      /* Set clipping to the given region */
++      XFixesSetPictureClipRegion (xdisplay, info->root_picture, 0, 0, region);
++
+       XRenderComposite (xdisplay, PictOpOver, overlay, None, info->root_picture,
+                         0, 0, 0, 0, 0, 0, screen_width, screen_height);
+       XRenderFreePicture (xdisplay, overlay);
+@@ -1337,15 +1459,13 @@ paint_all (MetaScreen   *screen,
+       usleep (100 * 1000);
+     }
+ 
+-  if (info->root_buffer == None)
+-    info->root_buffer = create_root_buffer (screen);
++  if (info->root_pixmaps[b] == None)
++    info->root_pixmaps[b] = create_root_pixmap (screen);
+ 
+-  paint_windows (screen, info->windows, info->root_buffer, region);
++  if (info->root_buffers[b] == None)
++    info->root_buffers[b] = create_root_buffer (screen, info->root_pixmaps[b]);
+ 
+-  XFixesSetPictureClipRegion (xdisplay, info->root_buffer, 0, 0, region);
+-  XRenderComposite (xdisplay, PictOpSrc, info->root_buffer, None,
+-                    info->root_picture, 0, 0, 0, 0, 0, 0,
+-                    screen_width, screen_height);
++  paint_windows (screen, info->windows, info->root_buffers[b], info->root_pixmaps[b], region);
+ }
+ 
+ static void
+@@ -1355,14 +1475,47 @@ repair_screen (MetaScreen *screen)
+   MetaDisplay *display = meta_screen_get_display (screen);
+   Display *xdisplay = meta_display_get_xdisplay (display);
+ 
+-  if (info!=NULL && info->all_damage != None)
++  g_return_if_fail(info != NULL);
++
++  if (info->all_damage != None)
+     {
+-      meta_error_trap_push (display);
+-      paint_all (screen, info->all_damage);
+-      XFixesDestroyRegion (xdisplay, info->all_damage);
+-      info->all_damage = None;
+-      info->clip_changed = FALSE;
+-      meta_error_trap_pop (display, FALSE);
++#ifdef HAVE_PRESENT
++      if (info->use_present)
++        {
++          if (!info->present_pending)
++            {
++              XserverRegion damage = info->all_damage;
++              meta_error_trap_push (display);
++              if (info->prev_damage)
++                {
++                  XFixesUnionRegion(xdisplay, info->prev_damage, info->prev_damage, damage);
++                  damage = info->prev_damage;
++                }
++
++              paint_all (screen, damage, info->root_current);
++
++              if (++info->root_current >= NUM_BUFFER)
++                info->root_current = 0;
++
++              if (info->prev_damage)
++                XFixesDestroyRegion (xdisplay, info->prev_damage);
++
++              info->prev_damage = info->all_damage;
++              info->all_damage = None;
++              info->clip_changed = FALSE;
++              meta_error_trap_pop (display, FALSE);
++            }
++        }
++      else
++#endif /* HAVE_PRESENT */
++        {
++          meta_error_trap_push (display);
++          paint_all (screen, info->all_damage, info->root_current);
++          XFixesDestroyRegion (xdisplay, info->all_damage);
++          info->all_damage = None;
++          info->clip_changed = FALSE;
++          meta_error_trap_pop (display, FALSE);
++        }
+     }
+ }
+ 
+@@ -2143,10 +2296,18 @@ process_configure_notify (MetaCompositorXRender  *compositor,
+         return;
+ 
+       info = meta_screen_get_compositor_data (screen);
+-      if (info != NULL && info->root_buffer)
++      if (info != NULL)
+         {
+-          XRenderFreePicture (xdisplay, info->root_buffer);
+-          info->root_buffer = None;
++          int b;
++          for (b = 0; b < NUM_BUFFER; b++)
++            {
++              if (info->root_buffers[b]) {
++                XRenderFreePicture (xdisplay, info->root_buffers[b]);
++                XFreePixmap (xdisplay, info->root_pixmaps[b]);
++                info->root_buffers[b] = None;
++                info->root_pixmaps[b] = None;
++              }
++            }
+         }
+ 
+       damage_screen (screen);
+@@ -2422,6 +2583,47 @@ process_shape (MetaCompositorXRender *compositor,
+     }
+ }
+ 
++#ifdef HAVE_PRESENT
++static void
++xrender_present_complete(MetaScreen *screen,
++                         XPresentCompleteNotifyEvent *ce)
++{
++  MetaCompScreen *info = meta_screen_get_compositor_data (screen);
++
++  info->present_pending = False;
++  repair_screen(screen);
++}
++#endif /* HAVE_PRESENT */
++
++static void
++process_generic(MetaCompositorXRender   *compositor,
++                XGenericEvent           *event)
++{
++  XGenericEventCookie *ge = (XGenericEventCookie *) event;
++  Display *xdisplay = meta_display_get_xdisplay (compositor->display);
++  XGetEventData(xdisplay, ge);
++
++  switch (ge->evtype)
++    {
++#ifdef HAVE_PRESENT
++    case PresentConfigureNotify:
++      break;
++    case PresentCompleteNotify:
++      {
++        if (ge->extension == compositor->present_major)
++          {
++            XPresentCompleteNotifyEvent *ce = ge->data;
++            MetaScreen *screen = find_screen_from_output(compositor->display, ce->window);
++            if (screen)
++              xrender_present_complete(screen, ce);
++          }
++      }
++      break;
++#endif /* HAVE_PRESENT */
++    }
++  XFreeEventData(xdisplay, ge);
++}
++
+ static int
+ timeout_debug (MetaCompositorXRender *compositor)
+ {
+@@ -2506,6 +2708,7 @@ xrender_manage_screen (MetaCompositor *compositor,
+                        MetaScreen     *screen)
+ {
+ #ifdef HAVE_COMPOSITE_EXTENSIONS
++  MetaCompositorXRender *xrc = (MetaCompositorXRender *) compositor;
+   MetaCompScreen *info;
+   MetaDisplay *display = meta_screen_get_display (screen);
+   Display *xdisplay = meta_display_get_xdisplay (display);
+@@ -2513,6 +2716,7 @@ xrender_manage_screen (MetaCompositor *compositor,
+   XRenderPictFormat *visual_format;
+   int screen_number = meta_screen_get_screen_number (screen);
+   Window xroot = meta_screen_get_xroot (screen);
++  int b;
+ 
+   /* Check if the screen is already managed */
+   if (meta_screen_get_compositor_data (screen))
+@@ -2554,7 +2758,10 @@ xrender_manage_screen (MetaCompositor *compositor,
+       return;
+     }
+ 
+-  info->root_buffer = None;
++  for (b = 0; b < NUM_BUFFER; b++) {
++    info->root_buffers[b] = None;
++    info->root_pixmaps[b] = None;
++  }
+   info->black_picture = solid_picture (display, screen, TRUE, 1, 0, 0, 0);
+ 
+   info->root_tile = None;
+@@ -2578,6 +2785,21 @@ xrender_manage_screen (MetaCompositor *compositor,
+   else
+     meta_verbose ("Disabling shadows\n");
+ 
++#ifdef HAVE_PRESENT
++  if (xrc->has_present)
++    {
++      info->present_eid = XPresentSelectInput(xdisplay, info->output,
++                                              PresentCompleteNotifyMask);
++      info->use_present = TRUE;
++      info->present_pending = FALSE;
++    }
++  else
++    {
++      info->use_present = FALSE;
++      g_warning ("XPresent not available");
++    }
++#endif /* HAVE_PRESENT */
++
+   XClearArea (xdisplay, info->output, 0, 0, 0, 0, TRUE);
+ 
+   meta_screen_set_cm_selection (screen);
+@@ -2761,6 +2983,10 @@ xrender_process_event (MetaCompositor *compositor,
+       process_destroy (xrc, (XDestroyWindowEvent *) event);
+       break;
+ 
++    case GenericEvent:
++      process_generic (xrc, (XGenericEvent *) event);
++      break;
++
+     default:
+       if (event->type == meta_display_get_damage_event_base (xrc->display) + XDamageNotify)
+         process_damage (xrc, (XDamageNotifyEvent *) event);
+@@ -3066,6 +3292,9 @@ meta_compositor_xrender_new (MetaDisplay *display)
+   xrc->atom_net_wm_window_type_tooltip = atoms[14];
+   xrc->show_redraw = FALSE;
+   xrc->debug = FALSE;
++#ifdef HAVE_PRESENT
++  xrc->has_present = XPresentQueryExtension(xdisplay, &xrc->present_major, NULL, NULL);
++#endif /* HAVE_PRESENT */
+ 
+ #ifdef USE_IDLE_REPAINT
+   meta_verbose ("Using idle repaint\n");
diff --git a/debian/patches/series b/debian/patches/series
index 0c5f846..a1a4f18 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 0000_no_scale.patch
 0002_tiled_windows_resized_horizontally.patch
+0003_xpresent.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mate/marco.git



More information about the pkg-mate-commits mailing list