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:
ramiro%netscape.com 1999-09-30 01:17:34 +00:00
Родитель fcb8e3875b
Коммит c810869399
4 изменённых файлов: 126 добавлений и 109 удалений

Просмотреть файл

@ -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
nsGtkUtils::gdk_window_flash(GdkWindow * aGdkWindow,
unsigned int aTimes,
unsigned long aInterval,
GdkRectangle * aArea)
GdkRectangle * aArea)
{
Display * display = 0;
Window root_window = 0;
Window child_window = 0;
Window xwindow = 0;
GC gc;
int x;
int y;
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);
gint x;
gint y;
gint width;
gint height;
guint i;
GdkGC * gc = 0;
GdkColor white;
// If an area is given, use that. Notice how out of whack coordinates
// and dimentsions are not checked!!!
gdk_window_get_geometry(aGdkWindow,
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)
{
root_x += aArea->x;
root_y += aArea->y;
width = aArea->width;
height = aArea->height;
x += aArea->x;
y += aArea->y;
width = aArea->width;
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++)
{
XFillRectangle(display,
root_window,
gc,
root_x,
root_y,
width,
height);
XSync(display, False);
usleep(aInterval);
gdk_draw_rectangle(GDK_ROOT_PARENT(),
gc,
TRUE,
x,
y,
width,
height);
gdk_flush();
usleep(aInterval);
}
XFreeGC(display, gc);
XUngrabServer(display);
gdk_gc_destroy(gc);
}
//////////////////////////////////////////////////////////////////

Просмотреть файл

@ -55,6 +55,14 @@ struct nsGtkUtils
GtkStateType state,
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)
*

Просмотреть файл

@ -31,6 +31,8 @@
#include <gdk/gdkx.h>
#include "nsIRollupListener.h"
#include "nsGtkUtils.h" // for nsGtkUtils::gdk_keyboard_get_modifiers()
#ifdef USE_XIM
#include "nsIServiceManager.h"
#include "nsIPref.h"
@ -678,6 +680,9 @@ NS_IMETHODIMP nsWidget::SetCursor(nsCursor aCursor)
return NS_OK;
}
#define CAPS_LOCK_IS_ON \
(nsGtkUtils::gdk_keyboard_get_modifiers() & GDK_LOCK_MASK)
NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
{
if (!mWidget)
@ -690,12 +695,15 @@ NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
return NS_ERROR_FAILURE;
#ifdef NS_DEBUG
debug_DumpInvalidate(stdout,
this,
nsnull,
aIsSynchronous,
debug_GetName(mWidget),
debug_GetRenderXID(mWidget));
if (CAPS_LOCK_IS_ON)
{
debug_DumpInvalidate(stdout,
this,
nsnull,
aIsSynchronous,
debug_GetName(mWidget),
debug_GetRenderXID(mWidget));
}
#endif // NS_DEBUG
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);
#ifdef NS_DEBUG
debug_DumpInvalidate(stdout,
this,
&aRect,
aIsSynchronous,
debug_GetName(mWidget),
debug_GetRenderXID(mWidget));
if (CAPS_LOCK_IS_ON)
{
debug_DumpInvalidate(stdout,
this,
&aRect,
aIsSynchronous,
debug_GetName(mWidget),
debug_GetRenderXID(mWidget));
}
#endif // NS_DEBUG
#if 0
@ -1171,11 +1182,14 @@ NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *aEvent,
#ifdef NS_DEBUG
GtkWidget * gw = (GtkWidget *) aEvent->widget->GetNativeData(NS_NATIVE_WIDGET);
debug_DumpEvent(stdout,
aEvent->widget,
aEvent,
debug_GetName(gw),
(PRInt32) debug_GetRenderXID(gw));
if (CAPS_LOCK_IS_ON)
{
debug_DumpEvent(stdout,
aEvent->widget,
aEvent,
debug_GetName(gw),
(PRInt32) debug_GetRenderXID(gw));
}
#endif // NS_DEBUG
if (nsnull != mMenuListener) {

Просмотреть файл

@ -400,6 +400,12 @@ nsresult nsWindow::SetIcon(GdkPixmap *pixmap,
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
*
@ -414,11 +420,14 @@ PRBool nsWindow::OnExpose(nsPaintEvent &event)
event.renderingContext = nsnull;
#ifdef NS_DEBUG
debug_DumpPaintEvent(stdout,
this,
&event,
debug_GetName(mWidget),
(PRInt32) debug_GetRenderXID(mWidget));
if (CAPS_LOCK_IS_ON)
{
debug_DumpPaintEvent(stdout,
this,
&event,
debug_GetName(mWidget),
(PRInt32) debug_GetRenderXID(mWidget));
}
#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);
#ifdef NS_DEBUG
if (debug_WantPaintFlashing())
if (WANT_PAINT_FLASHING)
{
GdkWindow * gw = GetRenderWindow(mWidget);
@ -506,11 +515,14 @@ PRBool nsWindow::OnDraw(nsPaintEvent &event)
event.renderingContext = nsnull;
#ifdef NS_DEBUG
debug_DumpPaintEvent(stdout,
this,
&event,
debug_GetName(mWidget),
(PRInt32) debug_GetRenderXID(mWidget));
if (CAPS_LOCK_IS_ON)
{
debug_DumpPaintEvent(stdout,
this,
&event,
debug_GetName(mWidget),
(PRInt32) debug_GetRenderXID(mWidget));
}
#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);
#ifdef NS_DEBUG
if (debug_WantPaintFlashing())
if (WANT_PAINT_FLASHING)
{
GdkWindow * gw = GetRenderWindow(mWidget);