Make MetaDisplay a real GObject

We need this to be able to add signals, among other things.

http://bugzilla.gnome.org/show_bug.cgi?id=563047
This commit is contained in:
Colin Walters 2008-12-02 17:58:07 -05:00
parent 06817df975
commit 8c3bcc7229
3 changed files with 35 additions and 2 deletions

View File

@ -74,6 +74,8 @@ typedef void (* MetaWindowPingFunc) (MetaDisplay *display,
struct _MetaDisplay
{
GObject parent_instance;
char *name;
Display *xdisplay;
@ -298,6 +300,11 @@ struct _MetaDisplay
#endif
};
struct _MetaDisplayClass
{
GObjectClass parent_class;
};
/* Xserver time can wraparound, thus comparing two timestamps needs to take
* this into account. Here's a little macro to help out. If no wraparound
* has occurred, this is equivalent to

View File

@ -127,6 +127,8 @@ typedef struct
Window xwindow;
} MetaAutoRaiseData;
G_DEFINE_TYPE(MetaDisplay, meta_display, G_TYPE_OBJECT);
/**
* The display we're managing. This is a singleton object. (Historically,
* this was a list of displays, but there was never any way to add more
@ -163,6 +165,12 @@ static void sanity_check_timestamps (MetaDisplay *display,
MetaGroup* get_focussed_group (MetaDisplay *display);
static void
meta_display_class_init (MetaDisplayClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
}
/**
* Destructor for MetaPingData structs. Will destroy the
* event source for the struct as well.
@ -298,6 +306,13 @@ disable_compositor (MetaDisplay *display)
display->compositor = NULL;
}
static void
meta_display_init (MetaDisplay *disp)
{
/* Some stuff could go in here that's currently in _open,
* but it doesn't really matter. */
}
/**
* Opens a new display, sets it up, initialises all the X extensions
* we will need, and adds it to the list of displays.
@ -340,7 +355,7 @@ meta_display_open (void)
XSynchronize (xdisplay, True);
g_assert (the_display == NULL);
the_display = g_new (MetaDisplay, 1);
the_display = g_object_new (META_TYPE_DISPLAY, NULL);
the_display->closing = 0;

View File

@ -22,11 +22,22 @@
#ifndef META_DISPLAY_H
#define META_DISPLAY_H
#include <glib.h>
#include <glib-object.h>
#include <X11/Xlib.h>
#include "types.h"
typedef struct _MetaDisplayClass MetaDisplayClass;
#define META_TYPE_DISPLAY (meta_display_get_type ())
#define META_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), META_TYPE_DISPLAY, MetaDisplay))
#define META_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_DISPLAY, MetaDisplayClass))
#define META_IS_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), META_TYPE_DISPLAY))
#define META_IS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_DISPLAY))
#define META_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_DISPLAY, MetaDisplayClass))
GType meta_display_get_type (void) G_GNUC_CONST;
#define meta_XFree(p) do { if ((p)) XFree ((p)); } while (0)
typedef enum