示例#1
0
文件: gtklayout.c 项目: Aridna/gtk2
/**
 * gtk_layout_freeze:
 * @layout: a #GtkLayout
 * 
 * This is a deprecated function, it doesn't do anything useful.
 **/
void
gtk_layout_freeze (GtkLayout *layout)
{
  g_return_if_fail (GTK_IS_LAYOUT (layout));

  layout->freeze_count++;
}
示例#2
0
void
gnucash_cursor_configure (GnucashCursor *cursor)
{
    gint x = 0, y = 0, w = 0, h = 0;

    g_return_if_fail (cursor != NULL);
    g_return_if_fail (GNUCASH_IS_CURSOR (cursor));

    if (!cursor->sheet)
        return;

    g_return_if_fail (GTK_IS_LAYOUT (cursor->sheet));

    gnucash_cursor_get_pixel_coords (cursor, &x, &y, &w, &h);
    cursor->x = x;
    cursor->y = y;
    cursor->w = w;
    cursor->h = h + 2;

    gnucash_sheet_style_get_cell_pixel_rel_coords (cursor->style,
            cursor->cell.row,  cursor->cell.col,
            &x, &y, &w, &h);
    cursor->cell.x = x;
    cursor->cell.y = y;
    cursor->cell.w = w;
    cursor->cell.h = h;
}
示例#3
0
/**
 * gtk_layout_get_bin_window:
 * @layout: a #GtkLayout
 *
 * Retrieve the bin window of the layout used for drawing operations.
 *
 * Returns: (transfer none): a #GdkWindow
 *
 * Since: 2.14
 **/
GdkWindow*
gtk_layout_get_bin_window (GtkLayout *layout)
{
  g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);

  return layout->priv->bin_window;
}
示例#4
0
/**
 * gtk_layout_put:
 * @layout: a #GtkLayout
 * @child_widget: child widget
 * @x: X position of child widget
 * @y: Y position of child widget
 *
 * Adds @child_widget to @layout, at position (@x,@y).
 * @layout becomes the new parent container of @child_widget.
 * 
 **/
void           
gtk_layout_put (GtkLayout     *layout, 
		GtkWidget     *child_widget, 
		gint           x, 
		gint           y)
{
  GtkLayoutPrivate *priv;
  GtkLayoutChild *child;

  g_return_if_fail (GTK_IS_LAYOUT (layout));
  g_return_if_fail (GTK_IS_WIDGET (child_widget));

  priv = layout->priv;

  child = g_new (GtkLayoutChild, 1);

  child->widget = child_widget;
  child->x = x;
  child->y = y;

  priv->children = g_list_append (priv->children, child);

  if (gtk_widget_get_realized (GTK_WIDGET (layout)))
    gtk_widget_set_parent_window (child->widget, priv->bin_window);

  gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
}
示例#5
0
/**
 * gtk_layout_get_vadjustment:
 * @layout: a #GtkLayout
 *
 * This function should only be called after the layout has been
 * placed in a #GtkScrolledWindow or otherwise configured for
 * scrolling. It returns the #GtkAdjustment used for communication
 * between the vertical scrollbar and @layout.
 *
 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
 *
 * Returns: (transfer none): vertical scroll adjustment
 *
 * Deprecated: 3.0: Use gtk_scrollable_get_vadjustment()
 **/
GtkAdjustment*
gtk_layout_get_vadjustment (GtkLayout *layout)
{
  g_return_val_if_fail (GTK_IS_LAYOUT (layout), NULL);

  return layout->priv->vadjustment;
}
示例#6
0
/**
 * gtk_layout_set_vadjustment:
 * @layout: a #GtkLayout
 * @adjustment: (allow-none): new scroll adjustment
 *
 * Sets the vertical scroll adjustment for the layout.
 *
 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
 *
 * Deprecated: 3.0: Use gtk_scrollable_set_vadjustment()
 **/
