Esempio n. 1
0
/* similar to what we have in libgimp/gimpui.c */
void
gimp_window_set_transient_for (GtkWindow *window,
                               guint32    parent_ID)
{
  /* Cross-process transient-for is broken in gdk/win32 <= 2.10.6. It
   * causes hangs, at least when used as by the gimp and script-fu
   * processes. In some newer GTK+ version it will be fixed to be a
   * no-op. If it eventually is fixed to actually work, change this to
   * a run-time check of GTK+ version. Remember to change also the
   * function with the same name in libgimp/gimpui.c
   */
#ifndef GDK_WINDOWING_WIN32
  GdkWindow *parent;

  parent = gdk_window_foreign_new_for_display (gdk_display_get_default (),
                                               parent_ID);

  if (! parent)
    return;

  if (GTK_WIDGET_REALIZED (window))
    gdk_window_set_transient_for (GTK_WIDGET (window)->window, parent);

  g_signal_connect_object (window, "realize",
                           G_CALLBACK (gimp_window_transient_realized),
                           parent, 0);

  g_object_unref (parent);
#endif
}
Esempio n. 2
0
/* From X Window System Interaction */
static VALUE
gdkwin_foreign_new(int argc, VALUE *argv, VALUE self)
{
    VALUE arg[2];
    GdkWindow * win = NULL;
    
    rb_scan_args(argc, argv, "11", &arg[0], &arg[1]);

    switch(argc)
    {
      case 1:
    	win = gdk_window_foreign_new(RVAL2GDKNATIVEWINDOW(arg[0]));
	break;
      case 2:
#if GTK_CHECK_VERSION(2,2,0)
    	win = gdk_window_foreign_new_for_display(RVAL2GOBJ(arg[0]),
                                                 RVAL2GDKNATIVEWINDOW(arg[1])); 
#else
    	win = gdk_window_foreign_new(NUM2UINT(arg[1])); 
        rb_warn("Not supported in GTK+-2.0.x.");
#endif 
   	break;
    }
    if (win == NULL)
        return Qnil;
    else {
        return GOBJ2RVAL(win);
    }
}
Esempio n. 3
0
void start_recording(GtkWidget *widget, gpointer data) {
    GdkNativeWindow native;
    GdkDisplay *display;
    GdkRectangle rect;

    if(is_recording)
        return;

    screen = gtk_widget_get_screen(widget);
    if (screen == NULL) {
        screen = gdk_screen_get_default ();
    }
    native = select_window(screen);
    display = gdk_screen_get_display (screen);
    window = gdk_window_foreign_new_for_display (display, native);

    gdk_drawable_get_size (GDK_DRAWABLE (window), &rect.width, &rect.height);

    /* creating flv und screenVideo instances */
    flv = newFLVStream(FLVVERSION_1, FLVFLAG_VIDEO);
    video = newScreenVideo(rect.width, rect.height, 64);
    printf("video width: %i, height: %i\n", rect.width, rect.height);

    /* capture timer */
    g_timeout_add ( 1000 / FRAMERATE,  next_capture, NULL);
    is_recording = 1;
}
Esempio n. 4
0
/* From X Window System Interaction */
static VALUE
rg_s_foreign_new(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
    VALUE arg[2];
    GdkWindow * win = NULL;

    rb_scan_args(argc, argv, "11", &arg[0], &arg[1]);

    switch(argc)
    {
      case 1:
        win = gdk_window_foreign_new(RVAL2GDKNATIVEWINDOW(arg[0]));
        break;
      case 2:
        win = gdk_window_foreign_new_for_display(RVAL2GOBJ(arg[0]),
                                                 RVAL2GDKNATIVEWINDOW(arg[1]));
        break;
    default:
        break;
    }
    if (win == NULL)
        return Qnil;
    else {
        return GOBJ2RVAL(win);
    }
}
Esempio n. 5
0
static void really_make_transient(GtkWidget *window, ALLEGRO_DISPLAY_XGLX *glx)
{
   GdkDisplay *gdk = gdk_drawable_get_display(GDK_DRAWABLE(window->window));
   GdkWindow *parent = gdk_window_lookup_for_display(gdk, glx->window);
   if (!parent)
      parent = gdk_window_foreign_new_for_display(gdk, glx->window);
   gdk_window_set_transient_for(window->window, parent);
}
Esempio n. 6
0
/**
 * mcm_window_set_parent_xid:
 **/
