Back to index

lightning-sunbird  0.9+nobinonly
Enumerations | Functions | Variables
gtkmozarea.c File Reference
#include "gtkmozarea.h"
#include <gtk/gtk.h>
#include <gdk/gdkx.h>

Go to the source code of this file.

Enumerations

enum  { TOPLEVEL_FOCUS_IN, TOPLEVEL_FOCUS_OUT, TOPLEVEL_CONFIGURE, LAST_SIGNAL }

Functions

static void gtk_mozarea_class_init (GtkMozAreaClass *klass)
static void gtk_mozarea_init (GtkMozArea *mozarea)
static void gtk_mozarea_realize (GtkWidget *widget)
static void gtk_mozarea_unrealize (GtkWidget *widget)
static void gtk_mozarea_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
static void gtk_mozarea_destroy (GtkObject *object)
static void attach_toplevel_listener (GtkMozArea *mozarea)
static void remove_toplevel_listener (GtkMozArea *mozarea)
static Window get_real_toplevel (Window aWindow)
static GdkWindow * get_real_gdk_toplevel (GtkMozArea *mozarea)
static GdkFilterReturn toplevel_window_filter (GdkXEvent *aGdkXEvent, GdkEvent *aEvent, gpointer data)
static GdkFilterReturn widget_window_filter (GdkXEvent *aGdkXEvent, GdkEvent *aEvent, gpointer data)
GtkType gtk_mozarea_get_type (void)
GtkWidget * gtk_mozarea_new (GdkWindow *parent_window)
gboolean gtk_mozarea_get_toplevel_focus (GtkMozArea *area)

Variables

GtkWidgetClass * parent_class = NULL
static guint mozarea_signals [LAST_SIGNAL] = { 0 }

Enumeration Type Documentation

anonymous enum
Enumerator:
TOPLEVEL_FOCUS_IN 
TOPLEVEL_FOCUS_OUT 
TOPLEVEL_CONFIGURE 
LAST_SIGNAL 

Definition at line 76 of file gtkmozarea.c.


Function Documentation

static void attach_toplevel_listener ( GtkMozArea *  mozarea) [static]

Definition at line 265 of file gtkmozarea.c.