void
gtk_layout_set_vadjustment (GtkLayout     *layout,
                            GtkAdjustment *adjustment)
{
  g_return_if_fail (GTK_IS_LAYOUT (layout));
  g_return_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment));

  gtk_layout_do_set_vadjustment (layout, adjustment);
}
示例#7
0
文件: gtklayout.c 项目: Aridna/gtk2
/**
 * gtk_layout_set_vadjustment:
 * @layout: a #GtkLayout
 * @adjustment: (allow-none): new scroll adjustment
 *
 * Sets the vertical scroll adjustment for the layout.
 *
 * See #GtkScrolledWindow, #GtkScrollbar, #GtkAdjustment for details.
 * 
 **/
void           
gtk_layout_set_vadjustment (GtkLayout     *layout,
			    GtkAdjustment *adjustment)
{
  g_return_if_fail (GTK_IS_LAYOUT (layout));
  
  gtk_layout_set_adjustments (layout, layout->hadjustment, adjustment);
  g_object_notify (G_OBJECT (layout), "vadjustment");
}
bool C4Window::ReInit(C4AbstractApp* pApp)
{
	// Check whether multisampling settings was changed. If not then we
	// don't need to ReInit anything.
#ifdef GDK_WINDOWING_X11
	int value;
	Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default());
	glXGetFBConfigAttrib(dpy, Info, GLX_SAMPLES, &value);
	if(value == Config.Graphics.MultiSampling) return true;

	// Check whether we have a visual with the requested number of samples
	GLXFBConfig new_info;
	if(!FindFBConfig(Config.Graphics.MultiSampling, &new_info)) return false;

	GdkScreen * scr = gtk_widget_get_screen(GTK_WIDGET(render_widget));
	XVisualInfo *vis_info = glXGetVisualFromFBConfig(dpy, new_info);
	assert(vis_info);
	GdkVisual * vis = gdk_x11_screen_lookup_visual(scr, vis_info->visualid);
	XFree(vis_info);

	// Un- and re-realizing the render_widget does not work, the window
	// remains hidden afterwards. So we re-create it from scratch.
	gtk_widget_destroy(GTK_WIDGET(render_widget));
	render_widget = gtk_drawing_area_new();
#if !GTK_CHECK_VERSION(3,10,0)
	gtk_widget_set_double_buffered (GTK_WIDGET(render_widget), false);
#endif
	g_object_set(G_OBJECT(render_widget), "can-focus", TRUE, NULL);
	
	gtk_widget_set_visual(GTK_WIDGET(render_widget),vis);

	Info = new_info;

	// Wait until window is mapped to get the window's XID
	gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(render_widget));
	gtk_widget_show_now(GTK_WIDGET(render_widget));

	if (GTK_IS_LAYOUT(render_widget))
	{
		GdkWindow* bin_wnd = gtk_layout_get_bin_window(GTK_LAYOUT(render_widget));
		renderwnd = GDK_WINDOW_XID(bin_wnd);
	}
	else
	{
		GdkWindow* render_wnd = gtk_widget_get_window(GTK_WIDGET(render_widget));
		renderwnd = GDK_WINDOW_XID(render_wnd);
	}

	gdk_flush();
	gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(render_widget)),
	                      gdk_cursor_new_for_display(gdk_display_get_default(), GDK_BLANK_CURSOR));
	return true;
#endif
}
示例#9
0
/**
 * gtk_layout_move:
 * @layout: a #GtkLayout
 * @child_widget: a current child of @layout
 * @x: X position to move to
 * @y: Y position to move to
 *
 * Moves a current child of @layout to a new position.
 * 
 **/
void           
gtk_layout_move (GtkLayout     *layout, 
		 GtkWidget     *child_widget, 
		 gint           x, 
		 gint           y)
{
  g_return_if_fail (GTK_IS_LAYOUT (layout));
  g_return_if_fail (GTK_IS_WIDGET (child_widget));
  g_return_if_fail (gtk_widget_get_parent (child_widget) == GTK_WIDGET (layout));

  gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y);
}
示例#10
0
文件: gtklayout.c 项目: Aridna/gtk2
/**
 * gtk_layout_get_size:
 * @layout: a #GtkLayout
 * @width: (allow-none): location to store the width set on @layout, or %NULL
 * @height: (allow-none): location to store the height set on @layout, or %NULL
 *
 * Gets the size that has been set on the layout, and that determines
 * the total extents of the layout's scrollbar area. See
 * gtk_layout_set_size ().
 **/