static void
mcm_window_set_parent_xid (GtkWindow *window, guint32 xid)
{
	GdkDisplay *display;
	GdkWindow *parent_window;
	GdkWindow *our_window;

	display = gdk_display_get_default ();
	parent_window = gdk_window_foreign_new_for_display (display, xid);
	our_window = gtk_widget_get_window (GTK_WIDGET (window));

	/* set this above our parent */
	gtk_window_set_modal (window, TRUE);
	gdk_window_set_transient_for (our_window, parent_window);
}
Esempio n. 7
0
/**
 * gimp_ui_get_progress_window:
 *
 * Returns the #GdkWindow of the window this plug-in's progress bar is
 * shown in. Use it to make plug-in dialogs transient to this window
 * as explained with gdk_window_set_transient_for().
 *
 * You shouldn't have to call this function directly. Use
 * gimp_window_set_transient() instead.
 *
 * Return value: A reference to a #GdkWindow or %NULL. You should
 *               unref the window using g_object_unref() as soon as
 *               you don't need it any longer.
 *
 * Since: GIMP 2.4
 */
GdkWindow *
gimp_ui_get_progress_window (void)
{
#ifndef GDK_NATIVE_WINDOW_POINTER
  GdkNativeWindow  window;

  g_return_val_if_fail (gimp_ui_initialized, NULL);

  window = gimp_progress_get_window_handle ();
  if (window)
    return gdk_window_foreign_new_for_display (gdk_display_get_default (),
                                               window);
#endif

  return NULL;
}
/**
 * gpk_window_set_parent_xid:
 **/
