Esempio n. 1
0
/* 
	This function exists because GDK retrieves client coordinates, not window ones.
	(Kevin: GDK uses GetClientRect and ClientToScreen).
	We need that to save and restore windows position.
*/
void window_get_rect(GtkWidget *widget, GdkRect *rect)
{
	gtk_window_get_size(GTK_WINDOW(widget), &rect->w, &rect->h);

#ifdef __WIN32__
	{
		BOOL bResult;
		HWND hWnd = GDK_WINDOW_HWND(widget->window);
		RECT lpRect;
		GdkRectangle gdkRect;

		bResult = GetWindowRect(hWnd, &lpRect);

		rect->x = lpRect.left;
		rect->y = lpRect.top;

		// Now obtain and add the offset between GDK and Win32 coordinates
		// (in the multi-screen case).
		gdk_screen_get_monitor_geometry(gdk_screen_get_default(), 0, &gdkRect);
		rect->x += gdkRect.x;
		rect->y += gdkRect.y;
	}
#else
	gdk_window_get_position(widget->window, &rect->x, &rect->y);
#endif
}
gboolean
gd_tagged_entry_tag_get_area (GdTaggedEntryTag      *tag,
                              cairo_rectangle_int_t *rect)
{
    GtkStyleContext *context;
    GtkAllocation background_allocation;
    int window_x, window_y;
    GtkAllocation alloc;

    g_return_val_if_fail (GD_IS_TAGGED_ENTRY_TAG (tag), FALSE);
    g_return_val_if_fail (rect != NULL, FALSE);

    gdk_window_get_position (tag->window, &window_x, &window_y);
    gtk_widget_get_allocation (GTK_WIDGET (tag->entry), &alloc);
    context = gd_tagged_entry_tag_get_context (tag, tag->entry);
    gd_tagged_entry_tag_get_relative_allocations (tag, tag->entry, context,
            &background_allocation,
            NULL, NULL);

    rect->x = window_x - alloc.x + background_allocation.x;
    rect->y = window_y - alloc.y + background_allocation.y;
    rect->width = background_allocation.width;
    rect->height = background_allocation.height;

    return TRUE;
}
/**
 * anjuta_tabber_get_widget_coordinates:
 * @widget: widget for the coordinates
 * @event: event to get coordinates from
 * @x: return location for x coordinate
 * @y: return location for y coordinate
 *
 * Returns: %TRUE if coordinates were set, %FALSE otherwise
 */
static gboolean
anjuta_tabber_get_widget_coordinates (GtkWidget *widget,
			GdkEvent  *event,
			gint      *x,
			gint      *y)
{
  GdkWindow *window = ((GdkEventAny *)event)->window;
  gdouble tx, ty;

  if (!gdk_event_get_coords (event, &tx, &ty))
    return FALSE;

  while (window && window != gtk_widget_get_window (widget))
    {
      gint window_x, window_y;

      gdk_window_get_position (window, &window_x, &window_y);
      tx += window_x;
      ty += window_y;

      window = gdk_window_get_parent (window);
    }

  if (window)
    {
      *x = tx;
      *y = ty;

      return TRUE;
    }
  else
    return FALSE;
}
Esempio n. 4
0
static VALUE
gdkwin_get_position(VALUE self)
{
    gint x, y;
    gdk_window_get_position(_SELF(self), &x, &y);
    return rb_assoc_new(INT2NUM(x), INT2NUM(y));
}
/**
      \brief Retrieve info from window, needed for accel layer
*/
void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo)
{
        GdkWindow *win;
        GtkWidget *widget=(GtkWidget *)draw;
          
        win = gtk_widget_get_parent_window(widget);

#ifdef __WIN32
		xinfo->display = (void*)GDK_WINDOW_HWND(widget->window);
#elif defined(__APPLE__)
		int windowWidth, windowHeight;
		int x, y;

		gdk_drawable_get_size(win, &windowWidth, &windowHeight);
		gdk_window_get_position(widget->window, &x, &y);

		xinfo->display = 0;
		xinfo->window = getMainNSWindow();
		xinfo->x = x;
		xinfo->y = windowHeight - (y + lastH);
		xinfo->width = lastW;
		xinfo->height = lastH;
#else
		xinfo->window = GDK_WINDOW_XWINDOW(widget->window);
		xinfo->display = GDK_WINDOW_XDISPLAY(win);
#endif
}
Esempio n. 6
0
void WinDraw_InitWindowSize(WORD width, WORD height)
{
	static BOOL inited = FALSE;

	if (!inited) {
		GdkWindow *t, *root = window->window;

		while ((t = gdk_window_get_parent(root)) != 0)
			root = t;
		gdk_window_get_size(root, &root_width, &root_height);
		inited = TRUE;
	}

	gdk_window_get_position(window->window, &winx, &winy);

	winw = width;
	winh = height;

	if (root_width < winw)
		winx = (root_width - winw) / 2;
	else if (winx < 0)
		winx = 0;
	else if ((winx + winw) > root_width)
		winx = root_width - winw;
	if (root_height < winh)
		winy = (root_height - winh) / 2;
	else if (winy < 0)
		winy = 0;
	else if ((winy + winh) > root_height)
		winy = root_height - winh;
}
Esempio n. 7
0
/**
      \brief Retrieve info from window, needed for accel layer
*/
void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo)
{
		GdkWindow *win, *parentWin;
		GtkWidget *widget=(GtkWidget *)draw;

		win = gtk_widget_get_window(widget);
		parentWin = gtk_widget_get_parent_window(widget);

#ifdef _WIN32
		xinfo->display = (void*)GDK_WINDOW_HWND(win);
#elif defined(__APPLE__)
		xinfo->display = 0;
		xinfo->window = getMainNSWindow();
#else
		xinfo->systemWindowId = GDK_WINDOW_XID(win);
		xinfo->display = GDK_WINDOW_XDISPLAY(parentWin);
#endif

		int windowWidth, windowHeight;
		int x, y;

		windowWidth = gdk_window_get_width(parentWin);
		windowHeight = gdk_window_get_height(parentWin);
		gdk_window_get_position(win, &x, &y);

		xinfo->x = x;
		xinfo->y = windowHeight - (y + lastH);
		xinfo->width = lastW;
		xinfo->height = lastH;
}
Esempio n. 8
0
/* Translates coordinates from dest_widget->window relative (src_x, src_y),
 * to allocation relative (dest_x, dest_y) of dest_widget.
 */
