[mutter/wayland] cursor-tracker: Start moving some code to a new file



commit 5f52f55916b29e87f321137f7ef04936482a8f68
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Mar 31 14:08:14 2014 -0400

    cursor-tracker: Start moving some code to a new file
    
    I want the MetaCursorTracker to mostly be about retrieving cursor
    information. Start moving the code that loads cursor images to a
    new file, MetaCursor. Eventually, MetaCursorTracker's APIs will
    all take MetaCursorReferences, and we can have a clean backend
    split here.

 src/Makefile.am                |    3 ++
 src/core/meta-cursor-private.h |   38 +++++++++++++++++++++++++++++++
 src/core/meta-cursor-tracker.c |   33 +--------------------------
 src/core/meta-cursor.c         |   48 ++++++++++++++++++++++++++++++++++++++++
 src/core/meta-cursor.h         |   30 +++++++++++++++++++++++++
 5 files changed, 120 insertions(+), 32 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index c81d096..5f43272 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -127,6 +127,9 @@ libmutter_wayland_la_SOURCES =                      \
        core/keybindings.c                      \
        core/keybindings-private.h              \
        core/main.c                             \
+       core/meta-cursor.c                      \
+       core/meta-cursor.h                      \
+       core/meta-cursor-private.h              \
        core/meta-cursor-tracker.c              \
        core/meta-cursor-tracker-private.h      \
        core/meta-idle-monitor.c                \
diff --git a/src/core/meta-cursor-private.h b/src/core/meta-cursor-private.h
new file mode 100644
index 0000000..14d3ec6
--- /dev/null
+++ b/src/core/meta-cursor-private.h
@@ -0,0 +1,38 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright 2013 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Giovanni Campagna <gcampagn redhat com>
+ */
+
+#ifndef META_CURSOR_PRIVATE_H
+#define META_CURSOR_PRIVATE_H
+
+#include "meta-cursor.h"
+
+#include <cogl/cogl.h>
+#include <gbm.h>
+
+struct _MetaCursorReference {
+  int ref_count;
+
+  CoglTexture2D *texture;
+  struct gbm_bo *bo;
+  int hot_x, hot_y;
+};
+
+#endif /* META_CURSOR_PRIVATE_H */
diff --git a/src/core/meta-cursor-tracker.c b/src/core/meta-cursor-tracker.c
index b2a619f..5c315fc 100644
--- a/src/core/meta-cursor-tracker.c
+++ b/src/core/meta-cursor-tracker.c
@@ -45,20 +45,13 @@
 #include <X11/extensions/Xfixes.h>
 #include <X11/Xcursor/Xcursor.h>
 
+#include "meta-cursor-private.h"
 #include "meta-cursor-tracker-private.h"
 #include "screen-private.h"
 #include "monitor-private.h"
 
 #include "wayland/meta-wayland-private.h"
 
-typedef struct {
-  int ref_count;
-
-  CoglTexture2D *texture;
-  struct gbm_bo *bo;
-  int hot_x, hot_y;
-} MetaCursorReference;
-
 struct _MetaCursorTracker {
   GObject parent_instance;
 
@@ -123,30 +116,6 @@ static void meta_cursor_tracker_set_crtc_has_hw_cursor (MetaCursorTracker *track
                                                         gboolean           has_hw_cursor);
 static void sync_cursor (MetaCursorTracker *tracker);
 
-static MetaCursorReference *
-meta_cursor_reference_ref (MetaCursorReference *self)
-{
-  g_assert (self->ref_count > 0);
-  self->ref_count++;
-
-  return self;
-}
-
-static void
-meta_cursor_reference_unref (MetaCursorReference *self)
-{
-  self->ref_count--;
-
-  if (self->ref_count == 0)
-    {
-      cogl_object_unref (self->texture);
-      if (self->bo)
-        gbm_bo_destroy (self->bo);
-
-      g_slice_free (MetaCursorReference, self);
-    }
-}
-
 static void
 translate_meta_cursor (MetaCursor   cursor,
                        guint       *glyph_out,
diff --git a/src/core/meta-cursor.c b/src/core/meta-cursor.c
new file mode 100644
index 0000000..822fd11
--- /dev/null
+++ b/src/core/meta-cursor.c
@@ -0,0 +1,48 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright 2013 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Giovanni Campagna <gcampagn redhat com>
+ */
+
+#include "config.h"
+
+#include "meta-cursor-private.h"
+
+MetaCursorReference *
+meta_cursor_reference_ref (MetaCursorReference *self)
+{
+  g_assert (self->ref_count > 0);
+  self->ref_count++;
+
+  return self;
+}
+
+void
+meta_cursor_reference_unref (MetaCursorReference *self)
+{
+  self->ref_count--;
+
+  if (self->ref_count == 0)
+    {
+      cogl_object_unref (self->texture);
+      if (self->bo)
+        gbm_bo_destroy (self->bo);
+
+      g_slice_free (MetaCursorReference, self);
+    }
+}
diff --git a/src/core/meta-cursor.h b/src/core/meta-cursor.h
new file mode 100644
index 0000000..6d5bc3e
--- /dev/null
+++ b/src/core/meta-cursor.h
@@ -0,0 +1,30 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright 2013 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Giovanni Campagna <gcampagn redhat com>
+ */
+
+#ifndef META_CURSOR_H
+#define META_CURSOR_H
+
+typedef struct _MetaCursorReference MetaCursorReference;
+
+MetaCursorReference * meta_cursor_reference_ref (MetaCursorReference *cursor);
+void meta_cursor_reference_unref (MetaCursorReference *cursor);
+
+#endif /* META_CURSOR_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]