Commit 09393d07 authored by Gerd Moellmann's avatar Gerd Moellmann
Browse files

(x_set_foreground_color): Change frame's cursor_pixel

only if its equal to the former foreground pixel color.
(x_set_foreground_color, x_set_background_color)
(x_set_mouse_color, x_set_cursor_color): Cleaned up.
parent 460e6bae
2001-05-16 Gerd Moellmann <gerd@gnu.org>
* xfns.c (x_set_foreground_color): Change frame's cursor_pixel
only if it's equal to the former foreground pixel color.
(x_set_foreground_color, x_set_background_color)
(x_set_mouse_color, x_set_cursor_color): Cleaned up.
2001-05-16 Dave Love <fx@gnu.org> 2001-05-16 Dave Love <fx@gnu.org>
* insdel.c (signal_before_change, signal_after_change): Consider a * insdel.c (signal_before_change, signal_after_change): Consider a
......
...@@ -1346,30 +1346,37 @@ x_set_foreground_color (f, arg, oldval) ...@@ -1346,30 +1346,37 @@ x_set_foreground_color (f, arg, oldval)
struct frame *f; struct frame *f;
Lisp_Object arg, oldval; Lisp_Object arg, oldval;
{ {
unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); struct x_output *x = f->output_data.x;
unsigned long fg, old_fg;
unload_color (f, f->output_data.x->foreground_pixel); fg = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
f->output_data.x->foreground_pixel = pixel; old_fg = x->foreground_pixel;
x->foreground_pixel = fg;
if (FRAME_X_WINDOW (f) != 0) if (FRAME_X_WINDOW (f) != 0)
{ {
BLOCK_INPUT; Display *dpy = FRAME_X_DISPLAY (f);
XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
f->output_data.x->foreground_pixel);
XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
f->output_data.x->foreground_pixel);
XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, BLOCK_INPUT;
f->output_data.x->foreground_pixel); XSetForeground (dpy, x->normal_gc, fg);
unload_color (f, f->output_data.x->cursor_pixel); XSetBackground (dpy, x->reverse_gc, fg);
f->output_data.x->cursor_pixel
= x_copy_color (f, f->output_data.x->foreground_pixel);
if (x->cursor_pixel == old_fg)
{
unload_color (f, x->cursor_pixel);
x->cursor_pixel = x_copy_color (f, fg);
XSetBackground (dpy, x->cursor_gc, x->cursor_pixel);
}
UNBLOCK_INPUT; UNBLOCK_INPUT;
update_face_from_frame_parameter (f, Qforeground_color, arg); update_face_from_frame_parameter (f, Qforeground_color, arg);
if (FRAME_VISIBLE_P (f)) if (FRAME_VISIBLE_P (f))
redraw_frame (f); redraw_frame (f);
} }
unload_color (f, old_fg);
} }
void void
...@@ -1377,34 +1384,33 @@ x_set_background_color (f, arg, oldval) ...@@ -1377,34 +1384,33 @@ x_set_background_color (f, arg, oldval)
struct frame *f; struct frame *f;
Lisp_Object arg, oldval; Lisp_Object arg, oldval;
{ {
unsigned long pixel = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f)); struct x_output *x = f->output_data.x;
unsigned long bg;
unload_color (f, f->output_data.x->background_pixel); bg = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
f->output_data.x->background_pixel = pixel; unload_color (f, x->background_pixel);
x->background_pixel = bg;
if (FRAME_X_WINDOW (f) != 0) if (FRAME_X_WINDOW (f) != 0)
{ {
BLOCK_INPUT; Display *dpy = FRAME_X_DISPLAY (f);
/* The main frame area. */ Lisp_Object bar;
XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
f->output_data.x->background_pixel);
XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->reverse_gc,
f->output_data.x->background_pixel);
XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
f->output_data.x->background_pixel);
XSetWindowBackground (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), BLOCK_INPUT;
f->output_data.x->background_pixel); XSetBackground (dpy, x->normal_gc, bg);
{ XSetForeground (dpy, x->reverse_gc, bg);
Lisp_Object bar; XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg);
for (bar = FRAME_SCROLL_BARS (f); !NILP (bar); XSetForeground (dpy, x->cursor_gc, bg);
bar = XSCROLL_BAR (bar)->next)
XSetWindowBackground (FRAME_X_DISPLAY (f), for (bar = FRAME_SCROLL_BARS (f);
SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)), !NILP (bar);
f->output_data.x->background_pixel); bar = XSCROLL_BAR (bar)->next)
} {
UNBLOCK_INPUT; Window window = SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar));
XSetWindowBackground (dpy, window, bg);
}
UNBLOCK_INPUT;
update_face_from_frame_parameter (f, Qbackground_color, arg); update_face_from_frame_parameter (f, Qbackground_color, arg);
if (FRAME_VISIBLE_P (f)) if (FRAME_VISIBLE_P (f))
...@@ -1417,149 +1423,141 @@ x_set_mouse_color (f, arg, oldval) ...@@ -1417,149 +1423,141 @@ x_set_mouse_color (f, arg, oldval)
struct frame *f; struct frame *f;
Lisp_Object arg, oldval; Lisp_Object arg, oldval;
{ {
struct x_output *x = f->output_data.x;
Display *dpy = FRAME_X_DISPLAY (f);
Cursor cursor, nontext_cursor, mode_cursor, cross_cursor; Cursor cursor, nontext_cursor, mode_cursor, cross_cursor;
Cursor hourglass_cursor, horizontal_drag_cursor; Cursor hourglass_cursor, horizontal_drag_cursor;
int count; int count;
unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
unsigned long mask_color = f->output_data.x->background_pixel; unsigned long mask_color = x->background_pixel;
/* Don't let pointers be invisible. */ /* Don't let pointers be invisible. */
if (mask_color == pixel if (mask_color == pixel)
&& mask_color == f->output_data.x->background_pixel)
{ {
x_free_colors (f, &pixel, 1); x_free_colors (f, &pixel, 1);
pixel = x_copy_color (f, f->output_data.x->foreground_pixel); pixel = x_copy_color (f, x->foreground_pixel);
} }
unload_color (f, f->output_data.x->mouse_pixel); unload_color (f, x->mouse_pixel);
f->output_data.x->mouse_pixel = pixel; x->mouse_pixel = pixel;
BLOCK_INPUT; BLOCK_INPUT;
/* It's not okay to crash if the user selects a screwy cursor. */ /* It's not okay to crash if the user selects a screwy cursor. */
count = x_catch_errors (FRAME_X_DISPLAY (f)); count = x_catch_errors (dpy);
if (!EQ (Qnil, Vx_pointer_shape)) if (!NILP (Vx_pointer_shape))
{ {
CHECK_NUMBER (Vx_pointer_shape, 0); CHECK_NUMBER (Vx_pointer_shape, 0);
cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XINT (Vx_pointer_shape)); cursor = XCreateFontCursor (dpy, XINT (Vx_pointer_shape));
} }
else else
cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_xterm); cursor = XCreateFontCursor (dpy, XC_xterm);
x_check_errors (FRAME_X_DISPLAY (f), "bad text pointer cursor: %s"); x_check_errors (dpy, "bad text pointer cursor: %s");
if (!EQ (Qnil, Vx_nontext_pointer_shape)) if (!NILP (Vx_nontext_pointer_shape))
{ {
CHECK_NUMBER (Vx_nontext_pointer_shape, 0); CHECK_NUMBER (Vx_nontext_pointer_shape, 0);
nontext_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), nontext_cursor
XINT (Vx_nontext_pointer_shape)); = XCreateFontCursor (dpy, XINT (Vx_nontext_pointer_shape));
} }
else else
nontext_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_left_ptr); nontext_cursor = XCreateFontCursor (dpy, XC_left_ptr);
x_check_errors (FRAME_X_DISPLAY (f), "bad nontext pointer cursor: %s"); x_check_errors (dpy, "bad nontext pointer cursor: %s");
if (!EQ (Qnil, Vx_hourglass_pointer_shape)) if (!NILP (Vx_hourglass_pointer_shape))
{ {
CHECK_NUMBER (Vx_hourglass_pointer_shape, 0); CHECK_NUMBER (Vx_hourglass_pointer_shape, 0);
hourglass_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), hourglass_cursor
XINT (Vx_hourglass_pointer_shape)); = XCreateFontCursor (dpy, XINT (Vx_hourglass_pointer_shape));
} }
else else
hourglass_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_watch); hourglass_cursor = XCreateFontCursor (dpy, XC_watch);
x_check_errors (FRAME_X_DISPLAY (f), "bad hourglass pointer cursor: %s"); x_check_errors (dpy, "bad hourglass pointer cursor: %s");
x_check_errors (FRAME_X_DISPLAY (f), "bad nontext pointer cursor: %s"); x_check_errors (dpy, "bad nontext pointer cursor: %s");
if (!EQ (Qnil, Vx_mode_pointer_shape)) if (!NILP (Vx_mode_pointer_shape))
{ {
CHECK_NUMBER (Vx_mode_pointer_shape, 0); CHECK_NUMBER (Vx_mode_pointer_shape, 0);
mode_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), mode_cursor = XCreateFontCursor (dpy, XINT (Vx_mode_pointer_shape));
XINT (Vx_mode_pointer_shape));
} }
else else
mode_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_xterm); mode_cursor = XCreateFontCursor (dpy, XC_xterm);
x_check_errors (FRAME_X_DISPLAY (f), "bad modeline pointer cursor: %s"); x_check_errors (dpy, "bad modeline pointer cursor: %s");
if (!EQ (Qnil, Vx_sensitive_text_pointer_shape)) if (!NILP (Vx_sensitive_text_pointer_shape))
{ {
CHECK_NUMBER (Vx_sensitive_text_pointer_shape, 0); CHECK_NUMBER (Vx_sensitive_text_pointer_shape, 0);
cross_cursor cross_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f), = XCreateFontCursor (dpy, XINT (Vx_sensitive_text_pointer_shape));
XINT (Vx_sensitive_text_pointer_shape));
} }
else else
cross_cursor = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_crosshair); cross_cursor = XCreateFontCursor (dpy, XC_crosshair);
if (!NILP (Vx_window_horizontal_drag_shape)) if (!NILP (Vx_window_horizontal_drag_shape))
{ {
CHECK_NUMBER (Vx_window_horizontal_drag_shape, 0); CHECK_NUMBER (Vx_window_horizontal_drag_shape, 0);
horizontal_drag_cursor horizontal_drag_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f), = XCreateFontCursor (dpy, XINT (Vx_window_horizontal_drag_shape));
XINT (Vx_window_horizontal_drag_shape));
} }
else else
horizontal_drag_cursor horizontal_drag_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f), XC_sb_h_double_arrow); = XCreateFontCursor (dpy, XC_sb_h_double_arrow);
/* Check and report errors with the above calls. */ /* Check and report errors with the above calls. */
x_check_errors (FRAME_X_DISPLAY (f), "can't set cursor shape: %s"); x_check_errors (dpy, "can't set cursor shape: %s");
x_uncatch_errors (FRAME_X_DISPLAY (f), count); x_uncatch_errors (dpy, count);
{ {
XColor fore_color, back_color; XColor fore_color, back_color;
fore_color.pixel = f->output_data.x->mouse_pixel; fore_color.pixel = x->mouse_pixel;
x_query_color (f, &fore_color); x_query_color (f, &fore_color);
back_color.pixel = mask_color; back_color.pixel = mask_color;
x_query_color (f, &back_color); x_query_color (f, &back_color);
XRecolorCursor (FRAME_X_DISPLAY (f), cursor, XRecolorCursor (dpy, cursor, &fore_color, &back_color);
&fore_color, &back_color); XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color);
XRecolorCursor (FRAME_X_DISPLAY (f), nontext_cursor, XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color);
&fore_color, &back_color); XRecolorCursor (dpy, cross_cursor, &fore_color, &back_color);
XRecolorCursor (FRAME_X_DISPLAY (f), mode_cursor, XRecolorCursor (dpy, hourglass_cursor, &fore_color, &back_color);
&fore_color, &back_color); XRecolorCursor (dpy, horizontal_drag_cursor, &fore_color, &back_color);
XRecolorCursor (FRAME_X_DISPLAY (f), cross_cursor,
&fore_color, &back_color);
XRecolorCursor (FRAME_X_DISPLAY (f), hourglass_cursor,
&fore_color, &back_color);
XRecolorCursor (FRAME_X_DISPLAY (f), horizontal_drag_cursor,
&fore_color, &back_color);
} }
if (FRAME_X_WINDOW (f) != 0) if (FRAME_X_WINDOW (f) != 0)
XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), cursor); XDefineCursor (dpy, FRAME_X_WINDOW (f), cursor);
if (cursor != f->output_data.x->text_cursor if (cursor != x->text_cursor
&& f->output_data.x->text_cursor != 0) && x->text_cursor != 0)
XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->text_cursor); XFreeCursor (dpy, x->text_cursor);
f->output_data.x->text_cursor = cursor; x->text_cursor = cursor;
if (nontext_cursor != f->output_data.x->nontext_cursor if (nontext_cursor != x->nontext_cursor
&& f->output_data.x->nontext_cursor != 0) && x->nontext_cursor != 0)
XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->nontext_cursor); XFreeCursor (dpy, x->nontext_cursor);
f->output_data.x->nontext_cursor = nontext_cursor; x->nontext_cursor = nontext_cursor;
if (hourglass_cursor != f->output_data.x->hourglass_cursor if (hourglass_cursor != x->hourglass_cursor
&& f->output_data.x->hourglass_cursor != 0) && x->hourglass_cursor != 0)
XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->hourglass_cursor); XFreeCursor (dpy, x->hourglass_cursor);
f->output_data.x->hourglass_cursor = hourglass_cursor; x->hourglass_cursor = hourglass_cursor;
if (mode_cursor != f->output_data.x->modeline_cursor if (mode_cursor != x->modeline_cursor
&& f->output_data.x->modeline_cursor != 0) && x->modeline_cursor != 0)
XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->modeline_cursor); XFreeCursor (dpy, f->output_data.x->modeline_cursor);
f->output_data.x->modeline_cursor = mode_cursor; x->modeline_cursor = mode_cursor;
if (cross_cursor != f->output_data.x->cross_cursor if (cross_cursor != x->cross_cursor
&& f->output_data.x->cross_cursor != 0) && x->cross_cursor != 0)
XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->cross_cursor); XFreeCursor (dpy, x->cross_cursor);
f->output_data.x->cross_cursor = cross_cursor; x->cross_cursor = cross_cursor;
if (horizontal_drag_cursor != f->output_data.x->horizontal_drag_cursor if (horizontal_drag_cursor != x->horizontal_drag_cursor
&& f->output_data.x->horizontal_drag_cursor != 0) && x->horizontal_drag_cursor != 0)
XFreeCursor (FRAME_X_DISPLAY (f), f->output_data.x->horizontal_drag_cursor); XFreeCursor (dpy, x->horizontal_drag_cursor);
f->output_data.x->horizontal_drag_cursor = horizontal_drag_cursor; x->horizontal_drag_cursor = horizontal_drag_cursor;
XFlush (FRAME_X_DISPLAY (f)); XFlush (dpy);
UNBLOCK_INPUT; UNBLOCK_INPUT;
update_face_from_frame_parameter (f, Qmouse_color, arg); update_face_from_frame_parameter (f, Qmouse_color, arg);
...@@ -1572,6 +1570,7 @@ x_set_cursor_color (f, arg, oldval) ...@@ -1572,6 +1570,7 @@ x_set_cursor_color (f, arg, oldval)
{ {
unsigned long fore_pixel, pixel; unsigned long fore_pixel, pixel;
int fore_pixel_allocated_p = 0, pixel_allocated_p = 0; int fore_pixel_allocated_p = 0, pixel_allocated_p = 0;
struct x_output *x = f->output_data.x;
if (!NILP (Vx_cursor_fore_pixel)) if (!NILP (Vx_cursor_fore_pixel))
{ {
...@@ -1580,13 +1579,13 @@ x_set_cursor_color (f, arg, oldval) ...@@ -1580,13 +1579,13 @@ x_set_cursor_color (f, arg, oldval)
fore_pixel_allocated_p = 1; fore_pixel_allocated_p = 1;
} }
else else
fore_pixel = f->output_data.x->background_pixel; fore_pixel = x->background_pixel;
pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
pixel_allocated_p = 1; pixel_allocated_p = 1;
/* Make sure that the cursor color differs from the background color. */ /* Make sure that the cursor color differs from the background color. */
if (pixel == f->output_data.x->background_pixel) if (pixel == x->background_pixel)
{ {
if (pixel_allocated_p) if (pixel_allocated_p)
{ {
...@@ -1594,7 +1593,7 @@ x_set_cursor_color (f, arg, oldval) ...@@ -1594,7 +1593,7 @@ x_set_cursor_color (f, arg, oldval)
pixel_allocated_p = 0; pixel_allocated_p = 0;
} }
pixel = f->output_data.x->mouse_pixel; pixel = x->mouse_pixel;
if (pixel == fore_pixel) if (pixel == fore_pixel)
{ {
if (fore_pixel_allocated_p) if (fore_pixel_allocated_p)
...@@ -1602,27 +1601,25 @@ x_set_cursor_color (f, arg, oldval) ...@@ -1602,27 +1601,25 @@ x_set_cursor_color (f, arg, oldval)
x_free_colors (f, &fore_pixel, 1); x_free_colors (f, &fore_pixel, 1);
fore_pixel_allocated_p = 0; fore_pixel_allocated_p = 0;
} }
fore_pixel = f->output_data.x->background_pixel; fore_pixel = x->background_pixel;
} }
} }
unload_color (f, f->output_data.x->cursor_foreground_pixel); unload_color (f, x->cursor_foreground_pixel);
if (!fore_pixel_allocated_p) if (!fore_pixel_allocated_p)
fore_pixel = x_copy_color (f, fore_pixel); fore_pixel = x_copy_color (f, fore_pixel);
f->output_data.x->cursor_foreground_pixel = fore_pixel; x->cursor_foreground_pixel = fore_pixel;
unload_color (f, f->output_data.x->cursor_pixel); unload_color (f, x->cursor_pixel);
if (!pixel_allocated_p) if (!pixel_allocated_p)
pixel = x_copy_color (f, pixel); pixel = x_copy_color (f, pixel);
f->output_data.x->cursor_pixel = pixel; x->cursor_pixel = pixel;
if (FRAME_X_WINDOW (f) != 0) if (FRAME_X_WINDOW (f) != 0)
{ {
BLOCK_INPUT; BLOCK_INPUT;
XSetBackground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc, XSetBackground (FRAME_X_DISPLAY (f), x->cursor_gc, x->cursor_pixel);
f->output_data.x->cursor_pixel); XSetForeground (FRAME_X_DISPLAY (f), x->cursor_gc, fore_pixel);
XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->cursor_gc,
fore_pixel);
UNBLOCK_INPUT; UNBLOCK_INPUT;
if (FRAME_VISIBLE_P (f)) if (FRAME_VISIBLE_P (f))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment