Multiple Display support proposed Layout



Hi,

I've managed to work few more days on the Multiple Display support for
gtk. You'll find attached the interfaces proposed (header files).

-- background info --
At the moment gtk only works on a single screen (Therefore only one display).
In the X11 implementation of gdk, all the info relative to display, screen,
visuals are global variables.

So to add multiple display support, I've created three classes to abstract the
handling of multiple display (see diagram attached and previous email
http://mail.gnome.org/archives/gtk-devel-list/2000-December/msg00100.html)
-- end background info --

I also attach the header files of these classes :
 gdkdisplaymgr.h,gdkdisplay.h,gdkscreen.h
and the X11 implementation classes :
 gdkdisplay-x11.h gdkscreen-x11.h

Please, bear in mind that theses interfaces are not complete yet...

I'm also augmenting the API by adding screen or display "variant"
to already existing functions to support multiple display.

e.g. for gdk_visual_init I've added a gdk_visual_init_screen
variant, gdk_visual_init called only for the default version.
See gdkmultihead.h for the "variant" signature I've already done.

So my question is : Is the naming convention I've used OK ? 
If not, please, give me some pointers.

Comment or feedback would be nice.
Thanks

Erwann

[ I speak for myself, not for my employer. ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Erwann Chénedé, Sun Microsystems Ireland
  Desktop Applications & Middleware Group
  Phone  : +353 1 8199031        xt: 19031
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Attachment: new-layout.png
Description: new-layout.png

#ifndef __GDK_DISPLAY_H__
#define __GDK_DISPLAY_H__

#include <gdk/gdktypes.h>
#include <gobject/gobject.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

typedef struct _GdkDisplayClass	    GdkDisplayClass;

#define GDK_TYPE_DISPLAY              (gdk_display_get_type ())
#define GDK_DISPLAY(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY, GdkDisplay))
#define GDK_DISPLAY_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY, GdkDisplayClass))
#define GDK_IS_DISPLAY(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY))
#define GDK_IS_DISPLAY_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY))
#define GDK_DISPLAY_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY, GdkDisplayClass))


struct _GdkDisplay 
{
    GObject parent_instance;
    
};

struct _GdkDisplayClass
{
    GObjectClass 	    parent_class;
    GdkDisplay *	    (*new_display)	    (gchar * display_name);	    
    gchar *		    (*get_display_string)   (GdkDisplay *dpy);	    
    gint 		    (*screen_count)	    (GdkDisplay *dpy);	    
    GdkScreen *		    (*get_screen)	    (GdkDisplay *dpy,gint screen_num);
    GdkScreen *		    (*get_default_screen)   (GdkDisplay *dpy);	    
};

GType		    gdk_display_get_type	(void);
GdkDisplay *	    gdk_display_new		(void);
GdkDisplay *	    gdk_display_ref		(GdkDisplay* display);
void		    gdk_display_unref		(GdkDisplay* display);


#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_DISPLAY_H__ */
#ifndef __GDK_DISPLAY_MGR__
#define __GDK_DISPLAY_MGR__

#include "gdkdisplay.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GDK_TYPE_DISPLAY_MGR              (gdk_display_mgr_type())
#define GDK_DISPLAY_MGR(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_MGR, GdkDisplayMgr))
#define GDK_DISPLAY_MGR_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_MGR, GdkDisplayMgrClass))
#define GDK_IS_DISPLAY_MGR(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY_MGR))
#define GDK_IS_DISPLAY_MGR_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY_MGR))
#define GDK_DISPLAY_MGR_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY_MGR, GdkDisplayMgrClass))

typedef struct _GdkDisplayMgr      GdkDisplayMgr;
typedef struct _GdkDisplayMgrClass GdkDisplayMgrClass;

struct _GdkDisplayMgr 
{
  GObject	    parent_instance;
  GdkDisplay *	    default_display;
  GSList *	    display_list;
};

struct _GdkDisplayMgrClass
{
  GObjectClass parent_class;
  
  GdkDisplay *		    (*open_display)	(GdkDisplayMgr * dpy_mgr,
						 gchar *display_name);
  void			    (*set_default)	(GdkDisplayMgr * dpy_mgr,
						 GdkDisplay *default_display);
  GdkDisplay *		    (*get_default)	(GdkDisplayMgr * dpy_mgr);
  gint			    (*get_num_display)  (GdkDisplayMgr * dpy_mgr);
};


GType		gdk_display_mgr_type	    (void);
GdkDisplayMgr * gdk_display_mgr_new	    (void);
/*GdkDisplayMgr * gdk_display_mgr_unref	    (GdkDisplayMgr * dpy_mgr);
void	        gdk_display_mgr_ref	    (GdkDisplayMgr * dpy_mgr);*/

#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_DISPLAY_MGR__ */

#ifndef __GDK_SCREEN_H__
#define __GDK_SCREEN_H__

#include "gdk/gdktypes.h"

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

typedef struct _GdkScreenClass	GdkScreenClass;

#define GDK_TYPE_SCREEN              (gdk_screen_get_type ())
#define GDK_SCREEN(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_SCREEN, GdkScreen))
#define GDK_SCREEN_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_SCREEN, GdkScreenClass))
#define GDK_IS_SCREEN(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_SCREEN))
#define GDK_IS_SCREEN_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_SCREEN))
#define GDK_SCREEN_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SCREEN, GdkScreenClass))



struct _GdkScreen
{
 GObject	parent_instance;
/* GdkVisual *	default_visual;*/
};

struct _GdkScreenClass 
{
 GObjectClass 	    parent_class;
 GdkDisplay *	    (*get_display)		(GdkScreen * screen);
 GdkScreen *	    (*get_root_window)		(GdkScreen * screen);
 gint 		    (*get_width)		(GdkScreen * screen);
 gint 		    (*get_height)		(GdkScreen * screen);
 gint 		    (*get_width_mm)		(GdkScreen * screen);
 gint 		    (*get_height_mm)		(GdkScreen * screen);
 gint 		    (*get_root_depth)		(GdkScreen * screen);
 gint		    (*get_screen_num)		(GdkScreen * screen);
/* GdkVisual *	    (*get_root_visual)		(GdkScreen * screen);
 GdkColormap *	    (*get_default_colormap)	(GdkScreen * screen);
 GdkGC *	    (*get_default_gc)		(GdkScreen * screen);*/
};

GType 		    gdk_screen_get_type	(void);
GdkScreen *	    gdk_screen_ref	(GdkScreen * screen);
void		    gdk_screen_unref	(GdkScreen * screen);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_SCREEN_H__ */
#ifndef __GDK_SCREEN_X11_H__
#define __GDK_SCREEN_X11_H__


#include "gdkscreen.h"
#include <X11/X.h>
#include <X11/Xlib.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

typedef struct _GdkScreenImplX11 GdkScreenImplX11;
typedef struct _GdkScreenImplX11Class GdkScreenImplX11Class;


#define GDK_TYPE_SCREEN_IMPL_X11              (gdk_X11_screen_impl_get_type ())
#define GDK_SCREEN_IMPL_X11(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_SCREEN_IMPL_X11, GdkScreenImplX11))
#define GDK_SCREEN_IMPL_X11_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_SCREEN_IMPL_X11, GdkScreenImplX11Class))
#define GDK_IS_SCREEN_IMPL_X11(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_SCREEN_IMPL_X11))
#define GDK_IS_SCREEN_IMPL_X11_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_SCREEN_IMPL_X11))
#define GDK_SCREEN_IMPL_X11_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_SCREEN_IMPL_X11, GdkScreenImplX11Class))



struct _GdkScreenImplX11 
{
    GdkScreen	    parent_instance;
    GdkDisplay *    display;
    Display *	    xdisplay;
    Screen *	    xscreen;
    gint	    scr_num;
    Window *	    root_window;
    Window *	    gdk_leader_window;
    /* Visual Part */
    GdkVisualPrivate *	system_visual;
    GdkVisualPrivate *	visuals;
    gint		nvisuals;
    gint		available_depths[7];
    gint		navailable_depths;
    GdkVisualType	available_types[6];
    gint		navailable_types;
    GHashTable *	visual_hash;
};

struct _GdkScreenImplX11Class
{
    GdkScreenClass parent_class;
};


GType gdk_X11_screen_impl_get_type();


GdkDisplay *	    gdk_X11_screen_get_display		(GdkScreen * screen);
gint 		    gdk_X11_screen_get_width		(GdkScreen * screen);
gint 		    gdk_X11_screen_get_height		(GdkScreen * screen);
gint 		    gdk_X11_screen_get_width_mm	(GdkScreen * screen);
gint 		    gdk_X11_screen_get_height_mm	(GdkScreen * screen);
gint 		    gdk_X11_screen_get_default_depth	(GdkScreen * screen);
/*GdkVisual *	    gdk_X11_screen_get_root_visual	(GdkScreen * screen);
GdkColormap *	    gdk_X11_screen_get_default_colormap(GdkScreen * screen);
GdkGC *		    gdk_X11_screen_get_default_gc	(GdkScreen * screen);*/

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _GDK_SCREEN_X11_H__ */
#ifndef __GDK_DISPLAY_X11__
#define __GDK_DISPLAY_X11__

#include "gdkdisplay.h"
#include <X11/X.h>
#include <X11/Xlib.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

typedef struct _GdkDisplayImplX11 GdkDisplayImplX11;
typedef struct _GdkDisplayImplX11Class GdkDisplayImplX11Class;


#define GDK_TYPE_DISPLAY_IMPL_X11              (gdk_x11_display_impl_get_type())
#define GDK_DISPLAY_IMPL_X11(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_IMPL_X11, GdkDisplayImplX11))
#define GDK_DISPLAY_IMPL_X11_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_IMPL_X11, GdkDisplayImplX11Class))
#define GDK_IS_DISPLAY_IMPL_X11(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY_IMPL_X11))
#define GDK_IS_DISPLAY_IMPL_X11_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY_IMPL_X11))
#define GDK_DISPLAY_IMPL_X11_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY_IMPL_X11, GdkDisplayImplX11Class))



struct _GdkDisplayImplX11 
{
    GdkDisplay	parent_instance;
    Display	* xdisplay;
    GdkScreen	* default_screen;
    GSList	* screen_list;
    /* Display wide Atoms */
    Atom	gdk_wm_delete_window;
    Atom        gdk_wm_take_focus;
    Atom        gdk_wm_protocols;
    Atom        gdk_wm_window_protocols[3];
    Atom        gdk_selection_property;
    gint	autorepeat;
};

struct _GdkDisplayImplX11Class
{
    GdkDisplayClass parent_class;
};

GdkDisplay *	gdk_x11_display_impl_display_new(gchar * display_name);
char *		gdk_x11_display_impl_get_display_string(GdkDisplay *dpy);	    
gint		gdk_x11_display_impl_screen_count(GdkDisplay *dpy);	    
GdkScreen *	gdk_x11_display_impl_get_screen(GdkDisplay *dpy,gint screen_num);
GdkScreen *	gdk_x11_display_impl_get_default_screen(GdkDisplay *dpy);	
static void	gdk_x11_display_impl_class_init(GdkDisplayImplX11Class *class);
GType		gdk_x11_display_impl_get_type();

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* __GDK_DISPLAY_X11__ */


#ifndef __GDK_MULTIHEAD__
#define __GDK_MULTIHEAD__

#include "gdkx.h"

/*
   MultiHead alternate version of existing functions 
 */
GdkAtom
gdk_atom_intern_display(const gchar * atom_name,
			gboolean only_if_exists,
			GdkDisplay * dpy);
gboolean
_gdk_windowing_init_check_display(int argc, char **argv, char *display_name);

void
 gdk_key_repeat_restore_display(GdkDisplay * dpy);

/*
   visual part 
 */
void gdk_visual_init_screen(GdkScreen * scr);
void gdk_visual_add_screen(GdkVisual * visual, GdkScreen * scr);
gint gdk_visual_get_best_depth_screen(GdkScreen * scr);
GdkVisualType gdk_visual_get_best_type_screen(GdkScreen * scr);
GdkVisual *gdk_visual_get_system_screen(GdkScreen * scr);
GdkVisual *gdk_visual_get_best_screen(GdkScreen * scr);
GdkVisual *gdk_visual_get_best_with_depth_screen(gint depth, GdkScreen * scr);
GdkVisual *gdk_visual_get_best_with_type_screen(GdkVisualType visual_type, GdkScreen * scr);
GdkVisual *gdk_visual_get_best_with_both_for_screen(gin depth,
					       GdkVisualType visual_type,
						    GdkScreen * scr);
void gdk_query_depths_screen(gint ** depths,
			     gint * count,
			     GdkScreen * scr);
void
 gdk_query_visual_types_screen(GdkVisualType ** visual_types,
			       gint * count
			       GdkScreen * scr);
GdkVisual *gdkx_visual_screen_get(VisualID xvisualid, GdkScreen * scr);



#endif


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