void
gtk_layout_get_size (GtkLayout *layout,
		     guint     *width,
		     guint     *height)
{
  g_return_if_fail (GTK_IS_LAYOUT (layout));

  if (width)
    *width = layout->width;
  if (height)
    *height = layout->height;
}
示例#11
0
文件: gtklayout.c 项目: Aridna/gtk2
/**
 * gtk_layout_thaw:
 * @layout: a #GtkLayout
 * 
 * This is a deprecated function, it doesn't do anything useful.
 **/
void
gtk_layout_thaw (GtkLayout *layout)
{
  g_return_if_fail (GTK_IS_LAYOUT (layout));

  if (layout->freeze_count)
    {
      if (!(--layout->freeze_count))
	{
	  gtk_widget_queue_draw (GTK_WIDGET (layout));
	  gdk_window_process_updates (GTK_WIDGET (layout)->window, TRUE);
	}
    }

}
示例#12
0
/**
 * gtk_layout_get_size:
 * @layout: a #GtkLayout
 * @width: (out) (allow-none): location to store the width set on
 *     @layout, or %NULL
 * @height: (out) (allow-none): location to store the height set on
 *     @layout, or %NULL
 *
 * Gets the size that has been set on the layout, and that determines
 * the total extents of the layout’s scrollbar area. See
 * gtk_layout_set_size ().
 **/
void
gtk_layout_get_size (GtkLayout *layout,
		     guint     *width,
		     guint     *height)
{
  GtkLayoutPrivate *priv;

  g_return_if_fail (GTK_IS_LAYOUT (layout));

  priv = layout->priv;

  if (width)
    *width = priv->width;
  if (height)
    *height = priv->height;
}
示例#13
0
/**
 * gtk_layout_set_size:
 * @layout: a #GtkLayout
 * @width: width of entire scrollable area
 * @height: height of entire scrollable area
 *
 * Sets the size of the scrollable area of the layout.
 * 
 **/
void
gtk_layout_set_size (GtkLayout     *layout, 
		     guint          width,
		     guint          height)
{
  GtkLayoutPrivate *priv;
  GtkWidget *widget;

  g_return_if_fail (GTK_IS_LAYOUT (layout));

  priv = layout->priv;
  widget = GTK_WIDGET (layout);

  g_object_freeze_notify (G_OBJECT (layout));
  if (width != priv->width)
     {
	priv->width = width;
	g_object_notify (G_OBJECT (layout), "width");
     }
  if (height != priv->height)
     {
	priv->height = height;
	g_object_notify (G_OBJECT (layout), "height");
     }
  g_object_thaw_notify (G_OBJECT (layout));

  if (gtk_widget_get_realized (widget))
    {
      GtkAllocation allocation;

      gtk_widget_get_allocation (widget, &allocation);
      width = MAX (width, allocation.width);
      height = MAX (height, allocation.height);
      gdk_window_resize (priv->bin_window, width, height);
    }

  gtk_layout_set_hadjustment_values (layout);
  gtk_layout_set_vadjustment_values (layout);
}
示例#14
0
文件: gtklayout.c 项目: Aridna/gtk2
/**
 * gtk_layout_set_size:
 * @layout: a #GtkLayout
 * @width: width of entire scrollable area
 * @height: height of entire scrollable area
 *
 * Sets the size of the scrollable area of the layout.
 * 
 **/