gboolean
gpk_window_set_parent_xid (GtkWindow *window, guint32 xid)
{
	GdkDisplay *display;
	GdkWindow *parent_window;
	GdkWindow *our_window;

	g_return_val_if_fail (xid != 0, FALSE);

	display = gdk_display_get_default ();
	parent_window = gdk_window_foreign_new_for_display (display, xid);
	our_window = gtk_widget_get_window (GTK_WIDGET (window));

	/* set this above our parent */
	gtk_window_set_modal (window, TRUE);
	gdk_window_set_transient_for (our_window, parent_window);
	return TRUE;
}
static void
impl_MateComponent_Canvas_Component_realize (PortableServer_Servant  servant,
				      const CORBA_char       *window,
				      CORBA_Environment      *ev)
{
	Gcc *gcc = GCC (matecomponent_object_from_servant (servant));
	MateCanvasItem *item = MATE_CANVAS_ITEM (gcc->priv->item);
	GdkWindow *gdk_window = gdk_window_foreign_new_for_display
		(gtk_widget_get_display (GTK_WIDGET (item->canvas)),
		 matecomponent_control_x11_from_window_id (window));

	if (gdk_window == NULL) {
		g_warning ("Invalid window id passed='%s'", window);
		return;
	}

	item->canvas->layout.bin_window = gdk_window;
	ICLASS (item)->realize (item);
}
Esempio n. 10
0
static gint32
shoot (GdkScreen *screen)
{
  GdkDisplay   *display;
  GdkWindow    *window;
  GdkPixbuf    *screenshot;
  GdkRegion    *shape = NULL;
  GdkRectangle  rect;
  GdkRectangle  screen_rect;
  gchar        *name  = NULL;
  gint32        image;
  gint          screen_x;
  gint          screen_y;
  gint          x, y;

  /* use default screen if we are running non-interactively */
  if (screen == NULL)
    screen = gdk_screen_get_default ();

  display = gdk_screen_get_display (screen);

  screen_rect.x      = 0;
  screen_rect.y      = 0;
  screen_rect.width  = gdk_screen_get_width (screen);
  screen_rect.height = gdk_screen_get_height (screen);

  if (shootvals.shoot_type == SHOOT_REGION)
    {
      rect.x = MIN (shootvals.x1, shootvals.x2);
      rect.y = MIN (shootvals.y1, shootvals.y2);
      rect.width  = ABS (shootvals.x2 - shootvals.x1);
      rect.height = ABS (shootvals.y2 - shootvals.y1);
    }
  else
    {
      if (shootvals.shoot_type == SHOOT_ROOT)
        {
          window = gdk_screen_get_root_window (screen);
        }
      else
        {
          window = gdk_window_foreign_new_for_display (display,
                                                       shootvals.window_id);
        }

      if (! window)
        {
          g_message (_("Specified window not found"));
          return -1;
        }

      gdk_drawable_get_size (GDK_DRAWABLE (window), &rect.width, &rect.height);
      gdk_window_get_origin (window, &x, &y);

      rect.x = x;
      rect.y = y;
    }

  if (! gdk_rectangle_intersect (&rect, &screen_rect, &rect))
    return -1;

  window = gdk_screen_get_root_window (screen);
  gdk_window_get_origin (window, &screen_x, &screen_y);

  screenshot = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
                                             rect.x - screen_x,
                                             rect.y - screen_y,
                                             0, 0, rect.width, rect.height);

  gdk_display_beep (display);
  gdk_flush ();

  if (! screenshot)
    {
      g_message (_("There was an error taking the screenshot."));
      return -1;
    }

  if (shootvals.shoot_type == SHOOT_WINDOW)
    {
      name = window_get_title (display, shootvals.window_id);

      shape = window_get_shape (screen, shootvals.window_id);

      if (shape)
        gdk_region_offset (shape, x - rect.x, y - rect.y);
    }

  image = create_image (screenshot, shape, name);

  g_object_unref (screenshot);

  if (shape)
    gdk_region_destroy (shape);

  g_free (name);

  return image;
}
Esempio n. 11
0
GwyRemote*
gwy_remote_get(void)
{
    GwyRemote *remote;
    GdkWindow *root;
    Display *xdisplay;
    Window xroot, xparent, *xchildren;
    Atom role_xatom;
    guint nchildren;
    gint i;

    remote = g_new0(GwyRemote, 1);
    remote->display = gdk_display_get_default();
    g_object_ref(remote->display);
    root = gdk_screen_get_root_window(gdk_screen_get_default());
    xdisplay = gdk_x11_display_get_xdisplay(remote->display);

    if (!XQueryTree(xdisplay, GDK_WINDOW_XID(root),
                    &xroot, &xparent, &xchildren, &nchildren)
        || !nchildren
        || !xchildren) {
        gwy_remote_free(remote);
        return NULL;
    }

    role_xatom = gdk_x11_get_xatom_by_name_for_display(remote->display,
                                                       "WM_WINDOW_ROLE");

    for (i = nchildren-1; !remote->toolbox && i >= 0; i--) {
        Window xwindow;
        Atom ret_type_xatom;
        gint ret_format;
        gulong bytes_after, nitems;
        guchar *data;

        /*
         * The XmuClientWindow() function finds a window at or below the
         * specified window, that has a WM_STATE property. If such a
         * window is found, it is returned; otherwise the argument window
         * is returned.
         */
        xwindow = XmuClientWindow(xdisplay, xchildren[i]);
        if (XGetWindowProperty(xdisplay, xwindow,
                               role_xatom, 0, 32, FALSE, XA_STRING,
                               &ret_type_xatom, &ret_format,
                               &nitems, &bytes_after, &data) == Success
            && ret_type_xatom) {
            if (gwy_strequal(data, GWY_TOOLBOX_WM_ROLE)) {
                remote->winid = xwindow;
                remote->toolbox
                    = gdk_window_foreign_new_for_display(remote->display,
                                                         remote->winid);
                g_object_ref(remote->toolbox);
            }

            XFree(data);
        }
    }

    XFree(xchildren);
    if (!remote->winid) {
        gwy_remote_free(remote);
        remote = NULL;
    }

    return remote;
}
Esempio n. 12
0
GdkWindow *
gimp_remote_find_toolbox (GdkDisplay *display,
                          GdkScreen  *screen)
{
  GdkWindow  *result = NULL;
  Display    *xdisplay;
  Window      root, parent;
  Window     *children;
  Atom        role_atom;
  Atom        string_atom;
  guint       nchildren;
  gint        i;

  GdkWindow  *root_window = gdk_screen_get_root_window (screen);

  xdisplay = gdk_x11_display_get_xdisplay (display);

  role_atom   = XInternAtom (xdisplay, "WM_WINDOW_ROLE", TRUE);
  string_atom = XInternAtom (xdisplay, "STRING",         TRUE);

  if (role_atom == None || string_atom == None)
    return NULL;

  if (XQueryTree (xdisplay, GDK_WINDOW_XID (root_window),
                  &root, &parent, &children, &nchildren) == 0)
    return NULL;

  if (! (children && nchildren))
    return NULL;

  for (i = nchildren - 1; i >= 0; i--)
    {
      Window  window;
      Atom    ret_type;
      gint    ret_format;
      gulong  bytes_after;
      gulong  nitems;
      guchar *data;

      /*  The XmuClientWindow() function finds a window at or below the
       *  specified window, that has a WM_STATE property. If such a
       *  window is found, it is returned; otherwise the argument window
       *  is returned.
       */

      window = XmuClientWindow (xdisplay, children[i]);

      /*  We are searching for the GIMP toolbox: Its WM_WINDOW_ROLE Property
       *  (as set by gtk_window_set_role ()) has the value "gimp-toolbox".
       *  This is pretty reliable, since it ask for a special property,
       *  explicitly set by GIMP. See below... :-)
       */

      if (XGetWindowProperty (xdisplay, window,
                              role_atom,
                              0, 32,
                              FALSE,
                              string_atom,
                              &ret_type, &ret_format, &nitems, &bytes_after,
                              &data) == Success && ret_type)
        {
          if (nitems > 11 &&
              strcmp ((const gchar *) data, "gimp-toolbox") == 0)
            {
              XFree (data);
              result = gdk_window_foreign_new_for_display (display, window);
              break;
            }

          XFree (data);
        }
    }

  XFree (children);

  return result;
}
/**
 * matecomponent_control_set_transient_for:
 * @control: a control with associated control frame
 * @window: a window upon which to set the transient window.
 * 
 *   Attempts to make the @window transient for the toplevel
 * of any associated controlframe the MateComponentControl may have.
 **/
