Mercurial > emacs
comparison src/xfns.c @ 27987:ce9edc646960
(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.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sat, 04 Mar 2000 16:02:15 +0000 |
parents | 0e2c6e5cca6e |
children | 3a34e2d1bf3c |
comparison
equal
deleted
inserted
replaced
27986:8cc3bff16c28 | 27987:ce9edc646960 |
---|---|
1246 register int status; | 1246 register int status; |
1247 Colormap screen_colormap; | 1247 Colormap screen_colormap; |
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) |
1255 { | 1255 { |
1256 /* Apply gamma correction. */ | 1256 /* Apply gamma correction. */ |
1323 return 1; | 1323 return 1; |
1324 else | 1324 else |
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 |
1333 int | 1333 int |
1334 x_decode_color (f, arg, def) | 1334 x_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); |
1347 | 1350 #endif |
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. */ |
1362 | 1369 |
1363 static void | 1370 static void |
1532 { | 1539 { |
1533 XColor fore_color, back_color; | 1540 XColor fore_color, back_color; |
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); |
1547 XRecolorCursor (FRAME_X_DISPLAY (f), nontext_cursor, | 1550 XRecolorCursor (FRAME_X_DISPLAY (f), nontext_cursor, |
1548 &fore_color, &back_color); | 1551 &fore_color, &back_color); |
2512 Lisp_Object attribute, class, component, subclass; | 2515 Lisp_Object attribute, class, component, subclass; |
2513 { | 2516 { |
2514 register char *value; | 2517 register char *value; |
2515 char *name_key; | 2518 char *name_key; |
2516 char *class_key; | 2519 char *class_key; |
2517 | |
2518 check_x (); | |
2519 | 2520 |
2520 CHECK_STRING (attribute, 0); | 2521 CHECK_STRING (attribute, 0); |
2521 CHECK_STRING (class, 0); | 2522 CHECK_STRING (class, 0); |
2522 | 2523 |
2523 if (!NILP (component)) | 2524 if (!NILP (component)) |
3354 int minibuffer_only; | 3355 int minibuffer_only; |
3355 { | 3356 { |
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; |
3363 Arg al [25]; | 3363 Arg al [25]; |
3364 int ac; | 3364 int ac; |
3380 ac = 0; | 3380 ac = 0; |
3381 XtSetArg (al[ac], XtNallowShellResize, 1); ac++; | 3381 XtSetArg (al[ac], XtNallowShellResize, 1); ac++; |
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); |
3388 | 3391 |
3389 f->output_data.x->widget = shell_widget; | 3392 f->output_data.x->widget = shell_widget; |
3395 (lw_callback) NULL, | 3398 (lw_callback) NULL, |
3396 (lw_callback) NULL, | 3399 (lw_callback) NULL, |
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 |
3403 the emacs screen when changing menubar. This reduces flickering. */ | 3411 the emacs screen when changing menubar. This reduces flickering. */ |
3404 | 3412 |
3406 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++; | 3414 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++; |
3407 XtSetArg (al[ac], XtNshowGrip, 0); ac++; | 3415 XtSetArg (al[ac], XtNshowGrip, 0); ac++; |
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 |
3417 XtManageChild (frame_widget); | 3427 XtManageChild (frame_widget); |
3418 | 3428 |
3584 attributes.border_pixel = f->output_data.x->border_pixel; | 3594 attributes.border_pixel = f->output_data.x->border_pixel; |
3585 attributes.bit_gravity = StaticGravity; | 3595 attributes.bit_gravity = StaticGravity; |
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) |
3597 = XCreateWindow (FRAME_X_DISPLAY (f), | 3605 = XCreateWindow (FRAME_X_DISPLAY (f), |
3598 f->output_data.x->parent_desc, | 3606 f->output_data.x->parent_desc, |
3891 | 3899 |
3892 FRAME_X_DISPLAY_INFO (f) = dpyinfo; | 3900 FRAME_X_DISPLAY_INFO (f) = dpyinfo; |
3893 #ifdef MULTI_KBOARD | 3901 #ifdef MULTI_KBOARD |
3894 FRAME_KBOARD (f) = kb; | 3902 FRAME_KBOARD (f) = kb; |
3895 #endif | 3903 #endif |
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 } | |
3896 | 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)) |
3900 { | 3931 { |
7252 Lisp_Object specified_file, color_symbols; | 7283 Lisp_Object specified_file, color_symbols; |
7253 | 7284 |
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; |
7262 attrs.valuemask |= XpmAllocCloseColors; | 7295 attrs.valuemask |= XpmAllocCloseColors; |
7263 #else | 7296 #else |
7478 color.red = r; | 7511 color.red = r; |
7479 color.green = g; | 7512 color.green = g; |
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 |
7487 if (rc) | 7520 if (rc) |
7488 { | 7521 { |
7525 Colormap cmap; | 7558 Colormap cmap; |
7526 int rc; | 7559 int rc; |
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); |
7534 UNBLOCK_INPUT; | 7567 UNBLOCK_INPUT; |
7535 | 7568 |
7643 static void | 7676 static void |
7644 x_laplace (f, img) | 7677 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; |
7652 Pixmap pixmap; | 7685 Pixmap pixmap; |
7653 int x, y, i; | 7686 int x, y, i; |
7781 XColor exact, color; | 7814 XColor exact, color; |
7782 Colormap cmap; | 7815 Colormap cmap; |
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; |
7790 look_at_corners_p = 0; | 7823 look_at_corners_p = 0; |
7791 } | 7824 } |
8517 XColor color; | 8550 XColor color; |
8518 Colormap cmap; | 8551 Colormap cmap; |
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; |
8526 | 8559 |
8527 bzero (&frame_background, sizeof frame_background); | 8560 bzero (&frame_background, sizeof frame_background); |
10398 XSetWindowAttributes attrs; | 10431 XSetWindowAttributes attrs; |
10399 unsigned long mask; | 10432 unsigned long mask; |
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; |
10408 attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f); | 10441 attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f); |
10409 /* Arrange for getting MapNotify and UnmapNotify events. */ | 10442 /* Arrange for getting MapNotify and UnmapNotify events. */ |