* BUG: Window should not raise useless resize events anymore.
* BUG: Windows embedded inside a Splitter correctly raise their Resize 
  events.
* BUG: Don't try to resize the window inner container with a negative size 
  when the window is too small.
* BUG: Draw window background correctly.
* BUG: Don't try to synchronize X11 when the debugger goes forward if there 
  is no X11 connection yet!


git-svn-id: svn://localhost/gambas/trunk@5082 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2012-08-27 00:26:34 +00:00
parent 1741274a34
commit bc5852b5fa
8 changed files with 65 additions and 60 deletions

View File

@ -642,12 +642,12 @@ void gContainer::setFont(gFont *ft)
void gContainer::moveChild(gControl *child, int x, int y)
{
GtkWidget *parent = getContainer();
GtkWidget *cont = gtk_widget_get_parent(child->border); //getContainer();
if (GTK_IS_LAYOUT(parent))
gtk_layout_move(GTK_LAYOUT(parent), child->border, x, y);
if (GTK_IS_LAYOUT(cont))
gtk_layout_move(GTK_LAYOUT(cont), child->border, x, y);
else
gtk_fixed_move(GTK_FIXED(parent), child->border, x, y);
gtk_fixed_move(GTK_FIXED(cont), child->border, x, y);
}
bool gContainer::hasBackground() const

View File

@ -805,7 +805,7 @@ HANDLES
******************************************************************/
bool gControl::isWindow()
bool gControl::isWindow() const
{
return g_typ == Type_gMainWindow;
}

View File

@ -43,7 +43,7 @@ public:
int getClass() const { return g_typ; }
bool isContainer() const { return (g_typ & 0x100) != 0; }
bool isWindow();
bool isWindow() const;
bool isTopLevel() const { return pr == NULL; }
bool isDestroyed() const { return _destroyed; }

View File

