aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2000-03-04 16:02:15 +0000
committerGerd Moellmann2000-03-04 16:02:15 +0000
commit9b2956e2a46ba2eb4ec42834f1bde03019a17e88 (patch)
tree0526331d5502dd0c375a29375e5f77702491d879 /src
parent7353f3a342be6307be00f0319bc50db56c9fdc95 (diff)
downloademacs-9b2956e2a46ba2eb4ec42834f1bde03019a17e88.tar.gz
emacs-9b2956e2a46ba2eb4ec42834f1bde03019a17e88.zip
(x_defined_color, x_set_mouse_color, lookup_rgb_color)
(lookup_pixel_color, x_laplace, x_build_heuristic_mask) (png_load): Access colormap of frame using FRAME_X_COLORMAP. (x_decode_color): Don't handle allocation of white and black specially. (x_window) [USE_X_TOOLKIT]: Set XtNvisual, XtNdepth, and XtNcolormap resources. (x_window) [!USE_X_TOOLKIT]: Pass colormap to XCreateWindow. (Fx_create_frame): Initialize color members of x_output structure. (xpm_load): Pass colormap to XPM lib.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c111
1 files changed, 72 insertions, 39 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 7f61cb602a8..a5f8ac3ba54 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1248,7 +1248,7 @@ x_defined_color (f, color, color_def, alloc)
1248 Display *display = FRAME_X_DISPLAY (f); 1248 Display *display = FRAME_X_DISPLAY (f);
1249 1249
1250 BLOCK_INPUT; 1250 BLOCK_INPUT;
1251 screen_colormap = DefaultColormap (display, XDefaultScreen (display)); 1251 screen_colormap = FRAME_X_COLORMAP (f);
1252 1252
1253 status = XParseColor (display, screen_colormap, color, color_def); 1253 status = XParseColor (display, screen_colormap, color, color_def);
1254 if (status && alloc) 1254 if (status && alloc)
@@ -1325,37 +1325,44 @@ x_defined_color (f, color, color_def, alloc)
1325 return 0; 1325 return 0;
1326} 1326}
1327 1327
1328/* Given a string ARG naming a color, compute a pixel value from it 1328
1329 suitable for screen F. 1329/* Return the pixel color value for color COLOR_NAME on frame F. If F
1330 If F is not a color screen, return DEF (default) regardless of what 1330 is a monochrome frame, return MONO_COLOR regardless of what ARG says.
1331 ARG says. */ 1331 Signal an error if color can't be allocated. */
1332 1332
1333int 1333int
1334x_decode_color (f, arg, def) 1334x_decode_color (f, color_name, mono_color)
1335 FRAME_PTR f; 1335 FRAME_PTR f;
1336 Lisp_Object arg; 1336 Lisp_Object color_name;
1337 int def; 1337 int mono_color;
1338{ 1338{
1339 XColor cdef; 1339 XColor cdef;
1340 1340
1341 CHECK_STRING (arg, 0); 1341 CHECK_STRING (color_name, 0);
1342 1342
1343 if (strcmp (XSTRING (arg)->data, "black") == 0) 1343#if 0 /* Don't do this. It's wrong when we're not using the default
1344 colormap, it makes freeing difficult, and it's probably not
1345 an important optimization. */
1346 if (strcmp (XSTRING (color_name)->data, "black") == 0)
1344 return BLACK_PIX_DEFAULT (f); 1347 return BLACK_PIX_DEFAULT (f);
1345 else if (strcmp (XSTRING (arg)->data, "white") == 0) 1348 else if (strcmp (XSTRING (color_name)->data, "white") == 0)
1346 return WHITE_PIX_DEFAULT (f); 1349 return WHITE_PIX_DEFAULT (f);
1350#endif
1347 1351
1352 /* Return MONO_COLOR for monochrome frames. */
1348 if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1) 1353 if (FRAME_X_DISPLAY_INFO (f)->n_planes == 1)
1349 return def; 1354 return mono_color;
1350 1355
1351 /* x_defined_color is responsible for coping with failures 1356 /* x_defined_color is responsible for coping with failures
1352 by looking for a near-miss. */ 1357 by looking for a near-miss. */
1353 if (x_defined_color (f, XSTRING (arg)->data, &cdef, 1)) 1358 if (x_defined_color (f, XSTRING (color_name)->data, &cdef, 1))
1354 return cdef.pixel; 1359 return cdef.pixel;
1355 1360
1356 Fsignal (Qerror, Fcons (build_string ("undefined color"), 1361 Fsignal (Qerror, Fcons (build_string ("undefined color"),
1357 Fcons (arg, Qnil))); 1362 Fcons (color_name, Qnil)));
1358} 1363}
1364
1365
1359 1366
1360/* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is 1367/* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is
1361 the previous value of that parameter, NEW_VALUE is the new value. */ 1368 the previous value of that parameter, NEW_VALUE is the new value. */
@@ -1534,13 +1541,9 @@ x_set_mouse_color (f, arg, oldval)
1534 1541
1535 fore_color.pixel = f->output_data.x->mouse_pixel; 1542 fore_color.pixel = f->output_data.x->mouse_pixel;
1536 back_color.pixel = mask_color; 1543 back_color.pixel = mask_color;
1537 XQueryColor (FRAME_X_DISPLAY (f), 1544 XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
1538 DefaultColormap (FRAME_X_DISPLAY (f),
1539 DefaultScreen (FRAME_X_DISPLAY (f))),
1540 &fore_color); 1545 &fore_color);
1541 XQueryColor (FRAME_X_DISPLAY (f), 1546 XQueryColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
1542 DefaultColormap (FRAME_X_DISPLAY (f),
1543 DefaultScreen (FRAME_X_DISPLAY (f))),
1544 &back_color); 1547 &back_color);
1545 XRecolorCursor (FRAME_X_DISPLAY (f), cursor, 1548 XRecolorCursor (FRAME_X_DISPLAY (f), cursor,
1546 &fore_color, &back_color); 1549 &fore_color, &back_color);
@@ -2515,8 +2518,6 @@ display_x_get_resource (dpyinfo, attribute, class, component, subclass)
2515 char *name_key; 2518 char *name_key;
2516 char *class_key; 2519 char *class_key;
2517 2520
2518 check_x ();
2519
2520 CHECK_STRING (attribute, 0); 2521 CHECK_STRING (attribute, 0);
2521 CHECK_STRING (class, 0); 2522 CHECK_STRING (class, 0);
2522 2523
@@ -3356,7 +3357,6 @@ x_window (f, window_prompting, minibuffer_only)
3356 XClassHint class_hints; 3357 XClassHint class_hints;
3357 XSetWindowAttributes attributes; 3358 XSetWindowAttributes attributes;
3358 unsigned long attribute_mask; 3359 unsigned long attribute_mask;
3359
3360 Widget shell_widget; 3360 Widget shell_widget;
3361 Widget pane_widget; 3361 Widget pane_widget;
3362 Widget frame_widget; 3362 Widget frame_widget;
@@ -3382,6 +3382,9 @@ x_window (f, window_prompting, minibuffer_only)
3382 XtSetArg (al[ac], XtNinput, 1); ac++; 3382 XtSetArg (al[ac], XtNinput, 1); ac++;
3383 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++; 3383 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
3384 XtSetArg (al[ac], XtNborderWidth, f->output_data.x->border_width); ac++; 3384 XtSetArg (al[ac], XtNborderWidth, f->output_data.x->border_width); ac++;
3385 XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
3386 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
3387 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
3385 shell_widget = XtAppCreateShell (f->namebuf, EMACS_CLASS, 3388 shell_widget = XtAppCreateShell (f->namebuf, EMACS_CLASS,
3386 applicationShellWidgetClass, 3389 applicationShellWidgetClass,
3387 FRAME_X_DISPLAY (f), al, ac); 3390 FRAME_X_DISPLAY (f), al, ac);
@@ -3397,6 +3400,11 @@ x_window (f, window_prompting, minibuffer_only)
3397 (lw_callback) NULL, 3400 (lw_callback) NULL,
3398 (lw_callback) NULL); 3401 (lw_callback) NULL);
3399 3402
3403 ac = 0;
3404 XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
3405 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
3406 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
3407 XtSetValues (pane_widget, al, ac);
3400 f->output_data.x->column_widget = pane_widget; 3408 f->output_data.x->column_widget = pane_widget;
3401 3409
3402 /* mappedWhenManaged to false tells to the paned window to not map/unmap 3410 /* mappedWhenManaged to false tells to the paned window to not map/unmap
@@ -3408,9 +3416,11 @@ x_window (f, window_prompting, minibuffer_only)
3408 XtSetArg (al[ac], XtNallowResize, 1); ac++; 3416 XtSetArg (al[ac], XtNallowResize, 1); ac++;
3409 XtSetArg (al[ac], XtNresizeToPreferred, 1); ac++; 3417 XtSetArg (al[ac], XtNresizeToPreferred, 1); ac++;
3410 XtSetArg (al[ac], XtNemacsFrame, f); ac++; 3418 XtSetArg (al[ac], XtNemacsFrame, f); ac++;
3411 frame_widget = XtCreateWidget (f->namebuf, 3419 XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
3412 emacsFrameClass, 3420 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
3413 pane_widget, al, ac); 3421 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
3422 frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget,
3423 al, ac);
3414 3424
3415 f->output_data.x->edit_widget = frame_widget; 3425 f->output_data.x->edit_widget = frame_widget;
3416 3426
@@ -3586,11 +3596,9 @@ x_window (f)
3586 attributes.backing_store = NotUseful; 3596 attributes.backing_store = NotUseful;
3587 attributes.save_under = True; 3597 attributes.save_under = True;
3588 attributes.event_mask = STANDARD_EVENT_SET; 3598 attributes.event_mask = STANDARD_EVENT_SET;
3589 attribute_mask = (CWBackPixel | CWBorderPixel | CWBitGravity 3599 attributes.colormap = FRAME_X_COLORMAP (f);
3590#if 0 3600 attribute_mask = (CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask
3591 | CWBackingStore | CWSaveUnder 3601 | CWColormap);
3592#endif
3593 | CWEventMask);
3594 3602
3595 BLOCK_INPUT; 3603 BLOCK_INPUT;
3596 FRAME_X_WINDOW (f) 3604 FRAME_X_WINDOW (f)
@@ -3894,6 +3902,29 @@ This function is an internal primitive--use `make-frame' instead.")
3894 FRAME_KBOARD (f) = kb; 3902 FRAME_KBOARD (f) = kb;
3895#endif 3903#endif
3896 3904
3905 /* These colors will be set anyway later, but it's important
3906 to get the color reference counts right, so initialize them! */
3907 {
3908 Lisp_Object black;
3909 struct gcpro gcpro1;
3910
3911 black = build_string ("black");
3912 GCPRO1 (black);
3913 f->output_data.x->foreground_pixel
3914 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3915 f->output_data.x->background_pixel
3916 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3917 f->output_data.x->cursor_pixel
3918 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3919 f->output_data.x->cursor_foreground_pixel
3920 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3921 f->output_data.x->border_pixel
3922 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3923 f->output_data.x->mouse_pixel
3924 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3925 UNGCPRO;
3926 }
3927
3897 /* Specify the parent under which to make this X window. */ 3928 /* Specify the parent under which to make this X window. */
3898 3929
3899 if (!NILP (parent)) 3930 if (!NILP (parent))
@@ -7254,8 +7285,10 @@ xpm_load (f, img)
7254 /* Configure the XPM lib. Use the visual of frame F. Allocate 7285 /* Configure the XPM lib. Use the visual of frame F. Allocate
7255 close colors. Return colors allocated. */ 7286 close colors. Return colors allocated. */
7256 bzero (&attrs, sizeof attrs); 7287 bzero (&attrs, sizeof attrs);
7257 attrs.visual = FRAME_X_DISPLAY_INFO (f)->visual; 7288 attrs.visual = FRAME_X_VISUAL (f);
7289 attrs.colormap = FRAME_X_COLORMAP (f);
7258 attrs.valuemask |= XpmVisual; 7290 attrs.valuemask |= XpmVisual;
7291 attrs.valuemask |= XpmColormap;
7259 attrs.valuemask |= XpmReturnAllocPixels; 7292 attrs.valuemask |= XpmReturnAllocPixels;
7260#ifdef XpmAllocCloseColors 7293#ifdef XpmAllocCloseColors
7261 attrs.alloc_close_colors = 1; 7294 attrs.alloc_close_colors = 1;
@@ -7480,7 +7513,7 @@ lookup_rgb_color (f, r, g, b)
7480 color.blue = b; 7513 color.blue = b;
7481 7514
7482 BLOCK_INPUT; 7515 BLOCK_INPUT;
7483 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); 7516 cmap = FRAME_X_COLORMAP (f);
7484 rc = x_alloc_nearest_color (f, cmap, &color); 7517 rc = x_alloc_nearest_color (f, cmap, &color);
7485 UNBLOCK_INPUT; 7518 UNBLOCK_INPUT;
7486 7519
@@ -7527,7 +7560,7 @@ lookup_pixel_color (f, pixel)
7527 7560
7528 BLOCK_INPUT; 7561 BLOCK_INPUT;
7529 7562
7530 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); 7563 cmap = FRAME_X_COLORMAP (f);
7531 color.pixel = pixel; 7564 color.pixel = pixel;
7532 XQueryColor (FRAME_X_DISPLAY (f), cmap, &color); 7565 XQueryColor (FRAME_X_DISPLAY (f), cmap, &color);
7533 rc = x_alloc_nearest_color (f, cmap, &color); 7566 rc = x_alloc_nearest_color (f, cmap, &color);
@@ -7645,7 +7678,7 @@ x_laplace (f, img)
7645 struct frame *f; 7678 struct frame *f;
7646 struct image *img; 7679 struct image *img;
7647{ 7680{
7648 Colormap cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); 7681 Colormap cmap = FRAME_X_COLORMAP (f);
7649 XImage *ximg, *oimg; 7682 XImage *ximg, *oimg;
7650 XColor *in[3]; 7683 XColor *in[3];
7651 long *out; 7684 long *out;
@@ -7783,7 +7816,7 @@ x_build_heuristic_mask (f, img, how)
7783 7816
7784 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); 7817 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
7785 7818
7786 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); 7819 cmap = FRAME_X_COLORMAP (f);
7787 if (XLookupColor (dpy, cmap, color_name, &exact, &color)) 7820 if (XLookupColor (dpy, cmap, color_name, &exact, &color))
7788 { 7821 {
7789 bg = color.pixel; 7822 bg = color.pixel;
@@ -8519,7 +8552,7 @@ png_load (f, img)
8519 png_color_16 frame_background; 8552 png_color_16 frame_background;
8520 8553
8521 BLOCK_INPUT; 8554 BLOCK_INPUT;
8522 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); 8555 cmap = FRAME_X_COLORMAP (f);
8523 color.pixel = FRAME_BACKGROUND_PIXEL (f); 8556 color.pixel = FRAME_BACKGROUND_PIXEL (f);
8524 XQueryColor (FRAME_X_DISPLAY (f), cmap, &color); 8557 XQueryColor (FRAME_X_DISPLAY (f), cmap, &color);
8525 UNBLOCK_INPUT; 8558 UNBLOCK_INPUT;
@@ -10400,8 +10433,8 @@ x_create_tip_frame (dpyinfo, parms)
10400 10433
10401 BLOCK_INPUT; 10434 BLOCK_INPUT;
10402 mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask; 10435 mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;
10403 /* Window managers looks at the override-redirect flag to 10436 /* Window managers look at the override-redirect flag to determine
10404 determine whether or net to give windows a decoration (Xlib 10437 whether or net to give windows a decoration (Xlib spec, chapter
10405 3.2.8). */ 10438 3.2.8). */
10406 attrs.override_redirect = True; 10439 attrs.override_redirect = True;
10407 attrs.save_under = True; 10440 attrs.save_under = True;