static void
window_to_alloc (GtkWidget *dest_widget,
		 gint       src_x,
		 gint       src_y,
		 gint      *dest_x,
		 gint      *dest_y)
{
  /* Translate from window relative to allocation relative */
  if (gtk_widget_get_has_window (dest_widget) && dest_widget->parent)
    {
      gint wx, wy;
      gdk_window_get_position (dest_widget->window, &wx, &wy);

      /* Offset coordinates if widget->window is smaller than
       * widget->allocation.
       */
      src_x += wx - dest_widget->allocation.x;
      src_y += wy - dest_widget->allocation.y;
    }
  else
    {
      src_x -= dest_widget->allocation.x;
      src_y -= dest_widget->allocation.y;
    }

  if (dest_x)
    *dest_x = src_x;
  if (dest_y)
    *dest_y = src_y;
}
Esempio n. 9
0
/* panel_window_get_position */
void panel_window_get_position(PanelWindow * panel, gint * x, gint * y)
{
	GdkWindow * window;

	window = gtk_widget_get_window(panel->window);
	gdk_window_get_position(window, x, y);
}
Esempio n. 10
0
static gboolean
on_expose_event(GtkWidget      *widget,
		GdkEventExpose *event,
		gpointer        data)
{
	cairo_t *cr;
	gint x, y, width, height;
	int i;
	cr = gdk_cairo_create(widget->window);

	gdk_window_get_position(widget->window, &x, &y);
	gdk_drawable_get_size(widget->window, &width, &height);

	
	cairo_set_source_rgb (cr, 0, 0, 0);
	//cairo_set_source(cr, bgpattern);
	cairo_paint (cr);

	for (i = 0; i < NUM_CIRCLES; ++i) {
		draw_circle(cr, width, height, circles + i);
	}

	cairo_destroy(cr);

	return FALSE;
}
Esempio n. 11
0
static void size_allocate(GtkWidget* widget, GtkAllocation* alloc)
{
    wxPizza* pizza = WX_PIZZA(widget);
    int border_x, border_y;
    pizza->get_border_widths(border_x, border_y);
    int w = alloc->width - 2 * border_x;
    if (w < 0) w = 0;

    if (gtk_widget_get_realized(widget))
    {
        int h = alloc->height - 2 * border_y;
        if (h < 0) h = 0;
        const int x = alloc->x + border_x;
        const int y = alloc->y + border_y;

        GdkWindow* window = gtk_widget_get_window(widget);
        int old_x, old_y;
        gdk_window_get_position(window, &old_x, &old_y);

        if (x != old_x || y != old_y ||
            w != gdk_window_get_width(window) || h != gdk_window_get_height(window))
        {
            gdk_window_move_resize(window, x, y, w, h);

            if (border_x + border_y)
            {
                // old and new border areas need to be invalidated,
                // otherwise they will not be erased/redrawn properly
                GdkWindow* parent = gtk_widget_get_parent_window(widget);
                gdk_window_invalidate_rect(parent, &widget->allocation, false);
                gdk_window_invalidate_rect(parent, alloc, false);
            }
        }
    }

    widget->allocation = *alloc;

    // adjust child positions
    for (const GList* list = pizza->m_fixed.children; list; list = list->next)
    {
        const GtkFixedChild* child = static_cast<GtkFixedChild*>(list->data);
        if (gtk_widget_get_visible(child->widget))
        {
            GtkAllocation child_alloc;
            // note that child positions do not take border into
            // account, they need to be relative to widget->window,
            // which has already been adjusted
            child_alloc.x = child->x - pizza->m_scroll_x;
            child_alloc.y = child->y - pizza->m_scroll_y;
            GtkRequisition req;
            gtk_widget_get_child_requisition(child->widget, &req);
            child_alloc.width  = req.width;
            child_alloc.height = req.height;
            if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
                child_alloc.x = w - child_alloc.x - child_alloc.width;
            gtk_widget_size_allocate(child->widget, &child_alloc);
        }
    }
}
Esempio n. 12
0
static void pizza_size_allocate(GtkWidget* widget, GtkAllocation* alloc)
{
    wxPizza* pizza = WX_PIZZA(widget);
    GtkBorder border;
    pizza->get_border(border);
    int w = alloc->width - border.left - border.right;
    if (w < 0) w = 0;

    if (gtk_widget_get_realized(widget))
    {
        int h = alloc->height - border.top - border.bottom;
        if (h < 0) h = 0;
        const int x = alloc->x + border.left;
        const int y = alloc->y + border.top;

        GdkWindow* window = gtk_widget_get_window(widget);
        int old_x, old_y;
        gdk_window_get_position(window, &old_x, &old_y);

        if (x != old_x || y != old_y ||
            w != gdk_window_get_width(window) || h != gdk_window_get_height(window))
        {
            gdk_window_move_resize(window, x, y, w, h);

            if (border.left + border.right + border.top + border.bottom)
            {
                // old and new border areas need to be invalidated,
                // otherwise they will not be erased/redrawn properly
                GtkAllocation old_alloc;
                gtk_widget_get_allocation(widget, &old_alloc);
                GdkWindow* parent = gtk_widget_get_parent_window(widget);
                gdk_window_invalidate_rect(parent, &old_alloc, false);
                gdk_window_invalidate_rect(parent, alloc, false);
            }
        }
    }

    gtk_widget_set_allocation(widget, alloc);

    // adjust child positions
    for (const GList* p = pizza->m_children; p; p = p->next)
    {
        const wxPizzaChild* child = static_cast<wxPizzaChild*>(p->data);
        if (gtk_widget_get_visible(child->widget))
        {
            GtkAllocation child_alloc;
            // note that child positions do not take border into
            // account, they need to be relative to widget->window,
            // which has already been adjusted
            child_alloc.x = child->x - pizza->m_scroll_x;
            child_alloc.y = child->y - pizza->m_scroll_y;
            child_alloc.width  = child->width;
            child_alloc.height = child->height;
            if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
                child_alloc.x = w - child_alloc.x - child_alloc.width;
            gtk_widget_size_allocate(child->widget, &child_alloc);
        }
    }
}
Esempio n. 13
0
static gboolean
cb_panel_size_allocate(GtkWidget *widget, GtkAllocation *size, GkrellmPanel *p)
	{
	gdk_window_get_position(p->drawing_area->window, NULL, &p->y_mapped);
	if (_GK.frame_left_panel_overlap > 0 || _GK.frame_right_panel_overlap > 0)
		_GK.need_frame_packing = TRUE;
	return FALSE;
	}
