1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2  * vim: set expandtab shiftwidth=2 tabstop=2: */
3 
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 
8 #ifndef __GTK_XTBIN_H__
9 #define __GTK_XTBIN_H__
10 
11 #include <gtk/gtk.h>
12 #include <X11/Intrinsic.h>
13 #include <X11/Xutil.h>
14 #include <X11/Xlib.h>
15 #ifdef MOZILLA_CLIENT
16 #include "mozilla/Types.h"
17 #ifdef _IMPL_GTKXTBIN_API
18 #define GTKXTBIN_API(type) MOZ_EXPORT type
19 #else
20 #define GTKXTBIN_API(type) MOZ_IMPORT_API type
21 #endif
22 #else
23 #define GTKXTBIN_API(type) type
24 #endif
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif /* __cplusplus */
29 
30 typedef struct _XtClient XtClient;
31 
32 struct _XtClient {
33   Display *xtdisplay;
34   Widget top_widget;   /* The toplevel widget */
35   Widget child_widget; /* The embedded widget */
36   Visual *xtvisual;
37   int xtdepth;
38   Colormap xtcolormap;
39   Window oldwindow;
40 };
41 
42 #if (GTK_MAJOR_VERSION == 2)
43 typedef struct _GtkXtBin GtkXtBin;
44 typedef struct _GtkXtBinClass GtkXtBinClass;
45 
46 #define GTK_TYPE_XTBIN (gtk_xtbin_get_type())
47 #define GTK_XTBIN(obj) \
48   (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_XTBIN, GtkXtBin))
49 #define GTK_XTBIN_CLASS(klass) \
50   (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_XTBIN, GtkXtBinClass))
51 #define GTK_IS_XTBIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_XTBIN))
52 #define GTK_IS_XTBIN_CLASS(klass) \
53   (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_XTBIN))
54 
55 struct _GtkXtBin {
56   GtkSocket gsocket;
57   GdkWindow *parent_window;
58   Display *xtdisplay; /* Xt Toolkit Display */
59 
60   Window xtwindow;   /* Xt Toolkit XWindow */
61   XtClient xtclient; /* Xt Client for XEmbed */
62 };
63 
64 struct _GtkXtBinClass {
65   GtkSocketClass parent_class;
66 };
67 
68 GTKXTBIN_API(GType) gtk_xtbin_get_type(void);
69 GTKXTBIN_API(GtkWidget *) gtk_xtbin_new(GdkWindow *parent_window, String *f);
70 #endif
71 
72 typedef struct _XtTMRec {
73   XtTranslations translations;       /* private to Translation Manager    */
74   XtBoundActions proc_table;         /* procedure bindings for actions    */
75   struct _XtStateRec *current_state; /* Translation Manager state ptr     */
76   unsigned long lastEventTime;
77 } XtTMRec, *XtTM;
78 
79 typedef struct _CorePart {
80   Widget self;                      /* pointer to widget itself          */
81   WidgetClass widget_class;         /* pointer to Widget's ClassRec      */
82   Widget parent;                    /* parent widget                     */
83   XrmName xrm_name;                 /* widget resource name quarkified   */
84   Boolean being_destroyed;          /* marked for destroy                */
85   XtCallbackList destroy_callbacks; /* who to call when widget destroyed */
86   XtPointer constraints;            /* constraint record                 */
87   Position x, y;                    /* window position                   */
88   Dimension width, height;          /* window dimensions                 */
89   Dimension border_width;           /* window border width               */
90   Boolean managed;                  /* is widget geometry managed?       */
91   Boolean sensitive;                /* is widget sensitive to user events*/
92   Boolean ancestor_sensitive;       /* are all ancestors sensitive?      */
93   XtEventTable event_table;         /* private to event dispatcher       */
94   XtTMRec tm;                       /* translation management            */
95   XtTranslations accelerators;      /* accelerator translations          */
96   Pixel border_pixel;               /* window border pixel               */
97   Pixmap border_pixmap;             /* window border pixmap or NULL      */
98   WidgetList popup_list;            /* list of popups                    */
99   Cardinal num_popups;              /* how many popups                   */
100   String name;                      /* widget resource name              */
101   Screen *screen;                   /* window's screen                   */
102   Colormap colormap;                /* colormap                          */
103   Window window;                    /* window ID                         */
104   Cardinal depth;                   /* number of planes in window        */
105   Pixel background_pixel;           /* window background pixel           */
106   Pixmap background_pixmap;         /* window background pixmap or NULL  */
107   Boolean visible;                  /* is window mapped and not occluded?*/
108   Boolean mapped_when_managed;      /* map window if it's managed?       */
109 } CorePart;
110 
111 typedef struct _WidgetRec {
112   CorePart core;
113 } WidgetRec, CoreRec;
114 
115 /* Exported functions, used by Xt plugins */
116 void xt_client_create(XtClient *xtclient, Window embeder, int height,
117                       int width);
118 void xt_client_unrealize(XtClient *xtclient);
119 void xt_client_destroy(XtClient *xtclient);
120 void xt_client_init(XtClient *xtclient, Visual *xtvisual, Colormap xtcolormap,
121                     int xtdepth);
122 void xt_client_xloop_create(void);
123 void xt_client_xloop_destroy(void);
124 Display *xt_client_get_display(void);
125 
126 #ifdef __cplusplus
127 }
128 #endif /* __cplusplus */
129 #endif /* __GTK_XTBIN_H__ */
130