Don't set the PC_EXPLICIT flag for unused palette entries, that might have

2002-02-17  Tor Lillqvist  <tml@iki.fi>

	* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
	PC_EXPLICIT flag for unused palette entries, that might have
	undesired side effects. Just set them to black. Black is always
	present in a palette, so having superfluous black entries won't
	cause any extra allocations from the system palette either when
	realized.

	* gdk/win32/gdkevents-win32.c
	(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
	system visual is static color, i.e. the user has told GDK to use
	just the 16 static colors. In that case no need to redraw
	anything, as the colors are static and by definition always
	correctly mapped in the system palette.
	(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
This commit is contained in:
Tor Lillqvist 2002-02-17 22:03:29 +00:00 committed by Tor Lillqvist
parent 38d639c0e8
commit 28bfe19594
9 changed files with 157 additions and 11 deletions

View File

@ -1,3 +1,22 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
PC_EXPLICIT flag for unused palette entries, that might have
undesired side effects. Just set them to black. Black is always
present in a palette, so having superfluous black entries won't
cause any extra allocations from the system palette either when
realized.
* gdk/win32/gdkevents-win32.c
(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
system visual is static color, i.e. the user has told GDK to use
just the 16 static colors. In that case no need to redraw
anything, as the colors are static and by definition always
correctly mapped in the system palette.
(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
* gtk/gtk.def: Add new gtkfilesel entry points.
2002-02-17 Matthias Clasen <maclas@gmx.de> 2002-02-17 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c,

View File

@ -1,3 +1,22 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
PC_EXPLICIT flag for unused palette entries, that might have
undesired side effects. Just set them to black. Black is always
present in a palette, so having superfluous black entries won't
cause any extra allocations from the system palette either when
realized.
* gdk/win32/gdkevents-win32.c
(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
system visual is static color, i.e. the user has told GDK to use
just the 16 static colors. In that case no need to redraw
anything, as the colors are static and by definition always
correctly mapped in the system palette.
(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
* gtk/gtk.def: Add new gtkfilesel entry points.
2002-02-17 Matthias Clasen <maclas@gmx.de> 2002-02-17 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c,

View File

@ -1,3 +1,22 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
PC_EXPLICIT flag for unused palette entries, that might have
undesired side effects. Just set them to black. Black is always
present in a palette, so having superfluous black entries won't
cause any extra allocations from the system palette either when
realized.
* gdk/win32/gdkevents-win32.c
(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
system visual is static color, i.e. the user has told GDK to use
just the 16 static colors. In that case no need to redraw
anything, as the colors are static and by definition always
correctly mapped in the system palette.
(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
* gtk/gtk.def: Add new gtkfilesel entry points.
2002-02-17 Matthias Clasen <maclas@gmx.de> 2002-02-17 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c,

View File

@ -1,3 +1,22 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
PC_EXPLICIT flag for unused palette entries, that might have
undesired side effects. Just set them to black. Black is always
present in a palette, so having superfluous black entries won't
cause any extra allocations from the system palette either when
realized.
* gdk/win32/gdkevents-win32.c
(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
system visual is static color, i.e. the user has told GDK to use
just the 16 static colors. In that case no need to redraw
anything, as the colors are static and by definition always
correctly mapped in the system palette.
(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
* gtk/gtk.def: Add new gtkfilesel entry points.
2002-02-17 Matthias Clasen <maclas@gmx.de> 2002-02-17 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c,

View File

@ -1,3 +1,22 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
PC_EXPLICIT flag for unused palette entries, that might have
undesired side effects. Just set them to black. Black is always
present in a palette, so having superfluous black entries won't
cause any extra allocations from the system palette either when
realized.
* gdk/win32/gdkevents-win32.c
(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
system visual is static color, i.e. the user has told GDK to use
just the 16 static colors. In that case no need to redraw
anything, as the colors are static and by definition always
correctly mapped in the system palette.
(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
* gtk/gtk.def: Add new gtkfilesel entry points.
2002-02-17 Matthias Clasen <maclas@gmx.de> 2002-02-17 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c,

View File

@ -1,3 +1,22 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
PC_EXPLICIT flag for unused palette entries, that might have
undesired side effects. Just set them to black. Black is always
present in a palette, so having superfluous black entries won't
cause any extra allocations from the system palette either when
realized.
* gdk/win32/gdkevents-win32.c
(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
system visual is static color, i.e. the user has told GDK to use
just the 16 static colors. In that case no need to redraw
anything, as the colors are static and by definition always
correctly mapped in the system palette.
(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
* gtk/gtk.def: Add new gtkfilesel entry points.
2002-02-17 Matthias Clasen <maclas@gmx.de> 2002-02-17 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c,

View File

@ -1,3 +1,22 @@
2002-02-17 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkcolor-win32.c (free_colors): Don't set the
PC_EXPLICIT flag for unused palette entries, that might have
undesired side effects. Just set them to black. Black is always
present in a palette, so having superfluous black entries won't
cause any extra allocations from the system palette either when
realized.
* gdk/win32/gdkevents-win32.c
(gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the
system visual is static color, i.e. the user has told GDK to use
just the 16 static colors. In that case no need to redraw
anything, as the colors are static and by definition always
correctly mapped in the system palette.
(WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either.
* gtk/gtk.def: Add new gtkfilesel entry points.
2002-02-17 Matthias Clasen <maclas@gmx.de> 2002-02-17 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c,

View File

@ -454,8 +454,11 @@ free_colors (GdkColormap *cmap,
GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap); GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap);
gint i; gint i;
#ifdef G_ENABLE_DEBUG #ifdef G_ENABLE_DEBUG
gint set_explicit = 0; gint set_black_count = 0;
#endif #endif
gboolean *cleared_entries;
cleared_entries = g_new0 (gboolean, cmap->size);
/* We don't have to do anything for non-palette devices. */ /* We don't have to do anything for non-palette devices. */
@ -470,7 +473,10 @@ free_colors (GdkColormap *cmap,
else if (cmapp->use[pixels[i]] == GDK_WIN32_PE_STATIC) else if (cmapp->use[pixels[i]] == GDK_WIN32_PE_STATIC)
; /* Nothing either*/ ; /* Nothing either*/
else else
{
cmapp->use[pixels[i]] = GDK_WIN32_PE_AVAILABLE; cmapp->use[pixels[i]] = GDK_WIN32_PE_AVAILABLE;
cleared_entries[pixels[i]] = TRUE;
}
} }
for (i = cmapp->current_size - 1; i >= 0; i--) for (i = cmapp->current_size - 1; i >= 0; i--)
if (cmapp->use[i] != GDK_WIN32_PE_AVAILABLE) if (cmapp->use[i] != GDK_WIN32_PE_AVAILABLE)
@ -484,25 +490,26 @@ free_colors (GdkColormap *cmap,
else else
cmapp->current_size = i + 1; cmapp->current_size = i + 1;
} }
pe.peRed = pe.peGreen = pe.peBlue = pe.peFlags = 0;
for (i = 0; i < cmapp->current_size; i++) for (i = 0; i < cmapp->current_size; i++)
{ {
if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE) if (cleared_entries[i])
{ {
*(WORD*)&pe = i;
pe.peFlags = PC_EXPLICIT;
if (!SetPaletteEntries (cmapp->hpal, i, 1, &pe)) if (!SetPaletteEntries (cmapp->hpal, i, 1, &pe))
WIN32_GDI_FAILED ("SetPaletteEntries"); WIN32_GDI_FAILED ("SetPaletteEntries");
GDK_NOTE (COLORMAP, set_explicit++); GDK_NOTE (COLORMAP, set_black_count++);
} }
} }
#if 0 #if 0
GDK_NOTE (COLORMAP, gdk_win32_print_hpalette (cmapp->hpal)); GDK_NOTE (COLORMAP, gdk_win32_print_hpalette (cmapp->hpal));
#else #else
GDK_NOTE (COLORMAP, (set_explicit > 0 ? GDK_NOTE (COLORMAP, (set_black_count > 0 ?
g_print ("free_colors: %d (%d) PC_EXPLICIT\n", g_print ("free_colors: %d (%d) set to black\n",
set_explicit, cmapp->current_size) set_black_count, cmapp->current_size)
: (void) 0)); : (void) 0));
#endif #endif
g_free (cleared_entries);
break; break;
default: default:

View File

@ -2732,8 +2732,11 @@ gdk_event_translate (GdkEvent *event,
case WM_QUERYNEWPALETTE: case WM_QUERYNEWPALETTE:
GDK_NOTE (EVENTS_OR_COLORMAP, g_print ("WM_QUERYNEWPALETTE: %p\n", GDK_NOTE (EVENTS_OR_COLORMAP, g_print ("WM_QUERYNEWPALETTE: %p\n",
msg->hwnd)); msg->hwnd));
if (gdk_visual_get_system ()->type == GDK_VISUAL_PSEUDO_COLOR)
{
synthesize_expose_events (window); synthesize_expose_events (window);
update_colors_counter = 0; update_colors_counter = 0;
}
*ret_val_flagp = TRUE; *ret_val_flagp = TRUE;
*ret_valp = FALSE; *ret_valp = FALSE;
break; break;
@ -2744,6 +2747,9 @@ gdk_event_translate (GdkEvent *event,
*ret_val_flagp = TRUE; *ret_val_flagp = TRUE;
*ret_valp = FALSE; *ret_valp = FALSE;
if (gdk_visual_get_system ()->type != GDK_VISUAL_PSEUDO_COLOR)
break;
if (msg->hwnd == (HWND) msg->wParam) if (msg->hwnd == (HWND) msg->wParam)
break; break;