Ok, so this is really a pure Gtk issue. I know this isn't necessarily the proper mailing list, but if anyone has any clues, I'd really appreciate the help.
See below for test program to illustrate issue, just resize X-window and watch the debug output.
What can I do to get the GdkWindow to update its size bounds when the underlying XWindow changes size?
// Written by Ch. Tronche (
http://tronche.lri.fr:8000/)
// Modified by C. Nygard to illustrate gdk_window resize issue
// Copyright by the author. This is unmaintained, no-warranty free software.
// Please use freely. It is appreciated (but by no means mandatory) to
// acknowledge the author's contribution. Thank you.
// Started on Thu Jun 26 23:29:03 1997
// gcc -o test test.c `pkg-config --libs --cflags gtk+-2.0 gtk+-x11-2.0`
#include <X11/Xlib.h>
#include <assert.h>
#include <unistd.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#define NIL (0)
main(int argc, char **argv)
{
GdkWindow *gdk_win;
gdk_init(&argc, &argv);
// Open the display
Display *dpy = XOpenDisplay(NIL);
assert(dpy);
// Get some colors
int blackColor = BlackPixel(dpy, DefaultScreen(dpy));
int whiteColor = WhitePixel(dpy, DefaultScreen(dpy));
// Create the window
Window w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0,
200, 100, 0, blackColor, blackColor);
gdk_win = gdk_window_foreign_new((guint32)w);
printf("gdk_win = %p\n", gdk_win);
// We want to get MapNotify events
XSelectInput(dpy, w, StructureNotifyMask);
// "Map" the window (that is, make it appear on the screen)
XMapWindow(dpy, w);
// Create a "Graphics Context"
GC gc = XCreateGC(dpy, w, 0, NIL);
// Tell the GC we draw using the white color
XSetForeground(dpy, gc, whiteColor);
// Wait for the MapNotify event
for(;;) {
XEvent e;
XNextEvent(dpy, &e);
if (e.type == MapNotify)
break;
}
// Draw the line
XDrawLine(dpy, w, gc, 10, 60, 180, 20);
// Send the "DrawLine" request to the server
XFlush(dpy);
gdk_win = gdk_window_foreign_new((guint32)w);
printf("gdk_win = %p\n", gdk_win);
// Spit out window dimensions whenever we get an event.
for(;;) {
XEvent e;
Window root;
int x, y, xret, yret;
unsigned int widthret,heightret,borderwidthret,depthret;
XNextEvent(dpy, &e);
XGetGeometry(dpy, w,
&root, &xret, &yret,
&widthret, &heightret, &borderwidthret, &depthret);
printf("Window dims: (%d, %d) pos: (%d, %d)\n",
widthret, heightret, xret, yret);
// Re-initializing gdk_win doesn't even help
gdk_win = gdk_window_foreign_new((guint32)w);
gdk_window_get_size(gdk_win, &x, &y);
printf("GdkWindow dims: (%d, %d)\n", x, y);
}
// Wait for 10 seconds
sleep(10);
}