void
gtk_layout_set_size (GtkLayout     *layout, 
		     guint          width,
		     guint          height)
{
  GtkWidget *widget;
  
  g_return_if_fail (GTK_IS_LAYOUT (layout));
  
  widget = GTK_WIDGET (layout);
  
  g_object_freeze_notify (G_OBJECT (layout));
  if (width != layout->width)
     {
	layout->width = width;
	g_object_notify (G_OBJECT (layout), "width");
     }
  if (height != layout->height)
     {
	layout->height = height;
	g_object_notify (G_OBJECT (layout), "height");
     }
  g_object_thaw_notify (G_OBJECT (layout));

  if (layout->hadjustment)
    gtk_layout_set_adjustment_upper (layout->hadjustment, layout->width, FALSE);
  if (layout->vadjustment)
    gtk_layout_set_adjustment_upper (layout->vadjustment, layout->height, FALSE);

  if (gtk_widget_get_realized (widget))
    {
      width = MAX (width, widget->allocation.width);
      height = MAX (height, widget->allocation.height);
      gdk_window_resize (layout->bin_window, width, height);
    }
}
static void 
grab_current_drawable (GtkWidget *widget, GdkDrawable **draw, GdkWindow **win)
{  
  g_assert (widget != NULL);
  g_assert (draw != NULL);
  g_assert (win != NULL);

  if (GTK_IS_WINDOW (widget))
    {
      *win = find_gtk_layout (widget)->bin_window;
    }
  else if (GTK_IS_LAYOUT (widget))
    {
      *win = GTK_LAYOUT (widget)->bin_window;
    }
  else
    {
      *win = widget->window;
    }

  *draw = *win;
  gdk_window_get_internal_paint_info (*win, draw, 0, 0);
  g_object_ref (*draw);
}
示例#16
0
BalsaMimeWidget *
balsa_mime_widget_new(BalsaMessage * bm, LibBalsaMessageBody * mime_body, gpointer data)
{
    BalsaMimeWidget *mw = NULL;
    gchar *content_type;
    mime_delegate_t *delegate;

    g_return_val_if_fail(bm != NULL, NULL);
    g_return_val_if_fail(mime_body != NULL, NULL);

    /* determine the content type of the passed MIME body */
    content_type = libbalsa_message_body_get_mime_type(mime_body);
    delegate = mime_delegate;
    while (delegate->handler &&
	   ((delegate->wildcard &&
	     g_ascii_strncasecmp(delegate->mime_type, content_type,
				 strlen(delegate->mime_type))) ||
	    (!delegate->wildcard &&
	     g_ascii_strcasecmp(delegate->mime_type, content_type))))
	delegate++;

    if (delegate->handler)
	mw = (delegate->handler) (bm, mime_body, content_type, data);
    /* fall back to default if no handler is present */
    if (!mw)
	mw = balsa_mime_widget_new_unknown(bm, mime_body, content_type);

    if (mw) {
	if (mw->widget) {
	    g_signal_connect(G_OBJECT(mw->widget), "focus_in_event",
			     G_CALLBACK(balsa_mime_widget_limit_focus),
			     (gpointer) bm);
	    g_signal_connect(G_OBJECT(mw->widget), "focus_out_event",
			     G_CALLBACK(balsa_mime_widget_unlimit_focus),
			     (gpointer) bm);
#ifdef HAVE_GPGME
	    if (mime_body->sig_info &&
		g_ascii_strcasecmp("application/pgp-signature", content_type) &&
		g_ascii_strcasecmp("application/pkcs7-signature", content_type) &&
		g_ascii_strcasecmp("application/x-pkcs7-signature", content_type)) {
		GtkWidget * signature =
		    balsa_mime_widget_signature_widget(mime_body, content_type);
		mw->widget = balsa_mime_widget_crypto_frame(mime_body, mw->widget,
							    mime_body->was_encrypted,
							    FALSE, signature);
	    } else if (mime_body->was_encrypted &&
		       g_ascii_strcasecmp("multipart/signed", content_type)) {
		mw->widget = balsa_mime_widget_crypto_frame(mime_body, mw->widget,
							    TRUE, TRUE, NULL);
	    }
#endif
            g_object_ref_sink(mw->widget);

	    if (GTK_IS_LAYOUT(mw->widget)) {
                GtkAdjustment *vadj;

                g_object_get(G_OBJECT(mw->widget), "vadjustment", &vadj,
                             NULL);
		g_signal_connect(vadj, "changed",
				 G_CALLBACK(vadj_change_cb), mw->widget);
            }

            gtk_widget_show_all(mw->widget);
	}
    }
    g_free(content_type);

    return mw;
}
示例#17
0
文件: gtklayout.c 项目: Aridna/gtk2
static void           
gtk_layout_set_adjustments (GtkLayout     *layout,
			    GtkAdjustment *hadj,
			    GtkAdjustment *vadj)
{
  gboolean need_adjust = FALSE;

  g_return_if_fail (GTK_IS_LAYOUT (layout));

  if (hadj)
    g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
  else if (layout->hadjustment)
    hadj = new_default_adjustment ();
  if (vadj)
    g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
  else if (layout->vadjustment)
    vadj = new_default_adjustment ();
  
  if (layout->hadjustment && (layout->hadjustment != hadj))
    {
      g_signal_handlers_disconnect_by_func (layout->hadjustment,
					    gtk_layout_adjustment_changed,
					    layout);
      g_object_unref (layout->hadjustment);
    }
  
  if (layout->vadjustment && (layout->vadjustment != vadj))
    {
      g_signal_handlers_disconnect_by_func (layout->vadjustment,
					    gtk_layout_adjustment_changed,
					    layout);
      g_object_unref (layout->vadjustment);
    }
  
  if (layout->hadjustment != hadj)
    {
      layout->hadjustment = hadj;
      g_object_ref_sink (layout->hadjustment);
      gtk_layout_set_adjustment_upper (layout->hadjustment, layout->width, FALSE);
      
      g_signal_connect (layout->hadjustment, "value-changed",
			G_CALLBACK (gtk_layout_adjustment_changed),
			layout);
      need_adjust = TRUE;
    }
  
  if (layout->vadjustment != vadj)
    {
      layout->vadjustment = vadj;
      g_object_ref_sink (layout->vadjustment);
      gtk_layout_set_adjustment_upper (layout->vadjustment, layout->height, FALSE);
      
      g_signal_connect (layout->vadjustment, "value-changed",
			G_CALLBACK (gtk_layout_adjustment_changed),
			layout);
      need_adjust = TRUE;
    }

  /* vadj or hadj can be NULL while constructing; don't emit a signal
     then */
  if (need_adjust && vadj && hadj)
    gtk_layout_adjustment_changed (NULL, layout);
}
C4Window* C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const char * Title, const C4Rect * size)
{
	Active = true;
#ifdef GDK_WINDOWING_X11
	if(!FindFBConfig(Config.Graphics.MultiSampling, &Info))
	{
		// Disable multisampling if we don't find a visual which
		// supports the currently configured setting.
		if(!FindFBConfig(0, &Info)) return NULL;
		Config.Graphics.MultiSampling = 0;
	}
#endif

	assert(!window);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	if (windowKind == W_Viewport)
	{
		C4ViewportWindow * vw = static_cast<C4ViewportWindow *>(this);

		// Cannot just use ScrolledWindow because this would just move
		// the GdkWindow of the DrawingArea.
		GtkWidget* table = gtk_grid_new();
		render_widget = gtk_drawing_area_new();
		gtk_widget_set_hexpand(GTK_WIDGET(render_widget), true);
		gtk_widget_set_vexpand(GTK_WIDGET(render_widget), true);
		gtk_grid_attach(GTK_GRID(table), GTK_WIDGET(render_widget), 0, 0, 1, 1);
		vw->h_scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, NULL);
		gtk_grid_attach(GTK_GRID(table), vw->h_scrollbar, 0, 1, 1, 1);
		vw->v_scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, NULL);
		gtk_grid_attach(GTK_GRID(table), vw->v_scrollbar, 1, 0, 1, 1);

		GtkAdjustment* adjustment = gtk_range_get_adjustment(GTK_RANGE(vw->h_scrollbar));

		g_signal_connect(
		  G_OBJECT(adjustment),
		  "value-changed",
		  G_CALLBACK(OnHScrollStatic),
		  this
		);

		adjustment = gtk_range_get_adjustment(GTK_RANGE(vw->v_scrollbar));

		g_signal_connect(
		  G_OBJECT(adjustment),
		  "value-changed",
		  G_CALLBACK(OnVScrollStatic),
		  this
		);

		gtk_container_add(GTK_CONTAINER(window), table);

		gtk_widget_add_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK | GDK_POINTER_MOTION_MASK);

		gtk_drag_dest_set(GTK_WIDGET(render_widget), GTK_DEST_DEFAULT_ALL, drag_drop_entries, 1, GDK_ACTION_COPY);
		g_signal_connect(G_OBJECT(render_widget), "drag-data-received", G_CALLBACK(OnDragDataReceivedStatic), this);
		g_signal_connect(G_OBJECT(render_widget), "draw", G_CALLBACK(OnExposeStatic), this);
		g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(OnKeyPressStatic), this);
		g_signal_connect(G_OBJECT(window), "key-release-event", G_CALLBACK(OnKeyReleaseStatic), this);
		g_signal_connect(G_OBJECT(window), "scroll-event", G_CALLBACK(OnScrollVW), this);
		g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(OnButtonPressStatic), this);
		g_signal_connect(G_OBJECT(window), "button-release-event", G_CALLBACK(OnButtonReleaseStatic), this);
		g_signal_connect(G_OBJECT(window), "motion-notify-event", G_CALLBACK(OnMotionNotifyStatic), this);
		g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(OnKeyPress), this);
		g_signal_connect(G_OBJECT(window), "key-release-event", G_CALLBACK(OnKeyRelease), this);
		g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(OnConfigureStatic), this);
		g_signal_connect(G_OBJECT(window), "realize", G_CALLBACK(OnRealizeStatic), this);

		g_signal_connect_after(G_OBJECT(render_widget), "configure-event", G_CALLBACK(OnConfigureDareaStatic), this);