Esempio n. 14
0
static gboolean
is_in_viewport (GtkWindow    *window,
		GdkScreen    *screen,
		gint          workspace,
		gint          viewport_x,
		gint          viewport_y)
{
	GdkScreen *s;
	GdkDisplay *display;
	GdkWindow *gdkwindow;
	const gchar *cur_name;
	const gchar *name;
	gint cur_n;
	gint n;
	gint ws;
	gint sc_width, sc_height;
	gint x, y, width, height;
	gint vp_x, vp_y;

	/* Check for screen and display match */
	display = gdk_screen_get_display (screen);
	cur_name = gdk_display_get_name (display);
	cur_n = gdk_screen_get_number (screen);

	s = gtk_window_get_screen (window);
	display = gdk_screen_get_display (s);
	name = gdk_display_get_name (display);
	n = gdk_screen_get_number (s);

	if (strcmp (cur_name, name) != 0 || cur_n != n)
	{
		return FALSE;
	}

	/* Check for workspace match */
	ws = gedit_utils_get_window_workspace (window);
	if (ws != workspace && ws != GEDIT_ALL_WORKSPACES)
	{
		return FALSE;
	}

	/* Check for viewport match */
	gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
	gdk_window_get_position (gdkwindow, &x, &y);
	width = gdk_window_get_width (gdkwindow);
	height = gdk_window_get_height (gdkwindow);
	gedit_utils_get_current_viewport (screen, &vp_x, &vp_y);
	x += vp_x;
	y += vp_y;

	sc_width = gdk_screen_get_width (screen);
	sc_height = gdk_screen_get_height (screen);

	return x + width * .25 >= viewport_x &&
	       x + width * .75 <= viewport_x + sc_width &&
	       y >= viewport_y &&
	       y + height <= viewport_y + sc_height;
}
Esempio n. 15
0
static void
nsp_window_main_menu_position (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
{
	GtkWidget *button = GTK_WIDGET(user_data);
	GdkWindow *window = gtk_widget_get_window(button);
	
	gdk_window_get_position(window, x, y);
	
	*x += 1;
	*y += button->allocation.height;
}
Esempio n. 16
0
File: ml_gdk.c Progetto: CRogers/obc
CAMLprim value ml_gdk_window_get_position (value window)
{
  int x, y;
  value ret;

  gdk_window_get_position (GdkWindow_val(window), &x, &y);
  
  ret = alloc_small (2,0);
  Field(ret,0) = Val_int(x);
  Field(ret,1) = Val_int(y);
  return ret;
}
Esempio n. 17
0
static void menu_pos( GtkMenu* menu, int* x, int* y, gboolean *push_in, GtkWidget* btn )
{
    GtkAllocation allocation;

    /* FIXME: I'm not sure if this work well in different WMs */
    gdk_window_get_position( gtk_widget_get_window( btn ), x, y);
/*    gdk_window_get_root_origin( btn->window, x, y); */
    gtk_widget_get_allocation ( GTK_WIDGET( btn ), &allocation );
    *x += allocation.x;
    *y += allocation.y + allocation.height;
    *push_in = FALSE;
}
Esempio n. 18
0
static gboolean
cb_treeview_motion (GtkWidget *widget,
		    GdkEventMotion *event,
		    StfDialogData *pagedata)
{
	int x = (int)event->x;
	int col, dx;
	RenderData_t *renderdata = pagedata->fixed.renderdata;
	int old_ruler_x = pagedata->fixed.ruler_x;
	int colstart, colend, colwidth;
	gpointer user;

	pagedata->fixed.ruler_x = -1;

	/* We get events from the buttons too.  Translate x.  */
	gdk_window_get_user_data (event->window, &user);
	if (GTK_IS_BUTTON (user)) {
		int ewx;
		gdk_window_get_position (event->window, &ewx, NULL);
		x += ewx;
	}

	stf_preview_find_column (renderdata, x, &col, &dx);

	colstart = (col == 0)
		? 0
		: stf_parse_options_fixed_splitpositions_nth (pagedata->parseoptions, col - 1);
	colend = stf_parse_options_fixed_splitpositions_nth (pagedata->parseoptions, col);
	colwidth = (colend == -1) ? G_MAXINT : colend - colstart;

	if (col >= 0 && col < renderdata->colcount) {
		int ci = calc_char_index (renderdata, col, &dx);
		if (ci <= colwidth) {
			int padx;
			GtkCellRenderer *cell =
				stf_preview_get_cell_renderer (renderdata, col);

			gtk_cell_renderer_get_padding (cell, &padx, NULL);
			pagedata->fixed.ruler_x = x - dx + padx;
		}
	}

	gdk_event_request_motions (event);

	if (pagedata->fixed.ruler_x == old_ruler_x)
		return FALSE;

	queue_redraw (widget, old_ruler_x);
	queue_redraw (widget, pagedata->fixed.ruler_x);

	return FALSE;
}
Esempio n. 19
0
/*
 *-------------------------------------------------------------------
 * window
 *-------------------------------------------------------------------
 */
static void collection_window_get_geometry(CollectWindow *cw)
{
	CollectionData *cd;
	GdkWindow *window;

	if (!cw) return;

	cd = cw->cd;
	window = gtk_widget_get_window(cw->window);
	gdk_window_get_position(window, &cd->window_x, &cd->window_y);
	cd->window_w = gdk_window_get_width(window);
	cd->window_h = gdk_window_get_height(window);
	cd->window_read = TRUE;
}
Esempio n. 20
0
static gboolean
gnc_header_draw (GtkWidget *header, cairo_t *cr)
{
    GnucashSheet *sheet = GNC_HEADER(header)->sheet;
    GdkWindow *sheet_layout_win = gtk_layout_get_bin_window (GTK_LAYOUT(sheet));
    gint x, y;

    // use this to get the scroll x value to align the header
    gdk_window_get_position (sheet_layout_win, &x, &y);

    cairo_set_source_surface (cr, GNC_HEADER(header)->surface, x, 0);
    cairo_paint (cr);

    return TRUE;
}
Esempio n. 21
0
GtkWidget* get_child_at_pos(GtkWidget* container, gfloat x, gfloat y)
{
	GList *children = gtk_container_get_children(GTK_CONTAINER(container));
	int len = g_list_length(children);
	int i;
	for(i =0; i < len; i++)
	{
		gint px, py, width, height;
		GdkWindow *w = gtk_widget_get_window(g_list_nth_data(children, i));
		gdk_window_get_position(w, &px, &py);
		gtk_widget_get_size_request(w, &width, &height);
		if(x >= px && x <= px + width && y >= py && y <= py + height)
			return w;
	}
	return NULL;
}
static gboolean
popup_button_press(GtkWidget         *popup,
		   GdkEventButton    *event,
		   GebrGuiToolButton *button)
{
	GdkWindow *window = gtk_widget_get_window(popup);
	gint xroot, yroot, width, height;
	gdk_window_get_position(window, &xroot, &yroot);
	gdk_drawable_get_size(GDK_DRAWABLE(window), &width, &height);

	if (event->x_root < xroot || event->x_root > xroot + width
	    || event->y_root < yroot || event->y_root > yroot + height)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);

	return TRUE;
}
/**
 * eel_gdk_window_get_bounds:
 * @gdk_window: The source GdkWindow.
 *
 * Return value: An EelIRect representation of the given GdkWindow's geometry
 * relative to its parent in the Gdk window hierarchy.
 *
 */