void
matecomponent_control_set_transient_for (MateComponentControl     *control,
				  GtkWindow         *window,
				  CORBA_Environment *opt_ev)
{
	CORBA_char         *id;
	GdkDisplay         *display;
	GdkWindow          *win;
	GdkNativeWindow    window_id;
	CORBA_Environment  *ev = NULL, tmp_ev;
	MateComponent_ControlFrame frame;
	gpointer            local_win;

	g_return_if_fail (GTK_IS_WINDOW (window));
	g_return_if_fail (MATECOMPONENT_IS_CONTROL (control));

	/* FIXME: special case the local case !
	 * we can only do this if set_transient is virtualized
	 * and thus we can catch it in MateComponentSocket and chain up
	 * again if we are embedded inside an embedded thing. */

	frame = control->priv->frame;

	if (frame == CORBA_OBJECT_NIL)
		return;

	if (opt_ev)
		ev = opt_ev;
	else {
		CORBA_exception_init (&tmp_ev);
		ev = &tmp_ev;
	}

	id = MateComponent_ControlFrame_getToplevelId (frame, ev);
	g_return_if_fail (!MATECOMPONENT_EX (ev) && id != NULL);

	window_id = matecomponent_control_x11_from_window_id (id);

#ifdef TRANSIENT_DEBUG
	g_warning ("Got id '%s' -> %d", id, window_id);
#endif
	CORBA_free (id);

	display = gtk_widget_get_display (GTK_WIDGET (window));

#if defined (GDK_WINDOWING_X11)
	local_win = gdk_xid_table_lookup_for_display (display, window_id);
#elif defined (GDK_WINDOWING_WIN32)
	local_win = gdk_win32_handle_table_lookup (window_id);
#endif
	if (local_win == NULL)
		win = gdk_window_foreign_new_for_display (display, window_id);
	else {
		win = GDK_WINDOW (local_win);
		g_object_ref (win);
	}
	g_return_if_fail (win != NULL);

	window_set_transient_for_gdk (window, win);

	if (!opt_ev)
		CORBA_exception_free (&tmp_ev);
}