#if !GTK_CHECK_VERSION(3,10,0)
		// do not draw the default background
		gtk_widget_set_double_buffered (GTK_WIDGET(render_widget), false);
#endif

		gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(Console.window));
#if !GTK_CHECK_VERSION(3,14,0)
		gtk_window_set_has_resize_grip(GTK_WINDOW(window), false);
#endif
	}
	else if (windowKind == W_Fullscreen)
	{
		render_widget = gtk_drawing_area_new();
		gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(render_widget));

		g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(OnConfigureNotify), this);
		g_signal_connect(G_OBJECT(window), "focus-in-event", G_CALLBACK(OnFocusInFS), this);
		g_signal_connect(G_OBJECT(window), "focus-out-event", G_CALLBACK(OnFocusOutFS), this);
		g_signal_connect(G_OBJECT(window), "unmap-event", G_CALLBACK(OnFocusOutFS), this);
		g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(OnButtonPressFS), this);
		g_signal_connect(G_OBJECT(window), "button-release-event", G_CALLBACK(OnButtonRelease), this);
		g_signal_connect(G_OBJECT(window), "motion-notify-event", G_CALLBACK(OnMotionNotify), this);
		g_signal_connect(G_OBJECT(window), "key-press-event", G_CALLBACK(OnKeyPress), this);
		g_signal_connect(G_OBJECT(window), "key-release-event", G_CALLBACK(OnKeyRelease), this);
		g_signal_connect(G_OBJECT(window), "scroll-event", G_CALLBACK(OnScroll), this);
		gtk_widget_add_events(GTK_WIDGET(window), GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
#if !GTK_CHECK_VERSION(3,10,0)
		gtk_widget_set_double_buffered (GTK_WIDGET(render_widget), false);
#endif

		GValue val = {0,{{0}}};
		g_value_init (&val, G_TYPE_BOOLEAN);
		g_value_set_boolean (&val, true);
		g_object_set_property (G_OBJECT (render_widget), "can-focus", &val);
		g_object_set_property (G_OBJECT (window), "can-focus", &val);
		g_value_unset (&val);
#if !GTK_CHECK_VERSION(3,14,0)
		gtk_window_set_has_resize_grip(GTK_WINDOW(window), false);
#endif
	}
	else if (windowKind == W_GuiWindow)
	{
		render_widget = window;
		g_signal_connect(G_OBJECT(window), "button-press-event", G_CALLBACK(OnButtonPressGD), this);
		g_signal_connect(G_OBJECT(window), "button-release-event", G_CALLBACK(OnButtonReleaseGD), this);
		g_signal_connect(G_OBJECT(window), "motion-notify-event", G_CALLBACK(OnMotionNotifyGD), this);
		g_signal_connect(G_OBJECT(window), "configure-event", G_CALLBACK(OnConfigureGD), this);
		g_signal_connect(G_OBJECT(window), "scroll-event", G_CALLBACK(OnScroll), this);

		gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(Console.window));