EelIRect
eel_gdk_window_get_bounds (GdkWindow *gdk_window)
{
	EelIRect bounds;
	int width;
	int height;

	g_return_val_if_fail (gdk_window != NULL, eel_irect_empty);

	gdk_window_get_position (gdk_window, &bounds.x0, &bounds.y0);
	gdk_drawable_get_size (gdk_window, &width, &height);

	bounds.x1 = bounds.x0 + width;
	bounds.y1 = bounds.y0 + height;

	return bounds;
}
Esempio n. 24
0
/* 
	This function exists because GDK retrieves client coordinates, not window ones.
	(Kevin: GDK uses GetClientRect and ClientToScreen).
	We need that to save and restore windows position.
*/
void window_get_rect(GtkWidget *widget, GdkRect *rect)
{
	gtk_window_get_size(GTK_WINDOW(widget), &rect->w, &rect->h);
	gdk_window_get_position(widget->window, &rect->x, &rect->y);

#ifdef __WIN32__
	{
		BOOL bResult;
		HWND hWnd = GDK_WINDOW_HWND(widget->window);
		RECT lpRect;

		bResult = GetWindowRect(hWnd, &lpRect);

		rect->x = lpRect.left;
		rect->y = lpRect.top;
	}
#endif
}
Esempio n. 25
0
static gboolean
overlay_enter_notify_cb (GtkWidget        *parent,
                         GdkEventCrossing *event,
                         gpointer          user_data)
{
    GtkWidget *widget = user_data;
    CheckPointerData *data;
    gint y_pos;

    NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);

    if (self->hover_timeout_id != 0)
    {
        g_source_remove (self->hover_timeout_id);
    }

    if (event->window != gtk_widget_get_window (widget))
    {
        return GDK_EVENT_PROPAGATE;
    }

    if (NAUTILUS_FLOATING_BAR (widget)->is_interactive)
    {
        return GDK_EVENT_PROPAGATE;
    }

    gdk_window_get_position (gtk_widget_get_window (widget), NULL, &y_pos);

    data = g_slice_new (CheckPointerData);
    data->overlay = parent;
    data->floating_bar = widget;
    data->device = gdk_event_get_device ((GdkEvent *) event);
    data->y_down_limit = y_pos;
    data->y_upper_limit = y_pos + gtk_widget_get_allocated_height (widget);

    self->hover_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT, HOVER_HIDE_TIMEOUT_INTERVAL,
                                                 check_pointer_timeout, data,
                                                 check_pointer_data_free);

    g_source_set_name_by_id (self->hover_timeout_id, "[nautilus-floating-bar] overlay_enter_notify_cb");

    return GDK_EVENT_STOP;
}
Esempio n. 26
0
static void
save_window (GString *s,
             GdkWindow *window)
{
    gint x, y;
    GdkColor *color;

    gdk_window_get_position (window, &x, &y);
    color = g_object_get_data (G_OBJECT (window), "color");

    g_string_append_printf (s, "%d,%d %dx%d (%d,%d,%d) %d %d\n",
                            x, y,
                            gdk_window_get_width (window),
                            gdk_window_get_height (window),
                            color->red, color->green, color->blue,
                            gdk_window_has_native (window),
                            g_list_length (gdk_window_peek_children (window)));

    save_children (s, window);
}
Esempio n. 27
0
static void
move_window_clicked (GtkWidget *button,
                     gpointer data)
{
    GdkWindow *window;
    GtkDirectionType direction;
    GList *selected, *l;
    gint x, y;

    direction = GPOINTER_TO_INT (data);

    selected = get_selected_windows ();

    for (l = selected; l != NULL; l = l->next)
    {
        window = l->data;

        gdk_window_get_position (window, &x, &y);

        switch (direction) {
        case GTK_DIR_UP:
            y -= 10;
            break;
        case GTK_DIR_DOWN:
            y += 10;
            break;
        case GTK_DIR_LEFT:
            x -= 10;
            break;
        case GTK_DIR_RIGHT:
            x += 10;
            break;
        default:
            break;
        }

        gdk_window_move (window, x, y);
    }

    g_list_free (selected);
}
JNIEXPORT void JNICALL 
Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreenUnlocked
  (JNIEnv * env, jobject obj, jintArray jpoint)
{
  void *ptr;
  jint *point;
  GtkWidget *widget;

  ptr = gtkpeer_get_widget (env, obj);
  point = (*env)->GetIntArrayElements (env, jpoint, 0);

  widget = get_widget(GTK_WIDGET (ptr));
  while(gtk_widget_get_parent(widget) != NULL)
    widget = gtk_widget_get_parent(widget);
  gdk_window_get_position (GTK_WIDGET(widget)->window, point, point+1);

  *point += GTK_WIDGET(ptr)->allocation.x;
  *(point+1) += GTK_WIDGET(ptr)->allocation.y;

  (*env)->ReleaseIntArrayElements(env, jpoint, point, 0);
}
Esempio n. 29
0
JNIEXPORT void JNICALL
Java_org_gnome_gdk_GdkWindow_gdk_1window_1get_1position
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jintArray _x,
	jintArray _y
)
{
	GdkWindow* self;
	gint* x;
	gint* y;

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

	// convert parameter x
	x = (gint*) (*env)->GetIntArrayElements(env, _x, NULL);
	if (x == NULL) {
		return; // Java Exception already thrown
	}

	// convert parameter y
	y = (gint*) (*env)->GetIntArrayElements(env, _y, NULL);
	if (y == NULL) {
		return; // Java Exception already thrown
	}

	// call function
	gdk_window_get_position(self, x, y);

	// cleanup parameter self

	// cleanup parameter x
	(*env)->ReleaseIntArrayElements(env, _x, (jint*)x, 0);

	// cleanup parameter y
	(*env)->ReleaseIntArrayElements(env, _y, (jint*)y, 0);
}
Esempio n. 30
-5
Rect Ctrl::GetWndScreenRect() const
{
	GuiLock __;
	if(IsOpen()) {
		gint x, y;
		gdk_window_get_position(gdk(), &x, &y);
	#if GTK_CHECK_VERSION(2, 24, 0)
		gint width = gdk_window_get_width(gdk());
		gint height = gdk_window_get_height(gdk());
	#else
		gint width, height;
		gdk_drawable_get_size(gdk(), &width, &height);
	#endif
		return RectC(x, y, width, height);
	}
	return Null;
}