コード例 #1
0
ファイル: GdkWindow.c プロジェクト: cyberpython/java-gnome
JNIEXPORT void JNICALL
Java_org_gnome_gdk_GdkWindow_gdk_1window_1get_1frame_1extents
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jlong _rect
)
{
	GdkWindow* self;
	GdkRectangle* rect;

	// convert parameter self
	self = (GdkWindow*) _self;

	// convert parameter rect
	rect = (GdkRectangle*) _rect;

	// call function
	gdk_window_get_frame_extents(self, rect);

	// cleanup parameter self

	// cleanup parameter rect
}
コード例 #2
0
ファイル: gailwindow.c プロジェクト: Aridna/gtk2
static void
gail_window_get_size (AtkComponent *component,
                      gint         *width,
                      gint         *height)
{
  GtkWidget *widget = GTK_ACCESSIBLE (component)->widget; 
  GdkRectangle rect;

  if (widget == NULL)
    /*
     * State is defunct
     */
    return;

  gail_return_if_fail (GTK_IS_WINDOW (widget));

  if (!gtk_widget_is_toplevel (widget))
    {
      AtkComponentIface *parent_iface;

      parent_iface = (AtkComponentIface *) g_type_interface_peek_parent (ATK_COMPONENT_GET_IFACE (component));
      parent_iface->get_size (component, width, height);
      return;
    }
  gdk_window_get_frame_extents (widget->window, &rect);

  *width = rect.width;
  *height = rect.height;
}
コード例 #3
0
ファイル: rbgdkwindow.c プロジェクト: geoffyoungs/ruby-gnome2
static VALUE
gdkwin_get_frame_extents(VALUE self)
{
    GdkRectangle rect;
    gdk_window_get_frame_extents(_SELF(self), &rect);
    return BOXED2RVAL(&rect, GDK_TYPE_RECTANGLE);
}
コード例 #4
0
static VALUE
rg_frame_extents(VALUE self)
{
    GdkRectangle rect;
    gdk_window_get_frame_extents(_SELF(self), &rect);
    return GDKRECTANGLE2RVAL(&rect);
}
コード例 #5
0
static void
screenshot_fallback_get_window_rect_coords (GdkWindow *window,
                                            gboolean include_border,
                                            GdkRectangle *real_coordinates_out,
                                            GdkRectangle *screenshot_coordinates_out)
{
  gint x_orig, y_orig;
  gint width, height;
  GdkRectangle real_coordinates;

  if (include_border)
    {
      gdk_window_get_frame_extents (window, &real_coordinates);
    }
  else
    {
      real_coordinates.width = gdk_window_get_width (window);
      real_coordinates.height = gdk_window_get_height (window);
      
      gdk_window_get_origin (window, &real_coordinates.x, &real_coordinates.y);
    }

  x_orig = real_coordinates.x;
  y_orig = real_coordinates.y;
  width  = real_coordinates.width;
  height = real_coordinates.height;

  if (real_coordinates_out != NULL)
    *real_coordinates_out = real_coordinates;

  if (x_orig < 0)
    {
      width = width + x_orig;
      x_orig = 0;
    }

  if (y_orig < 0)
    {
      height = height + y_orig;
      y_orig = 0;
    }

  if (x_orig + width > gdk_screen_width ())
    width = gdk_screen_width () - x_orig;

  if (y_orig + height > gdk_screen_height ())
    height = gdk_screen_height () - y_orig;

  if (screenshot_coordinates_out != NULL)
    {
      screenshot_coordinates_out->x = x_orig;
      screenshot_coordinates_out->y = y_orig;
      screenshot_coordinates_out->width = width;
      screenshot_coordinates_out->height = height;
    }
}
コード例 #6
0
ファイル: gtk.c プロジェクト: Airr/Claro
/* "borrowed" from http://mail.gnome.org/archives/gtk-app-devel-list/2004-November/msg00028.html */
static void widget_get_rect_in_screen( GtkWidget *widget, GdkRectangle *r )
{
	gint x,y,w,h;
	GdkRectangle extents;
	GdkWindow *window;
	window = gtk_widget_get_parent_window(widget); /* getting parent window */
	gdk_window_get_root_origin(window, &x,&y); /* parent's left-top screen coordinates */
	gdk_drawable_get_size(window, &w,&h); /* parent's width and height */
	gdk_window_get_frame_extents(window, &extents); /* parent's extents (including decorations) */
	r->x = x + (extents.width-w)/2 + widget->allocation.x; /* calculating x (assuming: left border size == right border size) */
	r->y = y + (extents.height-h)-(extents.width-w)/2 + widget->allocation.y; /* calculating y (assuming: left border size == right border size == bottom border size) */
	r->width = widget->allocation.width;
	r->height = widget->allocation.height;
}
コード例 #7
0
ファイル: gailwindow.c プロジェクト: Aridna/gtk2
static void
gail_window_get_extents (AtkComponent  *component,
                         gint          *x,
                         gint          *y,
                         gint          *width,
                         gint          *height,
                         AtkCoordType  coord_type)
{
  GtkWidget *widget = GTK_ACCESSIBLE (component)->widget; 
  GdkRectangle rect;
  gint x_toplevel, y_toplevel;

  if (widget == NULL)
    /*
     * State is defunct
     */
    return;

  gail_return_if_fail (GTK_IS_WINDOW (widget));

  if (!gtk_widget_is_toplevel (widget))
    {
      AtkComponentIface *parent_iface;

      parent_iface = (AtkComponentIface *) g_type_interface_peek_parent (ATK_COMPONENT_GET_IFACE (component));
      parent_iface->get_extents (component, x, y, width, height, coord_type);
      return;
    }

  gdk_window_get_frame_extents (widget->window, &rect);

  *width = rect.width;
  *height = rect.height;
  if (!gtk_widget_is_drawable (widget))
    {
      *x = G_MININT;
      *y = G_MININT;
      return;
    }
  *x = rect.x;
  *y = rect.y;
  if (coord_type == ATK_XY_WINDOW)
    {
      gdk_window_get_origin (widget->window, &x_toplevel, &y_toplevel);
      *x -= x_toplevel;
      *y -= y_toplevel;
    }
}
コード例 #8
0
ファイル: Preview.cpp プロジェクト: yoosamui/DockLight
/**
 * Transfers image data from a GdkWindow and converts it to an RGB(A) 
 * representation inside a GdkPixbuf. In other words, copies image data 
 * from a server-side drawable to a client-side RGB(A) buffer. 
 * This allows to efficiently read individual pixels on the client side.
 *  
 * Create a new GdkPixbuf containing a copy of src scaled to dest_width x dest_height . 
 * Leaves src unaffected. interp_type should be GDK_INTERP_NEAREST 
 * if you want maximum speed (but when scaling down GDK_INTERP_NEAREST is usually unusably ugly). 
 * The default interp_type should be GDK_INTERP_BILINEAR which offers reasonable quality and speed.
 * 
 * @param DockItem*  item
 * @return GdkPixbuf* 
 * 
 */