#if !GTK_CHECK_VERSION(3,14,0)
		gtk_window_set_has_resize_grip(GTK_WINDOW(window), false);
#endif
	}
	else if (windowKind == W_Console)
	{
		render_widget = window;
	}
	assert(window);
	assert(render_widget);
	// Override gtk's default to match name/class of the XLib windows
	gtk_window_set_wmclass(GTK_WINDOW(window), C4ENGINENAME, C4ENGINENAME);
	gtk_window_set_default_size(GTK_WINDOW(window), size->Wdt, size->Hgt);

	g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(OnDelete), this);
	handlerDestroy = g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(OnDestroyStatic), this);
	gtk_widget_add_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_SCROLL_MASK);

	// TODO: It would be nice to support GDK_SCROLL_SMOOTH_MASK and
	// smooth scrolling for scrolling in menus, however that should not
	// change the scroll wheel behaviour ingame for zooming or
	// inventory change. Note that when both GDK_SCROLL_MASK and
	// GDK_SMOOTH_SCROLL_MASK are enabled, both type of scroll events
	// are reported, so one needs to make sure to not double-process them.
	// It would be nice to have smooth scrolling also e.g. for zooming
	// ingame, but it probably requires the notion of smooth scrolling
	// other parts of the engine as well.
#ifdef GDK_WINDOWING_X11
	GdkScreen * scr = gtk_widget_get_screen(GTK_WIDGET(render_widget));
	Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default());
	XVisualInfo *vis_info = glXGetVisualFromFBConfig(dpy, Info);
	assert(vis_info);
	GdkVisual * vis = gdk_x11_screen_lookup_visual(scr, vis_info->visualid);
	XFree(vis_info);
	gtk_widget_set_visual(GTK_WIDGET(render_widget),vis);