{
  /* get the real gdk toplevel window */
  GdkWindow *gdk_window = get_real_gdk_toplevel(mozarea);

  /* attach our passive filter.  when this widget is destroyed it will
     be removed in our destroy method. */
  gdk_window_add_filter(gdk_window, toplevel_window_filter, mozarea);

  /* save it so that we can remove the filter later */
  mozarea->toplevel_window = gdk_window;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static GdkWindow * get_real_gdk_toplevel ( GtkMozArea *  mozarea) [static]

Definition at line 346 of file gtkmozarea.c.

{
  /* get the native window for this widget */
  GtkWidget *widget = GTK_WIDGET(mozarea);
  Window window = GDK_WINDOW_XWINDOW(widget->window);
  
  Window toplevel = get_real_toplevel(window);
  
  /* check to see if this is an already registered window with the
     type system. */
  GdkWindow *gdk_window = gdk_window_lookup(toplevel);
  
  /* This isn't our window?  It is now, fool! */
  if (!gdk_window) {
    /* import it into the type system */
    gdk_window = gdk_window_foreign_new(toplevel);
    /* make sure that we are listening for the right events on it. */
    gdk_window_set_events(gdk_window, GDK_FOCUS_CHANGE_MASK);
  }

  return gdk_window;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static Window get_real_toplevel ( Window  aWindow) [static]

Definition at line 288 of file gtkmozarea.c.

{
  Window current = aWindow;
  Atom   atom;

  /* get the atom for the WM_STATE variable that you get on WM
     managed windows. */

  atom = XInternAtom(GDK_DISPLAY(), "WM_STATE", FALSE);

  while (current) {
    Atom type = None;
    int format;
    unsigned long nitems, after;
    unsigned char *data;

    Window root_return;
    Window parent_return;
    Window *children_return = NULL;
    unsigned int nchildren_return;

    /* check for the atom on this window */
    XGetWindowProperty(GDK_DISPLAY(), current, atom,
                     0, 0, /* offsets */
                     False, /* don't delete */
                     AnyPropertyType,
                     &type, &format, &nitems, &after, &data);

    /* did we get something? */
    if (type != None) {
      XFree(data);
      data = NULL;
      /* ok, this is the toplevel window since it has the property set
         on it. */
      break;
    }
    
    /* what is the parent? */
    XQueryTree(GDK_DISPLAY(), current, &root_return,
              &parent_return, &children_return,
              &nchildren_return);

    if (children_return)
      XFree(children_return);

    /* If the parent window of this window is the root window then
     there is no window manager running so the current window is the
     toplevel window. */
    if (parent_return == root_return)
      break;

    current = parent_return;
  }

  return current;
}

Here is the caller graph for this function:

static void gtk_mozarea_class_init ( GtkMozAreaClass *  klass) [static]

Definition at line 111 of file gtkmozarea.c.

{
  GtkWidgetClass *widget_class;
  GtkObjectClass *object_class;

  widget_class = GTK_WIDGET_CLASS (klass);
  object_class = GTK_OBJECT_CLASS (klass);

  widget_class->realize = gtk_mozarea_realize;
  widget_class->unrealize = gtk_mozarea_unrealize;
  widget_class->size_allocate = gtk_mozarea_size_allocate;

  object_class->destroy = gtk_mozarea_destroy;

  parent_class = gtk_type_class(gtk_widget_get_type());

  /* set up our signals */

  mozarea_signals[TOPLEVEL_FOCUS_IN] =
    gtk_signal_new("toplevel_focus_in",
                   GTK_RUN_FIRST,
                   object_class->type,
                   GTK_SIGNAL_OFFSET(GtkMozAreaClass, toplevel_focus_in),
                   gtk_marshal_NONE__NONE,
                   GTK_TYPE_NONE, 0);
  mozarea_signals[TOPLEVEL_FOCUS_OUT] =
    gtk_signal_new("toplevel_focus_out",
                   GTK_RUN_FIRST,
                   object_class->type,
                   GTK_SIGNAL_OFFSET(GtkMozAreaClass, toplevel_focus_out),
                   gtk_marshal_NONE__NONE,
                   GTK_TYPE_NONE, 0);
  mozarea_signals[TOPLEVEL_CONFIGURE] =
    gtk_signal_new("toplevel_configure",
                   GTK_RUN_FIRST,
                   object_class->type,
                   GTK_SIGNAL_OFFSET(GtkMozAreaClass, toplevel_configure),
                   gtk_marshal_NONE__NONE,
                   GTK_TYPE_NONE, 0);
  gtk_object_class_add_signals(object_class, mozarea_signals, LAST_SIGNAL);

}

Here is the call graph for this function:

Here is the caller graph for this function:

static void gtk_mozarea_destroy ( GtkObject *  object) [static]

Definition at line 234 of file gtkmozarea.c.

{
  GtkMozArea *mozarea;

  g_return_if_fail(GTK_IS_MOZAREA(object));
  
  mozarea = GTK_MOZAREA(object);

  /* remove the listener from the toplevel */
  remove_toplevel_listener(mozarea);

  GTK_OBJECT_CLASS(parent_class)->destroy(object);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean gtk_mozarea_get_toplevel_focus ( GtkMozArea *  area)

Definition at line 255 of file gtkmozarea.c.

{
  g_return_val_if_fail(GTK_IS_MOZAREA(area), FALSE);
  
  return area->toplevel_focus;
}
GtkType gtk_mozarea_get_type ( void  )

Definition at line 86 of file gtkmozarea.c.

{
  static GtkType mozarea_type = 0;
  
  if (!mozarea_type)
    {
      static const GtkTypeInfo mozarea_info =
      {
        "GtkMozArea",
        sizeof (GtkMozArea),
        sizeof (GtkMozAreaClass),
        (GtkClassInitFunc) gtk_mozarea_class_init,
        (GtkObjectInitFunc) gtk_mozarea_init,
        /* reserved_1 */ NULL,
        /* reserved_2 */ NULL,
        (GtkClassInitFunc) NULL
      };
      
      mozarea_type = gtk_type_unique (GTK_TYPE_WIDGET, &mozarea_info);
    }

  return mozarea_type;
}

Here is the call graph for this function:

static void gtk_mozarea_init ( GtkMozArea *  mozarea) [static]

Definition at line 155 of file gtkmozarea.c.

{
  mozarea->superwin = NULL;
  mozarea->toplevel_focus = FALSE;
  mozarea->toplevel_window = NULL;
  gtk_widget_set_name(GTK_WIDGET(mozarea), "gtkmozarea");
}

Here is the caller graph for this function:

GtkWidget* gtk_mozarea_new ( GdkWindow *  parent_window)

Definition at line 249 of file gtkmozarea.c.

{
  return GTK_WIDGET (gtk_type_new (GTK_TYPE_MOZAREA));
}

Here is the caller graph for this function:

static void gtk_mozarea_realize ( GtkWidget *  widget) [static]

Definition at line 164 of file gtkmozarea.c.

{
  GtkMozArea *mozarea;
  
  g_return_if_fail (GTK_IS_MOZAREA (widget));

  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);

  mozarea = GTK_MOZAREA (widget);

  mozarea->superwin = gdk_superwin_new (gtk_widget_get_parent_window (widget),
                                        widget->allocation.x,
                                        widget->allocation.y,
                                        widget->allocation.width,
                                        widget->allocation.height);
  gdk_window_set_user_data (mozarea->superwin->shell_window, mozarea);
  widget->window = mozarea->superwin->shell_window;
  widget->style = gtk_style_attach (widget->style, widget->window);
  /* make sure that we add a reference to this window.
     if we don't then it will be destroyed by both the superwin
     destroy method and the widget class destructor */
  gdk_window_ref(widget->window);

  /* attach the toplevel X listener */
  attach_toplevel_listener(mozarea);

  /* Attach a filter so that we can get reparent notifications so we
     can reset our toplevel window.  This will automatically be
     removed when our window is destroyed. */
  gdk_window_add_filter(widget->window, widget_window_filter, mozarea);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void gtk_mozarea_size_allocate ( GtkWidget *  widget,
GtkAllocation *  allocation 
) [static]

Definition at line 215 of file gtkmozarea.c.

{
  GtkMozArea *mozarea;
  
  g_return_if_fail (GTK_IS_MOZAREA (widget));

  mozarea = GTK_MOZAREA (widget);

  if (GTK_WIDGET_REALIZED (widget))
    {
      gdk_window_move (mozarea->superwin->shell_window,
                     allocation->x, allocation->y);
      gdk_superwin_resize (mozarea->superwin,
                        allocation->width, allocation->height);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void gtk_mozarea_unrealize ( GtkWidget *  widget) [static]

Definition at line 197 of file gtkmozarea.c.

{
  GtkMozArea *mozarea;
  
  g_return_if_fail(GTK_IS_MOZAREA(widget));

  GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);

  mozarea = GTK_MOZAREA(widget);
  
  if (mozarea->superwin) {
    gtk_object_unref(GTK_OBJECT(mozarea->superwin));
    mozarea->superwin = NULL;
  }
  GTK_WIDGET_CLASS(parent_class)->unrealize(widget);
}

Here is the caller graph for this function:

static void remove_toplevel_listener ( GtkMozArea *  mozarea) [static]

Definition at line 280 of file gtkmozarea.c.

{
  gdk_window_remove_filter(mozarea->toplevel_window, toplevel_window_filter,
                           mozarea);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static GdkFilterReturn toplevel_window_filter ( GdkXEvent *  aGdkXEvent,
GdkEvent *  aEvent,
gpointer  data 
) [static]

Definition at line 370 of file gtkmozarea.c.

{
  XEvent       *xevent = (XEvent *)aGdkXEvent;
  GtkMozArea   *mozarea = (GtkMozArea *)data;

  switch (xevent->xany.type) {
  case FocusIn:
    mozarea->toplevel_focus = TRUE;
    gtk_signal_emit(GTK_OBJECT(mozarea), mozarea_signals[TOPLEVEL_FOCUS_IN]);
    break;
  case FocusOut:
    mozarea->toplevel_focus = FALSE;
    gtk_signal_emit(GTK_OBJECT(mozarea), mozarea_signals[TOPLEVEL_FOCUS_OUT]);
    break;
  case ConfigureNotify:
    gtk_signal_emit(GTK_OBJECT(mozarea), mozarea_signals[TOPLEVEL_CONFIGURE]);
    break;
  default:
    break;
  }

  return GDK_FILTER_CONTINUE;
}

Here is the caller graph for this function:

static GdkFilterReturn widget_window_filter ( GdkXEvent *  aGdkXEvent,
GdkEvent *  aEvent,
gpointer  data 
) [static]

Definition at line 397 of file gtkmozarea.c.

{
  XEvent       *xevent = (XEvent *)aGdkXEvent;
  GtkMozArea   *mozarea = (GtkMozArea *)data;

  switch(xevent->xany.type) {
  case ReparentNotify:
    /* remove the old filter on the toplevel and attach to the new one */
    remove_toplevel_listener(mozarea);
    attach_toplevel_listener(mozarea);
    break;
  default:
    break;
  }
  return GDK_FILTER_CONTINUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

guint mozarea_signals[LAST_SIGNAL] = { 0 } [static]

Definition at line 83 of file gtkmozarea.c.

GtkWidgetClass* parent_class = NULL

Definition at line 74 of file gtkmozarea.c.