зеркало из https://github.com/mozilla/pjs.git
Make paint flashing happen only if caps lock is down to make it easier
to target specific rendering problems. r=pavlov. bug 15234.
This commit is contained in:
Родитель
fcb8e3875b
Коммит
c810869399
|
@ -129,98 +129,81 @@ nsGtkUtils::gtk_widget_set_color(GtkWidget * widget,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
/* static */ GdkModifierType
|
||||||
|
nsGtkUtils::gdk_keyboard_get_modifiers()
|
||||||
|
{
|
||||||
|
GdkModifierType m = (GdkModifierType) 0;
|
||||||
|
|
||||||
|
gdk_window_get_pointer(NULL,NULL,NULL,&m);
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
/* static */ void
|
/* static */ void
|
||||||
nsGtkUtils::gdk_window_flash(GdkWindow * aGdkWindow,
|
nsGtkUtils::gdk_window_flash(GdkWindow * aGdkWindow,
|
||||||
unsigned int aTimes,
|
unsigned int aTimes,
|
||||||
unsigned long aInterval,
|
unsigned long aInterval,
|
||||||
GdkRectangle * aArea)
|
GdkRectangle * aArea)
|
||||||
{
|
{
|
||||||
Display * display = 0;
|
gint x;
|
||||||
Window root_window = 0;
|
gint y;
|
||||||
Window child_window = 0;
|
gint width;
|
||||||
Window xwindow = 0;
|
gint height;
|
||||||
GC gc;
|
guint i;
|
||||||
int x;
|
GdkGC * gc = 0;
|
||||||
int y;
|
GdkColor white;
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
unsigned int border_width;
|
|
||||||
unsigned int depth;
|
|
||||||
int root_x;
|
|
||||||
int root_y;
|
|
||||||
unsigned int i;
|
|
||||||
XGCValues gcv;
|
|
||||||
|
|
||||||
display = GDK_WINDOW_XDISPLAY(aGdkWindow);
|
|
||||||
|
|
||||||
xwindow = GDK_WINDOW_XWINDOW(aGdkWindow);
|
|
||||||
|
|
||||||
XGetGeometry(display,
|
|
||||||
xwindow,
|
|
||||||
&root_window,
|
|
||||||
&x,
|
|
||||||
&y,
|
|
||||||
&width,
|
|
||||||
&height,
|
|
||||||
&border_width,
|
|
||||||
&depth);
|
|
||||||
|
|
||||||
XTranslateCoordinates(display,
|
|
||||||
xwindow,
|
|
||||||
root_window,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
&root_x,
|
|
||||||
&root_y,
|
|
||||||
&child_window);
|
|
||||||
|
|
||||||
memset(&gcv, 0, sizeof(XGCValues));
|
|
||||||
|
|
||||||
gcv.function = GXxor;
|
|
||||||
gcv.foreground = WhitePixel(display, DefaultScreen(display));
|
|
||||||
gcv.subwindow_mode = IncludeInferiors;
|
|
||||||
|
|
||||||
if (gcv.foreground == 0)
|
|
||||||
gcv.foreground = 1;
|
|
||||||
|
|
||||||
gc = XCreateGC(display,
|
|
||||||
root_window,
|
|
||||||
GCFunction | GCForeground | GCSubwindowMode,
|
|
||||||
&gcv);
|
|
||||||
|
|
||||||
XGrabServer(display);
|
|
||||||
|
|
||||||
// If an area is given, use that. Notice how out of whack coordinates
|
gdk_window_get_geometry(aGdkWindow,
|
||||||
// and dimentsions are not checked!!!
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&width,
|
||||||
|
&height,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gdk_window_get_origin (aGdkWindow,
|
||||||
|
&x,
|
||||||
|
&y);
|
||||||
|
|
||||||
|
gc = gdk_gc_new(GDK_ROOT_PARENT());
|
||||||
|
|
||||||
|
white.pixel = WhitePixel(gdk_display,DefaultScreen(gdk_display));
|
||||||
|
|
||||||
|
gdk_gc_set_foreground(gc,&white);
|
||||||
|
gdk_gc_set_function(gc,GDK_XOR);
|
||||||
|
gdk_gc_set_subwindow(gc,GDK_INCLUDE_INFERIORS);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If an area is given, use that. Notice how out of whack coordinates
|
||||||
|
* and dimentsions are not checked!!!
|
||||||
|
*/
|
||||||
if (aArea)
|
if (aArea)
|
||||||
{
|
{
|
||||||
root_x += aArea->x;
|
x += aArea->x;
|
||||||
root_y += aArea->y;
|
y += aArea->y;
|
||||||
|
|
||||||
width = aArea->width;
|
width = aArea->width;
|
||||||
height = aArea->height;
|
height = aArea->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to do this twice so that the XOR effect can replace
|
/*
|
||||||
// the original window contents.
|
* Need to do this twice so that the XOR effect can replace
|
||||||
|
* the original window contents.
|
||||||
|
*/
|
||||||
for (i = 0; i < aTimes * 2; i++)
|
for (i = 0; i < aTimes * 2; i++)
|
||||||
{
|
{
|
||||||
XFillRectangle(display,
|
gdk_draw_rectangle(GDK_ROOT_PARENT(),
|
||||||
root_window,
|
gc,
|
||||||
gc,
|
TRUE,
|
||||||
root_x,
|
x,
|
||||||
root_y,
|
y,
|
||||||
width,
|
width,
|
||||||
height);
|
height);
|
||||||
|
|
||||||
XSync(display, False);
|
gdk_flush();
|
||||||
|
|
||||||
usleep(aInterval);
|
usleep(aInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gdk_gc_destroy(gc);
|
||||||
XFreeGC(display, gc);
|
|
||||||
|
|
||||||
XUngrabServer(display);
|
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -55,6 +55,14 @@ struct nsGtkUtils
|
||||||
GtkStateType state,
|
GtkStateType state,
|
||||||
GdkColor * color);
|
GdkColor * color);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current keyboard modifier state.
|
||||||
|
*
|
||||||
|
* @return the current keyboard modifier state.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static GdkModifierType gdk_keyboard_get_modifiers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flash an area within a GDK window (or the whole window)
|
* Flash an area within a GDK window (or the whole window)
|
||||||
*
|
*
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include "nsIRollupListener.h"
|
#include "nsIRollupListener.h"
|
||||||
|
|
||||||
|
#include "nsGtkUtils.h" // for nsGtkUtils::gdk_keyboard_get_modifiers()
|
||||||
|
|
||||||
#ifdef USE_XIM
|
#ifdef USE_XIM
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIPref.h"
|
#include "nsIPref.h"
|
||||||
|
@ -678,6 +680,9 @@ NS_IMETHODIMP nsWidget::SetCursor(nsCursor aCursor)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CAPS_LOCK_IS_ON \
|
||||||
|
(nsGtkUtils::gdk_keyboard_get_modifiers() & GDK_LOCK_MASK)
|
||||||
|
|
||||||
NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
|
NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
|
||||||
{
|
{
|
||||||
if (!mWidget)
|
if (!mWidget)
|
||||||
|
@ -690,12 +695,15 @@ NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
debug_DumpInvalidate(stdout,
|
if (CAPS_LOCK_IS_ON)
|
||||||
this,
|
{
|
||||||
nsnull,
|
debug_DumpInvalidate(stdout,
|
||||||
aIsSynchronous,
|
this,
|
||||||
debug_GetName(mWidget),
|
nsnull,
|
||||||
debug_GetRenderXID(mWidget));
|
aIsSynchronous,
|
||||||
|
debug_GetName(mWidget),
|
||||||
|
debug_GetRenderXID(mWidget));
|
||||||
|
}
|
||||||
#endif // NS_DEBUG
|
#endif // NS_DEBUG
|
||||||
|
|
||||||
if (aIsSynchronous) {
|
if (aIsSynchronous) {
|
||||||
|
@ -723,12 +731,15 @@ NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
|
||||||
mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height);
|
mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
debug_DumpInvalidate(stdout,
|
if (CAPS_LOCK_IS_ON)
|
||||||
this,
|
{
|
||||||
&aRect,
|
debug_DumpInvalidate(stdout,
|
||||||
aIsSynchronous,
|
this,
|
||||||
debug_GetName(mWidget),
|
&aRect,
|
||||||
debug_GetRenderXID(mWidget));
|
aIsSynchronous,
|
||||||
|
debug_GetName(mWidget),
|
||||||
|
debug_GetRenderXID(mWidget));
|
||||||
|
}
|
||||||
#endif // NS_DEBUG
|
#endif // NS_DEBUG
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1171,11 +1182,14 @@ NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *aEvent,
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
GtkWidget * gw = (GtkWidget *) aEvent->widget->GetNativeData(NS_NATIVE_WIDGET);
|
GtkWidget * gw = (GtkWidget *) aEvent->widget->GetNativeData(NS_NATIVE_WIDGET);
|
||||||
|
|
||||||
debug_DumpEvent(stdout,
|
if (CAPS_LOCK_IS_ON)
|
||||||
aEvent->widget,
|
{
|
||||||
aEvent,
|
debug_DumpEvent(stdout,
|
||||||
debug_GetName(gw),
|
aEvent->widget,
|
||||||
(PRInt32) debug_GetRenderXID(gw));
|
aEvent,
|
||||||
|
debug_GetName(gw),
|
||||||
|
(PRInt32) debug_GetRenderXID(gw));
|
||||||
|
}
|
||||||
#endif // NS_DEBUG
|
#endif // NS_DEBUG
|
||||||
|
|
||||||
if (nsnull != mMenuListener) {
|
if (nsnull != mMenuListener) {
|
||||||
|
|
|
@ -400,6 +400,12 @@ nsresult nsWindow::SetIcon(GdkPixmap *pixmap,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CAPS_LOCK_IS_ON \
|
||||||
|
(nsGtkUtils::gdk_keyboard_get_modifiers() & GDK_LOCK_MASK)
|
||||||
|
|
||||||
|
#define WANT_PAINT_FLASHING \
|
||||||
|
(debug_WantPaintFlashing() && CAPS_LOCK_IS_ON)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes an Expose Event
|
* Processes an Expose Event
|
||||||
*
|
*
|
||||||
|
@ -414,11 +420,14 @@ PRBool nsWindow::OnExpose(nsPaintEvent &event)
|
||||||
event.renderingContext = nsnull;
|
event.renderingContext = nsnull;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
debug_DumpPaintEvent(stdout,
|
if (CAPS_LOCK_IS_ON)
|
||||||
this,
|
{
|
||||||
&event,
|
debug_DumpPaintEvent(stdout,
|
||||||
debug_GetName(mWidget),
|
this,
|
||||||
(PRInt32) debug_GetRenderXID(mWidget));
|
&event,
|
||||||
|
debug_GetName(mWidget),
|
||||||
|
(PRInt32) debug_GetRenderXID(mWidget));
|
||||||
|
}
|
||||||
#endif // NS_DEBUG
|
#endif // NS_DEBUG
|
||||||
|
|
||||||
|
|
||||||
|
@ -464,7 +473,7 @@ PRBool nsWindow::OnExpose(nsPaintEvent &event)
|
||||||
mUpdateArea->Subtract(event.rect->x, event.rect->y, event.rect->width, event.rect->height);
|
mUpdateArea->Subtract(event.rect->x, event.rect->y, event.rect->width, event.rect->height);
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
if (debug_WantPaintFlashing())
|
if (WANT_PAINT_FLASHING)
|
||||||
{
|
{
|
||||||
GdkWindow * gw = GetRenderWindow(mWidget);
|
GdkWindow * gw = GetRenderWindow(mWidget);
|
||||||
|
|
||||||
|
@ -506,11 +515,14 @@ PRBool nsWindow::OnDraw(nsPaintEvent &event)
|
||||||
event.renderingContext = nsnull;
|
event.renderingContext = nsnull;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
debug_DumpPaintEvent(stdout,
|
if (CAPS_LOCK_IS_ON)
|
||||||
this,
|
{
|
||||||
&event,
|
debug_DumpPaintEvent(stdout,
|
||||||
debug_GetName(mWidget),
|
this,
|
||||||
(PRInt32) debug_GetRenderXID(mWidget));
|
&event,
|
||||||
|
debug_GetName(mWidget),
|
||||||
|
(PRInt32) debug_GetRenderXID(mWidget));
|
||||||
|
}
|
||||||
#endif // NS_DEBUG
|
#endif // NS_DEBUG
|
||||||
|
|
||||||
|
|
||||||
|
@ -551,7 +563,7 @@ PRBool nsWindow::OnDraw(nsPaintEvent &event)
|
||||||
mUpdateArea->Subtract(event.rect->x, event.rect->y, event.rect->width, event.rect->height);
|
mUpdateArea->Subtract(event.rect->x, event.rect->y, event.rect->width, event.rect->height);
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
if (debug_WantPaintFlashing())
|
if (WANT_PAINT_FLASHING)
|
||||||
{
|
{
|
||||||
GdkWindow * gw = GetRenderWindow(mWidget);
|
GdkWindow * gw = GetRenderWindow(mWidget);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче