зеркало из https://github.com/mozilla/gecko-dev.git
Fixing bug 42345 - hook up NS_MOVE events when a toplevel window is moved
on Linux. Also use get_root_origin instead of get_origin so that we persist the correct position. r=blizzard.
This commit is contained in:
Родитель
dd1e2629e0
Коммит
f1ebc3acd0
|
@ -45,6 +45,8 @@
|
|||
//#define DEBUG_EVENTS 1
|
||||
#endif
|
||||
|
||||
//#define DEBUG_MOVE
|
||||
|
||||
static void
|
||||
dispatch_superwin_event(GdkEvent *event, nsWindow *window);
|
||||
|
||||
|
@ -1007,3 +1009,35 @@ handle_superwin_flush(gpointer aData)
|
|||
nsWindow *window = (nsWindow *)aData;
|
||||
window->Update();
|
||||
}
|
||||
|
||||
gboolean
|
||||
handle_configure_event(GtkWidget *w, GdkEventConfigure *conf, gpointer p)
|
||||
{
|
||||
// This event handler is only installed on toplevel windows, because:
|
||||
// a) gdk_window_get_root_origin gives bad results for inner windows, and
|
||||
// b) we don't really need to worry about move events on inner windows
|
||||
|
||||
nsWindow *widget = (nsWindow *)p;
|
||||
|
||||
// Find out if the window position has changed
|
||||
nsRect oldBounds;
|
||||
widget->GetBounds(oldBounds);
|
||||
|
||||
nscoord x,y;
|
||||
gdk_window_get_root_origin(w->window, &x, &y);
|
||||
|
||||
if ((oldBounds.x == x) && (oldBounds.y == y))
|
||||
return PR_FALSE;
|
||||
|
||||
#ifdef DEBUG_MOVE
|
||||
printf("Window: Move from (%d,%d) to (%d,%d)\n", oldBounds.x, oldBounds.y,
|
||||
x, y);
|
||||
#endif
|
||||
|
||||
nscoord relX, relY;
|
||||
gdk_window_get_origin(w->window, &relX, &relY);
|
||||
|
||||
widget->OnMove(relX, relY);
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
class nsIWidget;
|
||||
|
||||
gint handle_configure_event(GtkWidget *w, GdkEventConfigure *conf, gpointer p);
|
||||
gboolean handle_configure_event(GtkWidget *w, GdkEventConfigure *conf, gpointer p);
|
||||
void handle_size_allocate(GtkWidget *w, GtkAllocation *alloc, gpointer p);
|
||||
gint handle_expose_event(GtkWidget *w, GdkEventExpose *event, gpointer p);
|
||||
|
||||
|
|
|
@ -586,7 +586,7 @@ NS_IMETHODIMP nsWidget::Move(PRInt32 aX, PRInt32 aY)
|
|||
|
||||
NS_IMETHODIMP nsWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
||||
{
|
||||
#if 0
|
||||
#ifdef DEBUG_MOVE
|
||||
printf("nsWidget::Resize %s (%p) to %d %d\n",
|
||||
(const char *) debug_GetName(mWidget),
|
||||
this,
|
||||
|
|
|
@ -222,7 +222,11 @@ NS_IMETHODIMP nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
|
|||
{
|
||||
if (mMozArea->window)
|
||||
{
|
||||
gdk_window_get_origin(mMozArea->window, &x, &y);
|
||||
if (!GTK_WIDGET_MAPPED(mMozArea) || !GTK_WIDGET_REALIZED(mMozArea)) {
|
||||
// get_root_origin will do Bad Things
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
gdk_window_get_root_origin(mMozArea->window, &x, &y);
|
||||
aNewRect.x = x + aOldRect.x;
|
||||
aNewRect.y = y + aOldRect.y;
|
||||
}
|
||||
|
@ -1892,6 +1896,10 @@ NS_METHOD nsWindow::CreateNative(GtkObject *parentWidget)
|
|||
"size_allocate",
|
||||
GTK_SIGNAL_FUNC(handle_size_allocate),
|
||||
this);
|
||||
gtk_signal_connect_after(GTK_OBJECT(mShell),
|
||||
"configure_event",
|
||||
GTK_SIGNAL_FUNC(handle_configure_event),
|
||||
this);
|
||||
break;
|
||||
|
||||
case eWindowType_child:
|
||||
|
|
Загрузка…
Ссылка в новой задаче