#endif
	gtk_widget_show_all(GTK_WIDGET(window));

//  XVisualInfo vitmpl; int blub;
//  vitmpl.visual = gdk_x11_visual_get_xvisual(gtk_widget_get_visual(window));
//  vitmpl.visualid = XVisualIDFromVisual(vitmpl.visual);
//  Info = XGetVisualInfo(dpy, VisualIDMask, &vitmpl, &blub);

//  printf("%p\n", gtk_widget_get_visual(render_widget));
//  Info = gdk_x11_visual_get_xvisual(gtk_widget_get_visual(render_widget));

	// Default icon has been set right after gtk_init(),
	// so we don't need to take care about setting the icon here.

	SetTitle(Title);

	// Wait until window is mapped to get the window's XID
	gtk_widget_show_now(GTK_WIDGET(window));
	GdkWindow* render_gdk_wnd;
	if (GTK_IS_LAYOUT(render_widget))
		render_gdk_wnd = gtk_layout_get_bin_window(GTK_LAYOUT(render_widget));
	else
		render_gdk_wnd = gtk_widget_get_window(GTK_WIDGET(render_widget));

#ifdef GDK_WINDOWING_X11
	renderwnd = GDK_WINDOW_XID(render_gdk_wnd);
#elif defined(GDK_WINDOWING_WIN32)
	renderwnd = reinterpret_cast<HWND>(gdk_win32_window_get_handle(render_gdk_wnd));
#endif
	// Make sure the window is shown and ready to be rendered into,
	// this avoids an async X error.
	gdk_flush();

	if (windowKind == W_Fullscreen)
		gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(render_widget)),
		                      gdk_cursor_new_for_display(gdk_display_get_default(), GDK_BLANK_CURSOR));
	return this;
}