@ -181,11 +181,11 @@ void gDraw::connect(gControl *wid)
switch (wid->getClass())
{
case Type_gMainWindow:
/*case Type_gMainWindow:
dr = GTK_LAYOUT(wid->widget)->bin_window;
mode = GDK_INCLUDE_INFERIORS;
break;
break;*/
case Type_gDrawingArea:

View File

@ -55,6 +55,7 @@ static void cb_show (GtkWidget *widget, gMainWindow *data)
if (data->opened)
{
//data->performArrange();
data->emitResize();
data->emit(SIGNAL(data->onShow));
data->_not_spontaneous = false;
}
@ -76,26 +77,12 @@ static gboolean win_close(GtkWidget *widget,GdkEvent *event,gMainWindow *data)
return true;
}
static gboolean resize_later(gMainWindow *data)
{
data->bufW = data->_next_w;
data->bufH = data->_next_h;
data->_next_timer = 0;
data->configure();
data->performArrange();
if (data->onResize)
data->onResize(data);
//data->refresh();
return false;
}
static gboolean cb_configure(GtkWidget *widget, GdkEventConfigure *event, gMainWindow *data)
{
gint x, y;
//fprintf(stderr, "cb_configure: %s: (%d %d) -> (%d %d) window = %p resized = %d\n", data->name(), data->bufW, data->bufH, event->width, event->height, event->window, data->_resized);
if (data->opened)
{
if (data->isTopLevel())
@ -107,6 +94,7 @@ static gboolean cb_configure(GtkWidget *widget, GdkEventConfigure *event, gMainW
x = event->x;
y = event->y;
}
if (x != data->bufX || y != data->bufY)
{
data->bufX = x;
@ -116,24 +104,10 @@ static gboolean cb_configure(GtkWidget *widget, GdkEventConfigure *event, gMainW
if ((event->width != data->bufW) || (event->height != data->bufH) || (data->_resized) || !event->window)
{
data->_next_w = event->width;
data->_next_h = event->height;
/* data->bufW=event->width;
data->bufH=event->height;
//g_debug("gMainWindow: cb_configure: %d", event->send_event);
data->performArrange();
if (data->onResize) data->onResize(data);*/
//if (data->_resized || data->parent())
//{
data->_resized = false;
resize_later(data);
/*}
else
{
//resize_later(data);
if (!data->_next_timer)
data->_next_timer = g_timeout_add(50, (GSourceFunc)resize_later, data);
}*/
data->_resized = false;
data->bufW = event->width;
data->bufH = event->height;
data->emitResize();
}
}
@ -185,7 +159,6 @@ void gMainWindow::initialize()
_current = NULL;
_background = NULL;
_style = NULL;
_next_timer = 0;
_xembed = false;
_activate = false;
_hidden = false;
@ -193,6 +166,7 @@ void gMainWindow::initialize()
_showMenuBar = true;
_popup = false;
_maximized = _minimized = _fullscreen = false;
_resize_last_w = _resize_last_h = -1;
onOpen = NULL;
onShow = NULL;
@ -287,9 +261,6 @@ gMainWindow::~gMainWindow()
gApplication::exitLoop(this);
}
if (_next_timer)
g_source_remove(_next_timer);
gPicture::assign(&_picture);
gPicture::assign(&_icon);
if (_title) g_free(_title);
@ -377,8 +348,11 @@ void gMainWindow::move(int x, int y)
oy = y + oy - bufY;
bufX = x;
bufY = y;
if (!X11_send_move_resize_event(GDK_WINDOW_XID(border->window), ox, oy, width(), height()))
return;
if (bufW > 0 && bufH > 0)
{
if (!X11_send_move_resize_event(GDK_WINDOW_XID(border->window), ox, oy, width(), height()))
return;
}
#else
bufX = x;
bufY = y;
@ -402,6 +376,8 @@ void gMainWindow::resize(int w, int h)
if (isTopLevel())
{
//fprintf(stderr, "resize: %s: %d %d\n", name(), w, h);
//gdk_window_enable_synchronized_configure (border->window);
bufW = w < 0 ? 0 : w;
@ -414,7 +390,6 @@ void gMainWindow::resize(int w, int h)
}
else
{
//fprintf(stderr, "resize: %d %d (%d)\n", w, h, gtk_window_get_resizable(GTK_WINDOW(border)));
if (isResizable())
gtk_window_resize(GTK_WINDOW(border), w, h);
else
@ -445,6 +420,7 @@ void gMainWindow::emitOpen()
{
//fprintf(stderr, "emit Open: %p (%d %d) resizable = %d\n", this, width(), height(), isResizable());
opened = true;
//_no_resize_event = true; // If the event loop is run during emitOpen(), some spurious configure events are received.
if (isTopLevel())
{
@ -468,9 +444,11 @@ void gMainWindow::emitOpen()
{
//fprintf(stderr, "emit Move & Resize: %p\n", this);
emit(SIGNAL(onMove));
emit(SIGNAL(onResize));
emitResize();
}
}
//_no_resize_event = false;
}
void gMainWindow::afterShow()
@ -1322,13 +1300,18 @@ void gMainWindow::configure()
h = menuBarHeight();
//fprintf(stderr, "configure: %s: %d %d - %d %d\n", name(), isMenuBarVisible(), h, width(), height());
//if (strcmp(name(), "FIDE") == 0 && (width() <= 32 || height() <= 32))
// BREAKPOINT();
if (isMenuBarVisible())
{
gtk_fixed_move(layout, GTK_WIDGET(menuBar), 0, 0);
if (h > 1)
gtk_widget_set_size_request(GTK_WIDGET(menuBar), width(), h);
gtk_fixed_move(layout, widget, 0, h);
gtk_widget_set_size_request(widget, width(), height() - h);
gtk_widget_set_size_request(widget, width(), Max(0, height() - h));
}
else
{
@ -1386,6 +1369,7 @@ void gMainWindow::checkMenuBar()
}
configure();
performArrange();
}
void gMainWindow::embedMenuBar(GtkWidget *border)
@ -1444,3 +1428,15 @@ int gMainWindow::screen()
gMainWindow *tl = topLevel();
return gdk_screen_get_number(gtk_window_get_screen(GTK_WINDOW(tl->border)));
}
void gMainWindow::emitResize()
{
if (bufW == _resize_last_w && bufH == _resize_last_h)
return;
_resize_last_w = bufW;
_resize_last_h = bufH;
configure();
performArrange();
emit(SIGNAL(onResize));
}

View File

@ -142,6 +142,7 @@ public:
int menuBarHeight();
void configure();
void embedMenuBar(GtkWidget *border);
void emitResize();
GtkWindowGroup *group;
GtkAccelGroup *accel;
@ -159,8 +160,8 @@ public:
gButton *_default;
gButton *_cancel;
int _next_w, _next_h;
guint _next_timer;
int _resize_last_w;
int _resize_last_h;
unsigned _mask : 1;
unsigned top_only : 1;

View File

@ -24,6 +24,7 @@
#include "widgets.h"
#include "widgets_private.h"
#include "gapplication.h"
#include "gmainwindow.h"
#include "gsplitter.h"
static void cb_notify(GtkPaned *paned, GParamSpec *arg1, gSplitter *data)
@ -34,7 +35,7 @@ static void cb_notify(GtkPaned *paned, GParamSpec *arg1, gSplitter *data)
static void cb_size_allocate(GtkPaned *widget, GtkAllocation *allocation, gSplitter *data)
{
data->updateChild(gtk_paned_get_child1(widget));
data->updateChild(); //gtk_paned_get_child1(widget));
}
static void cb_child_visibility(GtkWidget *widget, gSplitter *data)
@ -157,18 +158,20 @@ void gSplitter::insert(gControl *child, bool realize)
else
{
if (!vertical)
tmp=gtk_hpaned_new();
tmp = gtk_hpaned_new();
else
tmp=gtk_vpaned_new();
tmp = gtk_vpaned_new();
//gtk_widget_show_all(tmp);
gtk_paned_pack2(curr, tmp, TRUE, TRUE);
curr=GTK_PANED(tmp);
gtk_paned_pack1(curr, w, TRUE, TRUE);
gtk_paned_set_position(curr, child->width());
curr = GTK_PANED(tmp);
//g_signal_connect_after(G_OBJECT(curr),"notify",G_CALLBACK(slt_notify),(gpointer)this);
g_signal_connect_after(G_OBJECT(curr), "size-allocate", G_CALLBACK(cb_size_allocate), (gpointer)this);
g_signal_connect_after(G_OBJECT(curr), "notify", G_CALLBACK(cb_notify), (gpointer)this);
gtk_paned_pack1(curr, w, TRUE, TRUE);
gtk_paned_set_position(curr, child->width());
}
g_signal_connect_after(G_OBJECT(w), "show", G_CALLBACK(cb_child_visibility), (gpointer)this);
@ -181,6 +184,8 @@ void gSplitter::insert(gControl *child, bool realize)
free(layout);
unlock();
//performArrange();
}
void gSplitter::remove(gControl *child)
@ -407,7 +412,9 @@ void gSplitter::updateChild(GtkWidget *w)
//chd->resize(chd->border->allocation.width, chd->border->allocation.height);
//gApplication::setDirty();
//g_debug("gSplitter::updateChild: %s -> (%d %d %d %d)", chd->name(), chd->x(), chd->y(), chd->width(), chd->height());
if (chd->isContainer())
if (chd->isWindow())
((gMainWindow *)chd)->emitResize();
else if (chd->isContainer())
((gContainer*)chd)->performArrange();
}
}

View File

@ -329,6 +329,7 @@ extern "C"
case GB_SIGNAL_DEBUG_FORWARD:
//while (qApp->activePopupWidget())
// delete qApp->activePopupWidget();
if (gdk_display_get_default())
gdk_display_sync(gdk_display_get_default());
break;