GdkPixbuf* Preview::getScaledPixbuf(DockItem* item)
{
    GdkWindow *wm_window = gdk_x11_window_foreign_new_for_display(
            gdk_display_get_default(), item->m_xid);
    GdkRectangle boundingbox;
    gdk_window_get_frame_extents(wm_window, &boundingbox);


    GdkPixbuf *pb = gdk_pixbuf_get_from_window(wm_window,
            0, 0, boundingbox.width - 10, boundingbox.height - 30);


    if (pb == NULL) {
        return nullptr;
    }

    int height = m_previewHeight - DEF_PREVIEW_SCALE_HEIGHT_OFFSET;
    int width = m_previewWidth - DEF_PREVIEW_SCALE_WIDTH_OFFSET;
    int scale_heght = height;

    int windowheight = gdk_window_get_height(wm_window);

    int heightHalf = (height / 2);

    if (windowheight < 300)
        scale_heght = heightHalf;
    if (windowheight < 200)
        scale_heght = heightHalf - 20;
    if (windowheight < 100)
        scale_heght = heightHalf - 40;
    if (windowheight < 50)
        scale_heght = heightHalf - 60;

    if (scale_heght < 10)
        scale_heght = height;

    // offers reasonable quality and speed.
    GdkPixbuf* scaledpb = gdk_pixbuf_scale_simple(pb, width, scale_heght,
            GDK_INTERP_BILINEAR);

    g_object_unref(pb);

    return scaledpb;

}
コード例 #9
0
ファイル: mud-subwindow.c プロジェクト: GNOME/gnome-mud
/* MudSubwindow Callbacks */
static gboolean
mud_subwindow_delete_event_cb(GtkWidget *widget,
			      GdkEvent *event,
			      MudSubwindow *self)
{
    GdkWindow *wm_window;
    GdkRectangle rect;

    wm_window = gtk_widget_get_window(self->priv->window);
    gdk_window_get_frame_extents(wm_window, &rect);

    self->priv->x = rect.x;
    self->priv->y = rect.y;

    gtk_widget_hide(self->priv->window);
    self->priv->visible = FALSE;
    self->priv->view_hidden = FALSE;

    return TRUE;
}
コード例 #10
0
ファイル: mud-subwindow.c プロジェクト: GNOME/gnome-mud
void
mud_subwindow_hide(MudSubwindow *self)
{
    GdkWindow *wm_window;
    GdkRectangle rect;

    g_return_if_fail(MUD_IS_SUBWINDOW(self));

    if(self->priv->visible)
    {
        wm_window = gtk_widget_get_window(self->priv->window);
        gdk_window_get_frame_extents(wm_window, &rect);

        self->priv->x = rect.x;
        self->priv->y = rect.y;

        self->priv->visible = FALSE;
        gtk_widget_hide(self->priv->window);
    }
}
コード例 #11
0
ファイル: videooverlay.cpp プロジェクト: jgrande/ginga
bool VideoOverlay::move( const Point &point ) {
	const Size &s = _main->size();
	gint x,y,borderLeft,borderBottom;
	GdkRectangle fRect;

	GdkWindow *window = gtk_widget_get_window(_main->widget()); //	Getting window
	gdk_window_get_origin(window, &x,&y);  //	Parent's left-top screen coordinates
	gdk_window_get_frame_extents( window, &fRect ); //	Getting size and position including decorations


	//Calculating borders
	borderLeft = (fRect.width-s.w)/2;
	borderBottom = fRect.height - (s.h + (y-fRect.y));

	if (_needMove) {
		gtk_window_move( GTK_WINDOW (_main->widget()), fRect.x  ,fRect.y );
	}
	_needMove = !_needMove;

	gtk_window_move( GTK_WINDOW(_window), fRect.x+(fRect.width-s.w)+point.x-borderLeft, fRect.y+(fRect.height-s.h)+point.y-borderBottom );

	_rect = point;
	return true;
}
コード例 #12
0
ファイル: window.c プロジェクト: risujin/cellwriter
static gboolean window_configure(GtkWidget *widget, GdkEventConfigure *event)
/* Intelligently grow the window up and/or left if we are in the bottom or
   right corners of the screen respectively */
{
        GdkRectangle new_frame = {0, 0, 0, 0};
        GdkScreen *screen;
        int screen_w, screen_h, height_change, label_w;

        if (!window || !window->window)
                return FALSE;
        gtk_widget_get_display(window);

        /* Get screen and window information */
        screen = gtk_window_get_screen(GTK_WINDOW(window));
        screen_w = gdk_screen_get_width(screen);
        screen_h = gdk_screen_get_height(screen);
        gdk_window_get_frame_extents(window->window, &new_frame);

        /* We need to resize wrapped labels manually */
        label_w = window->allocation.width - 16;
        if (train_label && train_label->requisition.width != label_w)
                gtk_widget_set_size_request(train_label, label_w, -1);

        /* Docked windows have special placing requirements */
        height_change = new_frame.height - window_frame.height;
        if (window_docked) {
                window_frame = new_frame;
                if (screen_w != screen_width || screen_h != screen_height ||
                    (height_change && window_docked == WINDOW_DOCKED_BOTTOM)) {
                        screen_width = screen_w;
                        screen_height = screen_h;
                        trace("move-sizing bottom-docked window");
                        docked_move_resize();
                }
                update_struts();
                return FALSE;
        }
        screen_width = screen_w;
        screen_height = screen_h;

        /* Do nothing on the first configure */
        if (window_frame.height <= 1) {
                window_frame = new_frame;
                return FALSE;
        }

#ifndef WINDOW_GRAVITY
        /* Keep the window aligned to the bottom border */
        if (height_change && window_frame.y + window_frame.height / 2 >
                             gdk_screen_get_height(screen) / 2)
                window_frame.y -= height_change;
        else
                height_change = 0;

        /* Do not allow the window to go off-screen */
        if (window_frame.x + new_frame.width > screen_w)
                window_frame.x = screen_w - new_frame.width;
        if (window_frame.y + new_frame.height > screen_h)
                window_frame.y = screen_h - new_frame.height;
        if (window_frame.x < 0)
                window_frame.x = 0;
        if (window_frame.y < 0)
                window_frame.y = 0;

        /* Some window managers (Metacity) do not allow windows to resize
           larger than the screen and will move the window back within the
           screen bounds when this happens. We don't like this because it
           screws with our own correcting offset. Fortunately, both the move
           and the resize are bundled in one configure event so we can work
           around this by using our old x/y coordinates when the dimensions
           change. */
        if (height_change && (new_frame.x != window_frame.x ||
                              new_frame.y != window_frame.y)) {
                gtk_window_move(GTK_WINDOW(window),
                                window_frame.x, window_frame.y);
                window_frame.width = new_frame.width;
                window_frame.height = new_frame.height;
                trace("moving to (%d, %d)", window_frame.x, window_frame.y);
        } else
                window_frame = new_frame;
#endif

        return FALSE;
}