X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/9f7e52b4de1a3e79d69002c3d5491dde26826f01..8030369ccb5c871d3ce11b96c220f318bc741ed8:/src/xfns.c diff --git a/src/xfns.c b/src/xfns.c index 7132aa858c..4f23af432c 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -185,7 +185,7 @@ Lisp_Object Vx_pixel_size_width_font_regexp; Lisp_Object Qauto_raise; Lisp_Object Qauto_lower; -Lisp_Object Qbar; +Lisp_Object Qbar, Qhbar; Lisp_Object Qborder_color; Lisp_Object Qborder_width; Lisp_Object Qbox; @@ -219,6 +219,10 @@ Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; Lisp_Object Qscreen_gamma, Qline_spacing, Qcenter; Lisp_Object Qcompound_text, Qcancel_timer; Lisp_Object Qwait_for_wm; +Lisp_Object Qfullscreen; +Lisp_Object Qfullwidth; +Lisp_Object Qfullheight; +Lisp_Object Qfullboth; /* The below are defined in frame.c. */ @@ -297,12 +301,7 @@ check_x_display_info (frame) dpyinfo = x_display_info_for_name (frame); else { - FRAME_PTR f; - - CHECK_LIVE_FRAME (frame); - f = XFRAME (frame); - if (! FRAME_X_P (f)) - error ("Non-X frame used"); + FRAME_PTR f = check_x_frame (frame); dpyinfo = FRAME_X_DISPLAY_INFO (f); } @@ -637,7 +636,7 @@ x_create_bitmap_from_file (f, file) { if (dpyinfo->bitmaps[id].refcount && dpyinfo->bitmaps[id].file - && !strcmp (dpyinfo->bitmaps[id].file, (char *) XSTRING (file)->data)) + && !strcmp (dpyinfo->bitmaps[id].file, (char *) SDATA (file))) { ++dpyinfo->bitmaps[id].refcount; return id + 1; @@ -645,12 +644,12 @@ x_create_bitmap_from_file (f, file) } /* Search bitmap-file-path for the file, if appropriate. */ - fd = openp (Vx_bitmap_file_path, file, Qnil, &found, 0); + fd = openp (Vx_bitmap_file_path, file, Qnil, &found, Qnil); if (fd < 0) return -1; emacs_close (fd); - filename = (char *) XSTRING (found)->data; + filename = (char *) SDATA (found); result = XReadBitmapFile (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), filename, &width, &height, &bitmap, &xhot, &yhot); @@ -661,11 +660,11 @@ x_create_bitmap_from_file (f, file) dpyinfo->bitmaps[id - 1].pixmap = bitmap; dpyinfo->bitmaps[id - 1].refcount = 1; dpyinfo->bitmaps[id - 1].file - = (char *) xmalloc (STRING_BYTES (XSTRING (file)) + 1); + = (char *) xmalloc (SBYTES (file) + 1); dpyinfo->bitmaps[id - 1].depth = 1; dpyinfo->bitmaps[id - 1].height = height; dpyinfo->bitmaps[id - 1].width = width; - strcpy (dpyinfo->bitmaps[id - 1].file, XSTRING (file)->data); + strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file)); return id; } @@ -733,6 +732,7 @@ static void x_disable_image P_ ((struct frame *, struct image *)); void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); static void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object)); static void x_set_wait_for_wm P_ ((struct frame *, Lisp_Object, Lisp_Object)); +static void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); @@ -740,6 +740,7 @@ void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object)); +static void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_internal_border_width P_ ((struct frame *, Lisp_Object, @@ -777,32 +778,36 @@ static unsigned long lookup_pixel_color P_ ((struct frame *f, unsigned long p)); static struct x_frame_parm_table x_frame_parms[] = { - "auto-raise", x_set_autoraise, - "auto-lower", x_set_autolower, - "background-color", x_set_background_color, - "border-color", x_set_border_color, - "border-width", x_set_border_width, - "cursor-color", x_set_cursor_color, - "cursor-type", x_set_cursor_type, - "font", x_set_font, - "foreground-color", x_set_foreground_color, - "icon-name", x_set_icon_name, - "icon-type", x_set_icon_type, - "internal-border-width", x_set_internal_border_width, - "menu-bar-lines", x_set_menu_bar_lines, - "mouse-color", x_set_mouse_color, - "name", x_explicitly_set_name, - "scroll-bar-width", x_set_scroll_bar_width, - "title", x_set_title, - "unsplittable", x_set_unsplittable, - "vertical-scroll-bars", x_set_vertical_scroll_bars, - "visibility", x_set_visibility, - "tool-bar-lines", x_set_tool_bar_lines, - "scroll-bar-foreground", x_set_scroll_bar_foreground, - "scroll-bar-background", x_set_scroll_bar_background, - "screen-gamma", x_set_screen_gamma, - "line-spacing", x_set_line_spacing, - "wait-for-wm", x_set_wait_for_wm + {"auto-raise", x_set_autoraise}, + {"auto-lower", x_set_autolower}, + {"background-color", x_set_background_color}, + {"border-color", x_set_border_color}, + {"border-width", x_set_border_width}, + {"cursor-color", x_set_cursor_color}, + {"cursor-type", x_set_cursor_type}, + {"font", x_set_font}, + {"foreground-color", x_set_foreground_color}, + {"icon-name", x_set_icon_name}, + {"icon-type", x_set_icon_type}, + {"internal-border-width", x_set_internal_border_width}, + {"menu-bar-lines", x_set_menu_bar_lines}, + {"mouse-color", x_set_mouse_color}, + {"name", x_explicitly_set_name}, + {"scroll-bar-width", x_set_scroll_bar_width}, + {"title", x_set_title}, + {"unsplittable", x_set_unsplittable}, + {"vertical-scroll-bars", x_set_vertical_scroll_bars}, + {"visibility", x_set_visibility}, + {"tool-bar-lines", x_set_tool_bar_lines}, + {"scroll-bar-foreground", x_set_scroll_bar_foreground}, + {"scroll-bar-background", x_set_scroll_bar_background}, + {"screen-gamma", x_set_screen_gamma}, + {"line-spacing", x_set_line_spacing}, + {"left-fringe", x_set_fringe_width}, + {"right-fringe", x_set_fringe_width}, + {"wait-for-wm", x_set_wait_for_wm}, + {"fullscreen", x_set_fullscreen}, + }; /* Attach the `x-frame-parameter' properties to @@ -818,6 +823,28 @@ init_x_parm_symbols () make_number (i)); } + +/* Really try to move where we want to be in case of fullscreen. Some WMs + moves the window where we tell them. Some (mwm, twm) moves the outer + window manager window there instead. + Try to compensate for those WM here. */ +static void +x_fullscreen_move (f, new_top, new_left) + struct frame *f; + int new_top; + int new_left; +{ + if (new_top != f->output_data.x->top_pos + || new_left != f->output_data.x->left_pos) + { + int move_x = new_left + f->output_data.x->x_pixels_outer_diff; + int move_y = new_top + f->output_data.x->y_pixels_outer_diff; + + f->output_data.x->want_fullscreen |= FULLSCREEN_MOVE_WAIT; + x_set_offset (f, move_x, move_y, 1); + } +} + /* Change the parameters of frame F as specified by ALIST. If a parameter is not specially recognized, do nothing special; otherwise call the `x_set_...' function for that parameter. @@ -848,6 +875,7 @@ x_set_frame_parameters (f, alist) int i, p; int left_no_change = 0, top_no_change = 0; int icon_left_no_change = 0, icon_top_no_change = 0; + int fullscreen_is_being_set = 0; struct gcpro gcpro1, gcpro2; @@ -896,17 +924,23 @@ x_set_frame_parameters (f, alist) /* Process foreground_color and background_color before anything else. They are independent of other properties, but other properties (e.g., cursor_color) are dependent upon them. */ + /* Process default font as well, since fringe widths depends on it. */ + /* Also, process fullscreen, width and height depend upon that */ for (p = 0; p < i; p++) { Lisp_Object prop, val; prop = parms[p]; val = values[p]; - if (EQ (prop, Qforeground_color) || EQ (prop, Qbackground_color)) + if (EQ (prop, Qforeground_color) + || EQ (prop, Qbackground_color) + || EQ (prop, Qfont) + || EQ (prop, Qfullscreen)) { register Lisp_Object param_index, old_value; old_value = get_frame_param (f, prop); + fullscreen_is_being_set |= EQ (prop, Qfullscreen); if (NILP (Fequal (val, old_value))) { @@ -941,7 +975,10 @@ x_set_frame_parameters (f, alist) icon_top = val; else if (EQ (prop, Qicon_left)) icon_left = val; - else if (EQ (prop, Qforeground_color) || EQ (prop, Qbackground_color)) + else if (EQ (prop, Qforeground_color) + || EQ (prop, Qbackground_color) + || EQ (prop, Qfont) + || EQ (prop, Qfullscreen)) /* Processed above. */ continue; else @@ -994,6 +1031,21 @@ x_set_frame_parameters (f, alist) XSETINT (icon_top, 0); } + if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set) + { + /* If the frame is visible already and the fullscreen parameter is + being set, it is too late to set WM manager hints to specify + size and position. + Here we first get the width, height and position that applies to + fullscreen. We then move the frame to the appropriate + position. Resize of the frame is taken care of in the code after + this if-statement. */ + int new_left, new_top; + + x_fullscreen_adjust (f, &width, &height, &new_top, &new_left); + x_fullscreen_move (f, new_top, new_left); + } + /* Don't set these parameters unless they've been explicitly specified. The window might be mapped or resized while we're in this function, and we don't want to override that unless the lisp @@ -1096,70 +1148,115 @@ x_real_positions (f, xptr, yptr) FRAME_PTR f; int *xptr, *yptr; { - int win_x, win_y; - Window child; + int win_x, win_y, outer_x, outer_y; + int real_x = 0, real_y = 0; + int had_errors = 0; + Window win = f->output_data.x->parent_desc; - /* This is pretty gross, but seems to be the easiest way out of - the problem that arises when restarting window-managers. */ + int count; -#ifdef USE_X_TOOLKIT - Window outer = (f->output_data.x->widget - ? XtWindow (f->output_data.x->widget) - : FRAME_X_WINDOW (f)); -#else - Window outer = f->output_data.x->window_desc; -#endif - Window tmp_root_window; - Window *tmp_children; - unsigned int tmp_nchildren; + BLOCK_INPUT; + + count = x_catch_errors (FRAME_X_DISPLAY (f)); - while (1) + if (win == FRAME_X_DISPLAY_INFO (f)->root_window) + win = FRAME_OUTER_WINDOW (f); + + /* This loop traverses up the containment tree until we hit the root + window. Window managers may intersect many windows between our window + and the root window. The window we find just before the root window + should be the outer WM window. */ + for (;;) { - int count = x_catch_errors (FRAME_X_DISPLAY (f)); - Window outer_window; + Window wm_window, rootw; + Window *tmp_children; + unsigned int tmp_nchildren; + int success; - XQueryTree (FRAME_X_DISPLAY (f), outer, &tmp_root_window, - &f->output_data.x->parent_desc, - &tmp_children, &tmp_nchildren); - XFree ((char *) tmp_children); + success = XQueryTree (FRAME_X_DISPLAY (f), win, &rootw, + &wm_window, &tmp_children, &tmp_nchildren); - win_x = win_y = 0; + had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); - /* Find the position of the outside upper-left corner of - the inner window, with respect to the outer window. */ - if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) - outer_window = f->output_data.x->parent_desc; - else - outer_window = outer; + /* Don't free tmp_children if XQueryTree failed. */ + if (! success) + break; + + XFree ((char *) tmp_children); + + if (wm_window == rootw || had_errors) + break; + win = wm_window; + } + + if (! had_errors) + { + int ign; + Window child, rootw; + + /* Get the real coordinates for the WM window upper left corner */ + XGetGeometry (FRAME_X_DISPLAY (f), win, + &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); + + /* Translate real coordinates to coordinates relative to our + window. For our window, the upper left corner is 0, 0. + Since the upper left corner of the WM window is outside + our window, win_x and win_y will be negative: + + ------------------ ---> x + | title | + | ----------------- v y + | | our window + */ XTranslateCoordinates (FRAME_X_DISPLAY (f), /* From-window, to-window. */ - outer_window, FRAME_X_DISPLAY_INFO (f)->root_window, + FRAME_X_WINDOW (f), /* From-position, to-position. */ - 0, 0, &win_x, &win_y, + real_x, real_y, &win_x, &win_y, /* Child of win. */ &child); - /* It is possible for the window returned by the XQueryNotify - to become invalid by the time we call XTranslateCoordinates. - That can happen when you restart some window managers. - If so, we get an error in XTranslateCoordinates. - Detect that and try the whole thing over. */ - if (! x_had_errors_p (FRAME_X_DISPLAY (f))) + if (FRAME_X_WINDOW (f) == FRAME_OUTER_WINDOW (f)) { - x_uncatch_errors (FRAME_X_DISPLAY (f), count); - break; + outer_x = win_x; + outer_y = win_y; } + else + { + XTranslateCoordinates (FRAME_X_DISPLAY (f), - x_uncatch_errors (FRAME_X_DISPLAY (f), count); + /* From-window, to-window. */ + FRAME_X_DISPLAY_INFO (f)->root_window, + FRAME_OUTER_WINDOW (f), + + /* From-position, to-position. */ + real_x, real_y, &outer_x, &outer_y, + + /* Child of win. */ + &child); } - *xptr = win_x; - *yptr = win_y; + had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); + } + + x_uncatch_errors (FRAME_X_DISPLAY (f), count); + + UNBLOCK_INPUT; + + if (had_errors) return; + + f->output_data.x->x_pixels_diff = -win_x; + f->output_data.x->y_pixels_diff = -win_y; + f->output_data.x->x_pixels_outer_diff = -outer_x; + f->output_data.x->y_pixels_outer_diff = -outer_y; + + *xptr = real_x; + *yptr = real_y; } /* Insert a description of internally-recorded parameters of frame X @@ -1194,6 +1291,14 @@ x_report_frame_params (f, alistptr) make_number (f->output_data.x->border_width)); store_in_alist (alistptr, Qinternal_border_width, make_number (f->output_data.x->internal_border_width)); + store_in_alist (alistptr, Qleft_fringe, + make_number (f->output_data.x->left_fringe_width)); + store_in_alist (alistptr, Qright_fringe, + make_number (f->output_data.x->right_fringe_width)); + store_in_alist (alistptr, Qscroll_bar_width, + make_number (FRAME_HAS_VERTICAL_SCROLL_BARS (f) + ? FRAME_SCROLL_BAR_PIXEL_WIDTH(f) + : 0)); sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f)); store_in_alist (alistptr, Qwindow_id, build_string (buf)); @@ -1280,9 +1385,9 @@ x_decode_color (f, color_name, mono_color) #if 0 /* Don't do this. It's wrong when we're not using the default colormap, it makes freeing difficult, and it's probably not an important optimization. */ - if (strcmp (XSTRING (color_name)->data, "black") == 0) + if (strcmp (SDATA (color_name), "black") == 0) return BLACK_PIX_DEFAULT (f); - else if (strcmp (XSTRING (color_name)->data, "white") == 0) + else if (strcmp (SDATA (color_name), "white") == 0) return WHITE_PIX_DEFAULT (f); #endif @@ -1292,7 +1397,7 @@ x_decode_color (f, color_name, mono_color) /* x_defined_color is responsible for coping with failures by looking for a near-miss. */ - if (x_defined_color (f, XSTRING (color_name)->data, &cdef, 1)) + if (x_defined_color (f, SDATA (color_name), &cdef, 1)) return cdef.pixel; Fsignal (Qerror, Fcons (build_string ("Undefined color"), @@ -1335,6 +1440,25 @@ x_set_wait_for_wm (f, new_value, old_value) } +/* Change the `fullscreen' frame parameter of frame F. OLD_VALUE is + the previous value of that parameter, NEW_VALUE is the new value. */ + +static void +x_set_fullscreen (f, new_value, old_value) + struct frame *f; + Lisp_Object new_value, old_value; +{ + if (NILP (new_value)) + f->output_data.x->want_fullscreen = FULLSCREEN_NONE; + else if (EQ (new_value, Qfullboth)) + f->output_data.x->want_fullscreen = FULLSCREEN_BOTH; + else if (EQ (new_value, Qfullwidth)) + f->output_data.x->want_fullscreen = FULLSCREEN_WIDTH; + else if (EQ (new_value, Qfullheight)) + f->output_data.x->want_fullscreen = FULLSCREEN_HEIGHT; +} + + /* Change the `screen-gamma' frame parameter of frame F. OLD_VALUE is the previous value of that parameter, NEW_VALUE is the new value. */ @@ -1521,7 +1645,7 @@ x_set_mouse_color (f, arg, oldval) = XCreateFontCursor (dpy, XINT (Vx_sensitive_text_pointer_shape)); } else - cross_cursor = XCreateFontCursor (dpy, XC_crosshair); + cross_cursor = XCreateFontCursor (dpy, XC_hand2); if (!NILP (Vx_window_horizontal_drag_shape)) { @@ -1734,6 +1858,19 @@ x_specified_cursor_type (arg, width) type = BAR_CURSOR; *width = XINT (XCDR (arg)); } + else if (EQ (arg, Qhbar)) + { + type = HBAR_CURSOR; + *width = 2; + } + else if (CONSP (arg) + && EQ (XCAR (arg), Qhbar) + && INTEGERP (XCDR (arg)) + && XINT (XCDR (arg)) >= 0) + { + type = HBAR_CURSOR; + *width = XINT (XCDR (arg)); + } else if (NILP (arg)) type = NO_CURSOR; else @@ -1755,9 +1892,8 @@ x_set_cursor_type (f, arg, oldval) FRAME_DESIRED_CURSOR (f) = x_specified_cursor_type (arg, &width); f->output_data.x->cursor_width = width; - /* Make sure the cursor gets redrawn. This is overkill, but how - often do people change cursor types? */ - update_mode_lines++; + /* Make sure the cursor gets redrawn. */ + cursor_type_changed = 1; } void @@ -1778,9 +1914,9 @@ x_set_icon_type (f, arg, oldval) BLOCK_INPUT; if (NILP (arg)) result = x_text_icon (f, - (char *) XSTRING ((!NILP (f->icon_name) + (char *) SDATA ((!NILP (f->icon_name) ? f->icon_name - : f->name))->data); + : f->name))); else result = x_bitmap_icon (f, arg); @@ -1832,11 +1968,11 @@ x_set_icon_name (f, arg, oldval) BLOCK_INPUT; result = x_text_icon (f, - (char *) XSTRING ((!NILP (f->icon_name) - ? f->icon_name - : !NILP (f->title) - ? f->title - : f->name))->data); + (char *) SDATA ((!NILP (f->icon_name) + ? f->icon_name + : !NILP (f->title) + ? f->title + : f->name))); if (result) { @@ -1864,12 +2000,12 @@ x_set_font (f, arg, oldval) BLOCK_INPUT; result = (STRINGP (fontset_name) - ? x_new_fontset (f, XSTRING (fontset_name)->data) - : x_new_font (f, XSTRING (arg)->data)); + ? x_new_fontset (f, SDATA (fontset_name)) + : x_new_font (f, SDATA (arg))); UNBLOCK_INPUT; if (EQ (result, Qnil)) - error ("Font `%s' is not defined", XSTRING (arg)->data); + error ("Font `%s' is not defined", SDATA (arg)); else if (EQ (result, Qt)) error ("The characters of the given font have varying widths"); else if (STRINGP (result)) @@ -1904,6 +2040,14 @@ x_set_font (f, arg, oldval) } } +static void +x_set_fringe_width (f, new_value, old_value) + struct frame *f; + Lisp_Object new_value, old_value; +{ + x_compute_fringe_widths (f, 1); +} + void x_set_border_width (f, arg, oldval) struct frame *f; @@ -2214,6 +2358,10 @@ x_set_scroll_bar_background (f, value, oldval) CODING_SYSTEM, and return a newly allocated memory area which should be freed by `xfree' by a caller. + SELECTIONP non-zero means the string is being encoded for an X + selection, so it is safe to run pre-write conversions (which + may run Lisp code). + Store the byte length of resulting text in *TEXT_BYTES. If the text contains only ASCII and Latin-1, store 1 in *STRING_P, @@ -2222,17 +2370,19 @@ x_set_scroll_bar_background (f, value, oldval) the result should be `COMPOUND_TEXT'. */ unsigned char * -x_encode_text (string, coding_system, text_bytes, stringp) +x_encode_text (string, coding_system, selectionp, text_bytes, stringp) Lisp_Object string, coding_system; int *text_bytes, *stringp; + int selectionp; { - unsigned char *str = XSTRING (string)->data; - int chars = XSTRING (string)->size; - int bytes = STRING_BYTES (XSTRING (string)); + unsigned char *str = SDATA (string); + int chars = SCHARS (string); + int bytes = SBYTES (string); int charset_info; int bufsize; unsigned char *buf; struct coding_system coding; + extern Lisp_Object Qcompound_text_with_extensions; charset_info = find_charset_in_text (str, chars, bytes, NULL, Qnil); if (charset_info == 0) @@ -2244,6 +2394,15 @@ x_encode_text (string, coding_system, text_bytes, stringp) } setup_coding_system (coding_system, &coding); + if (selectionp + && SYMBOLP (coding.pre_write_conversion) + && !NILP (Ffboundp (coding.pre_write_conversion))) + { + string = run_pre_post_conversion_on_str (string, &coding, 1); + str = SDATA (string); + chars = SCHARS (string); + bytes = SBYTES (string); + } coding.src_multibyte = 1; coding.dst_multibyte = 0; coding.mode |= CODING_MODE_LAST_BLOCK; @@ -2255,7 +2414,9 @@ x_encode_text (string, coding_system, text_bytes, stringp) buf = (unsigned char *) xmalloc (bufsize); encode_coding (&coding, str, buf, bytes, bufsize); *text_bytes = coding.produced; - *stringp = (charset_info == 1 || !EQ (coding_system, Qcompound_text)); + *stringp = (charset_info == 1 + || (!EQ (coding_system, Qcompound_text) + && !EQ (coding_system, Qcompound_text_with_extensions))); return buf; } @@ -2297,7 +2458,7 @@ x_set_name (f, name, explicit) /* Check for no change needed in this very common case before we do any consing. */ if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name, - XSTRING (f->name)->data)) + SDATA (f->name))) return; name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name); } @@ -2327,7 +2488,7 @@ x_set_name (f, name, explicit) coding_system = Vlocale_coding_system; if (NILP (coding_system)) coding_system = Qcompound_text; - text.value = x_encode_text (name, coding_system, &bytes, &stringp); + text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); text.encoding = (stringp ? XA_STRING : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); text.format = 8; @@ -2339,7 +2500,7 @@ x_set_name (f, name, explicit) } else { - icon.value = x_encode_text (f->icon_name, coding_system, + icon.value = x_encode_text (f->icon_name, coding_system, 0, &bytes, &stringp); icon.encoding = (stringp ? XA_STRING : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); @@ -2356,16 +2517,16 @@ x_set_name (f, name, explicit) XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &icon); #endif /* not USE_X_TOOLKIT */ if (!NILP (f->icon_name) - && icon.value != XSTRING (f->icon_name)->data) + && icon.value != SDATA (f->icon_name)) xfree (icon.value); - if (text.value != XSTRING (name)->data) + if (text.value != SDATA (name)) xfree (text.value); } #else /* not HAVE_X11R4 */ XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (name)->data); + SDATA (name)); XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (name)->data); + SDATA (name)); #endif /* not HAVE_X11R4 */ UNBLOCK_INPUT; } @@ -2434,7 +2595,7 @@ x_set_title (f, name, old_name) coding_system = Vlocale_coding_system; if (NILP (coding_system)) coding_system = Qcompound_text; - text.value = x_encode_text (name, coding_system, &bytes, &stringp); + text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); text.encoding = (stringp ? XA_STRING : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); text.format = 8; @@ -2446,7 +2607,7 @@ x_set_title (f, name, old_name) } else { - icon.value = x_encode_text (f->icon_name, coding_system, + icon.value = x_encode_text (f->icon_name, coding_system, 0, &bytes, &stringp); icon.encoding = (stringp ? XA_STRING : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); @@ -2463,16 +2624,16 @@ x_set_title (f, name, old_name) XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &icon); #endif /* not USE_X_TOOLKIT */ if (!NILP (f->icon_name) - && icon.value != XSTRING (f->icon_name)->data) + && icon.value != SDATA (f->icon_name)) xfree (icon.value); - if (text.value != XSTRING (name)->data) + if (text.value != SDATA (name)) xfree (text.value); } #else /* not HAVE_X11R4 */ XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (name)->data); + SDATA (name)); XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (name)->data); + SDATA (name)); #endif /* not HAVE_X11R4 */ UNBLOCK_INPUT; } @@ -2597,10 +2758,10 @@ validate_x_resource_name () if (STRINGP (Vx_resource_name)) { - unsigned char *p = XSTRING (Vx_resource_name)->data; + unsigned char *p = SDATA (Vx_resource_name); int i; - len = STRING_BYTES (XSTRING (Vx_resource_name)); + len = SBYTES (Vx_resource_name); /* Only letters, digits, - and _ are valid in resource names. Count the valid characters and count the invalid ones. */ @@ -2639,12 +2800,12 @@ validate_x_resource_name () for (i = 0; i < len; i++) { - int c = XSTRING (new)->data[i]; + int c = SREF (new, i); if (! ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_')) - XSTRING (new)->data[i] = '_'; + SSET (new, i, '_'); } } @@ -2684,37 +2845,37 @@ and the class is `Emacs.CLASS.SUBCLASS'. */) /* Allocate space for the components, the dots which separate them, and the final '\0'. Make them big enough for the worst case. */ - name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name)) + name_key = (char *) alloca (SBYTES (Vx_resource_name) + (STRINGP (component) - ? STRING_BYTES (XSTRING (component)) : 0) - + STRING_BYTES (XSTRING (attribute)) + ? SBYTES (component) : 0) + + SBYTES (attribute) + 3); - class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class)) - + STRING_BYTES (XSTRING (class)) + class_key = (char *) alloca (SBYTES (Vx_resource_class) + + SBYTES (class) + (STRINGP (subclass) - ? STRING_BYTES (XSTRING (subclass)) : 0) + ? SBYTES (subclass) : 0) + 3); /* Start with emacs.FRAMENAME for the name (the specific one) and with `Emacs' for the class key (the general one). */ - strcpy (name_key, XSTRING (Vx_resource_name)->data); - strcpy (class_key, XSTRING (Vx_resource_class)->data); + strcpy (name_key, SDATA (Vx_resource_name)); + strcpy (class_key, SDATA (Vx_resource_class)); strcat (class_key, "."); - strcat (class_key, XSTRING (class)->data); + strcat (class_key, SDATA (class)); if (!NILP (component)) { strcat (class_key, "."); - strcat (class_key, XSTRING (subclass)->data); + strcat (class_key, SDATA (subclass)); strcat (name_key, "."); - strcat (name_key, XSTRING (component)->data); + strcat (name_key, SDATA (component)); } strcat (name_key, "."); - strcat (name_key, XSTRING (attribute)->data); + strcat (name_key, SDATA (attribute)); value = x_get_string_resource (check_x_display_info (Qnil)->xrdb, name_key, class_key); @@ -2750,37 +2911,37 @@ display_x_get_resource (dpyinfo, attribute, class, component, subclass) /* Allocate space for the components, the dots which separate them, and the final '\0'. Make them big enough for the worst case. */ - name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name)) + name_key = (char *) alloca (SBYTES (Vx_resource_name) + (STRINGP (component) - ? STRING_BYTES (XSTRING (component)) : 0) - + STRING_BYTES (XSTRING (attribute)) + ? SBYTES (component) : 0) + + SBYTES (attribute) + 3); - class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class)) - + STRING_BYTES (XSTRING (class)) + class_key = (char *) alloca (SBYTES (Vx_resource_class) + + SBYTES (class) + (STRINGP (subclass) - ? STRING_BYTES (XSTRING (subclass)) : 0) + ? SBYTES (subclass) : 0) + 3); /* Start with emacs.FRAMENAME for the name (the specific one) and with `Emacs' for the class key (the general one). */ - strcpy (name_key, XSTRING (Vx_resource_name)->data); - strcpy (class_key, XSTRING (Vx_resource_class)->data); + strcpy (name_key, SDATA (Vx_resource_name)); + strcpy (class_key, SDATA (Vx_resource_class)); strcat (class_key, "."); - strcat (class_key, XSTRING (class)->data); + strcat (class_key, SDATA (class)); if (!NILP (component)) { strcat (class_key, "."); - strcat (class_key, XSTRING (subclass)->data); + strcat (class_key, SDATA (subclass)); strcat (name_key, "."); - strcat (name_key, XSTRING (component)->data); + strcat (name_key, SDATA (component)); } strcat (name_key, "."); - strcat (name_key, XSTRING (attribute)->data); + strcat (name_key, SDATA (attribute)); value = x_get_string_resource (dpyinfo->xrdb, name_key, class_key); @@ -2802,13 +2963,13 @@ x_get_resource_string (attribute, class) /* Allocate space for the components, the dots which separate them, and the final '\0'. */ - name_key = (char *) alloca (STRING_BYTES (XSTRING (Vinvocation_name)) + name_key = (char *) alloca (SBYTES (Vinvocation_name) + strlen (attribute) + 2); class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2); sprintf (name_key, "%s.%s", - XSTRING (Vinvocation_name)->data, + SDATA (Vinvocation_name), attribute); sprintf (class_key, "%s.%s", EMACS_CLASS, class); @@ -2866,15 +3027,15 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type) switch (type) { case RES_TYPE_NUMBER: - return make_number (atoi (XSTRING (tem)->data)); + return make_number (atoi (SDATA (tem))); case RES_TYPE_FLOAT: - return make_float (atof (XSTRING (tem)->data)); + return make_float (atof (SDATA (tem))); case RES_TYPE_BOOLEAN: tem = Fdowncase (tem); - if (!strcmp (XSTRING (tem)->data, "on") - || !strcmp (XSTRING (tem)->data, "true")) + if (!strcmp (SDATA (tem), "on") + || !strcmp (SDATA (tem), "true")) return Qt; else return Qnil; @@ -2888,11 +3049,11 @@ x_get_arg (dpyinfo, alist, param, attribute, class, type) { Lisp_Object lower; lower = Fdowncase (tem); - if (!strcmp (XSTRING (lower)->data, "on") - || !strcmp (XSTRING (lower)->data, "true")) + if (!strcmp (SDATA (lower), "on") + || !strcmp (SDATA (lower), "true")) return Qt; - else if (!strcmp (XSTRING (lower)->data, "off") - || !strcmp (XSTRING (lower)->data, "false")) + else if (!strcmp (SDATA (lower), "off") + || !strcmp (SDATA (lower), "false")) return Qnil; else return Fintern (tem, Qnil); @@ -3025,7 +3186,7 @@ or a list (- N) meaning -N pixels relative to bottom/right corner. */) CHECK_STRING (string); - geometry = XParseGeometry ((char *) XSTRING (string)->data, + geometry = XParseGeometry ((char *) SDATA (string), &x, &y, &width, &height); #if 0 @@ -3120,8 +3281,9 @@ x_figure_window_size (f, parms) = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f) ? 0 : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font))); - f->output_data.x->flags_areas_extra - = FRAME_FLAGS_AREA_WIDTH (f); + + x_compute_fringe_widths (f, 0); + f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width); f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height); @@ -3192,6 +3354,22 @@ x_figure_window_size (f, parms) window_prompting |= PPosition; } + if (f->output_data.x->want_fullscreen != FULLSCREEN_NONE) + { + int left, top; + int width, height; + + /* It takes both for some WM:s to place it where we want */ + window_prompting = USPosition | PPosition; + x_fullscreen_adjust (f, &width, &height, &top, &left); + f->width = width; + f->height = height; + f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width); + f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height); + f->output_data.x->left_pos = left; + f->output_data.x->top_pos = top; + } + return window_prompting; } @@ -3381,7 +3559,7 @@ create_frame_xic (f) { /* Determine the base fontname from the ASCII font name of FONTSET. */ - char *ascii_font = (char *) XSTRING (fontset_ascii (fontset))->data; + char *ascii_font = (char *) SDATA (fontset_ascii (fontset)); char *p = ascii_font; int i; @@ -3602,7 +3780,7 @@ x_window (f, window_prompting, minibuffer_only) Elsewhere we specify the window name for the window manager. */ { - char *str = (char *) XSTRING (Vx_resource_name)->data; + char *str = (char *) SDATA (Vx_resource_name); f->namebuf = (char *) xmalloc (strlen (str) + 1); strcpy (f->namebuf, str); } @@ -3735,8 +3913,8 @@ x_window (f, window_prompting, minibuffer_only) validate_x_resource_name (); - class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; - class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data; + class_hints.res_name = (char *) SDATA (Vx_resource_name); + class_hints.res_class = (char *) SDATA (Vx_resource_class); XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints); #ifdef HAVE_X_I18N @@ -3863,8 +4041,8 @@ x_window (f) validate_x_resource_name (); - class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data; - class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data; + class_hints.res_name = (char *) SDATA (Vx_resource_name); + class_hints.res_class = (char *) SDATA (Vx_resource_class); XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints); /* The menubar is part of the ordinary display; @@ -3951,9 +4129,9 @@ x_icon (f, parms) ? IconicState : NormalState)); - x_text_icon (f, (char *) XSTRING ((!NILP (f->icon_name) + x_text_icon (f, (char *) SDATA ((!NILP (f->icon_name) ? f->icon_name - : f->name))->data); + : f->name))); UNBLOCK_INPUT; } @@ -4121,7 +4299,7 @@ This function is an internal primitive--use `make-frame' instead. */) int minibuffer_only = 0; long window_prompting = 0; int width, height; - int count = BINDING_STACK_SIZE (); + int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; Lisp_Object display; struct x_display_info *dpyinfo = NULL; @@ -4286,9 +4464,9 @@ This function is an internal primitive--use `make-frame' instead. */) { tem = Fquery_fontset (font, Qnil); if (STRINGP (tem)) - font = x_new_fontset (f, XSTRING (tem)->data); + font = x_new_fontset (f, SDATA (tem)); else - font = x_new_font (f, XSTRING (font)->data); + font = x_new_font (f, SDATA (font)); } /* Try out a font which we hope has bold and italic variations. */ @@ -4357,6 +4535,10 @@ This function is an internal primitive--use `make-frame' instead. */) "screenGamma", "ScreenGamma", RES_TYPE_FLOAT); x_default_parameter (f, parms, Qline_spacing, Qnil, "lineSpacing", "LineSpacing", RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qleft_fringe, Qnil, + "leftFringe", "LeftFringe", RES_TYPE_NUMBER); + x_default_parameter (f, parms, Qright_fringe, Qnil, + "rightFringe", "RightFringe", RES_TYPE_NUMBER); x_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground, "scrollBarForeground", @@ -4384,6 +4566,8 @@ This function is an internal primitive--use `make-frame' instead. */) "title", "Title", RES_TYPE_STRING); x_default_parameter (f, parms, Qwait_for_wm, Qt, "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN); + x_default_parameter (f, parms, Qfullscreen, Qnil, + "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; @@ -4596,7 +4780,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, CHECK_STRING (color); - if (x_defined_color (f, XSTRING (color)->data, &foo, 0)) + if (x_defined_color (f, SDATA (color), &foo, 0)) return Qt; else return Qnil; @@ -4612,7 +4796,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, CHECK_STRING (color); - if (x_defined_color (f, XSTRING (color)->data, &foo, 0)) + if (x_defined_color (f, SDATA (color), &foo, 0)) { Lisp_Object rgb[3]; @@ -4976,7 +5160,7 @@ visual_classes[] = {"PseudoColor", PseudoColor}, {"TrueColor", TrueColor}, {"DirectColor", DirectColor}, - NULL + {NULL, 0} }; @@ -5023,12 +5207,12 @@ select_visual (dpyinfo) /* VALUE should be of the form CLASS-DEPTH, where CLASS is one of `PseudoColor', `TrueColor' etc. and DEPTH is the color depth, a decimal number. NAME is compared with case ignored. */ - char *s = (char *) alloca (STRING_BYTES (XSTRING (value)) + 1); + char *s = (char *) alloca (SBYTES (value) + 1); char *dash; int i, class = -1; XVisualInfo vinfo; - strcpy (s, XSTRING (value)->data); + strcpy (s, SDATA (value)); dash = index (s, '-'); if (dash) { @@ -5052,7 +5236,7 @@ select_visual (dpyinfo) if (class == -1 || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen), dpyinfo->n_planes, class, &vinfo)) - fatal ("Invalid visual specification `%s'", XSTRING (value)->data); + fatal ("Invalid visual specification `%s'", SDATA (value)); dpyinfo->visual = vinfo.visual; } @@ -5111,10 +5295,10 @@ x_display_info_for_name (name) validate_x_resource_name (); dpyinfo = x_term_init (name, (char *)0, - (char *) XSTRING (Vx_resource_name)->data); + (char *) SDATA (Vx_resource_name)); if (dpyinfo == 0) - error ("Cannot connect to X server %s", XSTRING (name)->data); + error ("Cannot connect to X server %s", SDATA (name)); x_in_use = 1; XSETFASTINT (Vwindow_system_version, 11); @@ -5144,7 +5328,7 @@ terminate Emacs if we can't open the connection. */) error ("Not using X Windows"); if (! NILP (xrm_string)) - xrm_option = (unsigned char *) XSTRING (xrm_string)->data; + xrm_option = (unsigned char *) SDATA (xrm_string); else xrm_option = (unsigned char *) 0; @@ -5153,7 +5337,7 @@ terminate Emacs if we can't open the connection. */) /* This is what opens the connection and sets x_current_display. This also initializes many symbols, such as those used for input. */ dpyinfo = x_term_init (display, xrm_option, - (char *) XSTRING (Vx_resource_name)->data); + (char *) SDATA (Vx_resource_name)); if (dpyinfo == 0) { @@ -5162,9 +5346,9 @@ terminate Emacs if we can't open the connection. */) Check the DISPLAY environment variable or use `-d'.\n\ Also use the `xhost' program to verify that it is set to permit\n\ connections from your machine.\n", - XSTRING (display)->data); + SDATA (display)); else - error ("Cannot connect to X server %s", XSTRING (display)->data); + error ("Cannot connect to X server %s", SDATA (display)); } x_in_use = 1; @@ -5282,8 +5466,8 @@ Lisp_Object Qxbm; /* Keywords. */ extern Lisp_Object QCwidth, QCheight, QCforeground, QCbackground, QCfile; -extern Lisp_Object QCdata; -Lisp_Object QCtype, QCascent, QCmargin, QCrelief; +extern Lisp_Object QCdata, QCtype; +Lisp_Object QCascent, QCmargin, QCrelief; Lisp_Object QCconversion, QCcolor_symbols, QCheuristic_mask; Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask; @@ -5478,7 +5662,7 @@ parse_image_spec (spec, keywords, nkeywords, type) /* Find key in KEYWORDS. Error if not found. */ for (i = 0; i < nkeywords; ++i) - if (strcmp (keywords[i].name, XSYMBOL (key)->name->data) == 0) + if (strcmp (keywords[i].name, SDATA (SYMBOL_NAME (key))) == 0) break; if (i == nkeywords) @@ -5958,7 +6142,7 @@ x_alloc_image_color (f, img, color_name, dflt) xassert (STRINGP (color_name)); - if (x_defined_color (f, XSTRING (color_name)->data, &color, 1)) + if (x_defined_color (f, SDATA (color_name), &color, 1)) { /* This isn't called frequently so we get away with simply reallocating the color vector to the needed size, here. */ @@ -6488,7 +6672,7 @@ x_find_image_file (file) GCPRO2 (file_found, search_path); /* Try to find FILE in data-directory, then x-bitmap-file-path. */ - fd = openp (search_path, file, Qnil, &file_found, 0); + fd = openp (search_path, file, Qnil, &file_found, Qnil); if (fd == -1) file_found = Qnil; @@ -6696,7 +6880,7 @@ xbm_image_p (object) if (STRINGP (elt)) { - if (XSTRING (elt)->size + if (SCHARS (elt) < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR) return 0; } @@ -6711,7 +6895,7 @@ xbm_image_p (object) } else if (STRINGP (data)) { - if (XSTRING (data)->size + if (SCHARS (data) < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height) return 0; } @@ -7041,9 +7225,9 @@ xbm_file_p (data) { int w, h; return (STRINGP (data) - && xbm_read_bitmap_data (XSTRING (data)->data, - (XSTRING (data)->data - + STRING_BYTES (XSTRING (data))), + && xbm_read_bitmap_data (SDATA (data), + (SDATA (data) + + SBYTES (data)), &w, &h, NULL)); } @@ -7079,7 +7263,7 @@ xbm_load (f, img) return 0; } - contents = slurp_file (XSTRING (file)->data, &size); + contents = slurp_file (SDATA (file), &size); if (contents == NULL) { image_error ("Error loading XBM image `%s'", img->spec, Qnil); @@ -7129,9 +7313,9 @@ xbm_load (f, img) background); if (in_memory_file_p) - success_p = xbm_load_image (f, img, XSTRING (data)->data, - (XSTRING (data)->data - + STRING_BYTES (XSTRING (data)))); + success_p = xbm_load_image (f, img, SDATA (data), + (SDATA (data) + + SBYTES (data))); else { if (VECTORP (data)) @@ -7145,13 +7329,13 @@ xbm_load (f, img) { Lisp_Object line = XVECTOR (data)->contents[i]; if (STRINGP (line)) - bcopy (XSTRING (line)->data, p, nbytes); + bcopy (SDATA (line), p, nbytes); else bcopy (XBOOL_VECTOR (line)->data, p, nbytes); } } else if (STRINGP (data)) - bits = XSTRING (data)->data; + bits = SDATA (data); else bits = XBOOL_VECTOR (data)->data; @@ -7553,10 +7737,10 @@ xpm_load (f, img) { Lisp_Object name = XCAR (XCAR (tail)); Lisp_Object color = XCDR (XCAR (tail)); - xpm_syms[i].name = (char *) alloca (XSTRING (name)->size + 1); - strcpy (xpm_syms[i].name, XSTRING (name)->data); - xpm_syms[i].value = (char *) alloca (XSTRING (color)->size + 1); - strcpy (xpm_syms[i].value, XSTRING (color)->data); + xpm_syms[i].name = (char *) alloca (SCHARS (name) + 1); + strcpy (xpm_syms[i].name, SDATA (name)); + xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1); + strcpy (xpm_syms[i].value, SDATA (color)); } } @@ -7577,14 +7761,14 @@ xpm_load (f, img) } rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (file)->data, &img->pixmap, &img->mask, + SDATA (file), &img->pixmap, &img->mask, &attrs); } else { Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL); rc = XpmCreatePixmapFromBuffer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), - XSTRING (buffer)->data, + SDATA (buffer), &img->pixmap, &img->mask, &attrs); } @@ -8384,7 +8568,7 @@ pbm_load (f, img) return 0; } - contents = slurp_file (XSTRING (file)->data, &size); + contents = slurp_file (SDATA (file), &size); if (contents == NULL) { image_error ("Error reading `%s'", file, Qnil); @@ -8399,8 +8583,8 @@ pbm_load (f, img) { Lisp_Object data; data = image_spec_value (img->spec, QCdata, NULL); - p = XSTRING (data)->data; - end = p + STRING_BYTES (XSTRING (data)); + p = SDATA (data); + end = p + SBYTES (data); } /* Check magic number. */ @@ -8728,7 +8912,6 @@ png_load (f, img) png_byte channels; png_uint_32 row_bytes; int transparent_p; - char *gamma_str; double screen_gamma, image_gamma; int intent; struct png_memory_storage tbr; /* Data to be read */ @@ -8750,7 +8933,7 @@ png_load (f, img) } /* Open the image file. */ - fp = fopen (XSTRING (file)->data, "rb"); + fp = fopen (SDATA (file), "rb"); if (!fp) { image_error ("Cannot open image file `%s'", file, Qnil); @@ -8772,8 +8955,8 @@ png_load (f, img) else { /* Read from memory. */ - tbr.bytes = XSTRING (specified_data)->data; - tbr.len = STRING_BYTES (XSTRING (specified_data)); + tbr.bytes = SDATA (specified_data); + tbr.len = SBYTES (specified_data); tbr.index = 0; /* Check PNG signature. */ @@ -8866,24 +9049,22 @@ png_load (f, img) || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb (png_ptr); - /* The value 2.2 is a guess for PC monitors from PNG example.c. */ - gamma_str = getenv ("SCREEN_GAMMA"); - screen_gamma = gamma_str ? atof (gamma_str) : 2.2; + screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2); /* Tell the PNG lib to handle gamma correction for us. */ #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED) if (png_get_sRGB (png_ptr, info_ptr, &intent)) - /* There is a special chunk in the image specifying the gamma. */ - png_set_sRGB (png_ptr, info_ptr, intent); + /* The libpng documentation says this is right in this case. */ + png_set_gamma (png_ptr, screen_gamma, 0.45455); else #endif if (png_get_gAMA (png_ptr, info_ptr, &image_gamma)) /* Image contains gamma information. */ png_set_gamma (png_ptr, screen_gamma, image_gamma); else - /* Use a default of 0.5 for the image gamma. */ - png_set_gamma (png_ptr, screen_gamma, 0.5); + /* Use the standard default for the image gamma. */ + png_set_gamma (png_ptr, screen_gamma, 0.45455); /* Handle alpha channel by combining the image with a background color. Do this only if a real alpha channel is supplied. For @@ -8898,7 +9079,7 @@ png_load (f, img) /* The user specified `:background', use that. */ { XColor color; - if (x_defined_color (f, XSTRING (specified_bg)->data, &color, 0)) + if (x_defined_color (f, SDATA (specified_bg), &color, 0)) { png_color_16 user_bg; @@ -9318,7 +9499,7 @@ jpeg_load (f, img) return 0; } - fp = fopen (XSTRING (file)->data, "r"); + fp = fopen (SDATA (file), "r"); if (fp == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -9365,8 +9546,8 @@ jpeg_load (f, img) if (NILP (specified_data)) jpeg_stdio_src (&cinfo, (FILE *) fp); else - jpeg_memory_src (&cinfo, XSTRING (specified_data)->data, - STRING_BYTES (XSTRING (specified_data))); + jpeg_memory_src (&cinfo, SDATA (specified_data), + SBYTES (specified_data)); jpeg_read_header (&cinfo, TRUE); @@ -9712,7 +9893,7 @@ tiff_load (f, img) } /* Try to open the image file. */ - tiff = TIFFOpen (XSTRING (file)->data, "r"); + tiff = TIFFOpen (SDATA (file), "r"); if (tiff == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -9723,8 +9904,8 @@ tiff_load (f, img) else { /* Memory source! */ - memsrc.bytes = XSTRING (specified_data)->data; - memsrc.len = STRING_BYTES (XSTRING (specified_data)); + memsrc.bytes = SDATA (specified_data); + memsrc.len = SBYTES (specified_data); memsrc.index = 0; tiff = TIFFClientOpen ("memory_source", "r", &memsrc, @@ -9961,7 +10142,7 @@ gif_load (f, img) } /* Open the GIF file. */ - gif = DGifOpenFileName (XSTRING (file)->data); + gif = DGifOpenFileName (SDATA (file)); if (gif == NULL) { image_error ("Cannot open `%s'", file, Qnil); @@ -9973,8 +10154,8 @@ gif_load (f, img) { /* Read from memory! */ current_gif_memory_src = &memsrc; - memsrc.bytes = XSTRING (specified_data)->data; - memsrc.len = STRING_BYTES (XSTRING (specified_data)); + memsrc.bytes = SDATA (specified_data); + memsrc.len = SBYTES (specified_data); memsrc.index = 0; gif = DGifOpen(&memsrc, gif_read_from_memory); @@ -10007,8 +10188,8 @@ gif_load (f, img) return 0; } - width = img->width = gif->SWidth; - height = img->height = gif->SHeight; + width = img->width = max (gif->SWidth, gif->Image.Left + gif->Image.Width); + height = img->height = max (gif->SHeight, gif->Image.Top + gif->Image.Height); /* Create the X image and pixmap. */ if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) @@ -10424,10 +10605,10 @@ selected frame. Value is VALUE. */) CHECK_STRING (value); BLOCK_INPUT; - prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False); + prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False); XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom, XA_STRING, 8, PropModeReplace, - XSTRING (value)->data, XSTRING (value)->size); + SDATA (value), SCHARS (value)); /* Make sure the property is set when we return. */ XFlush (FRAME_X_DISPLAY (f)); @@ -10449,7 +10630,7 @@ FRAME nil or omitted means use the selected frame. Value is PROP. */) CHECK_STRING (prop); BLOCK_INPUT; - prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False); + prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False); XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom); /* Make sure the property is removed when we return. */ @@ -10480,7 +10661,7 @@ value. */) CHECK_STRING (prop); BLOCK_INPUT; - prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False); + prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False); rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom, 0, 0, False, XA_STRING, &actual_type, &actual_format, &actual_size, @@ -10751,7 +10932,7 @@ x_create_tip_frame (dpyinfo, parms, text) Lisp_Object name; long window_prompting = 0; int width, height; - int count = BINDING_STACK_SIZE (); + int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3; struct kboard *kb; int face_change_count_before = face_change_count; @@ -10873,9 +11054,9 @@ x_create_tip_frame (dpyinfo, parms, text) { tem = Fquery_fontset (font, Qnil); if (STRINGP (tem)) - font = x_new_fontset (f, XSTRING (tem)->data); + font = x_new_fontset (f, SDATA (tem)); else - font = x_new_font (f, XSTRING (font)->data); + font = x_new_font (f, SDATA (font)); } /* Try out a font which we hope has bold and italic variations. */ @@ -11077,7 +11258,7 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) /* Move the tooltip window where the mouse pointer is. Resize and show it. */ - if (!INTEGERP (left) && !INTEGERP (top)) + if (!INTEGERP (left) || !INTEGERP (top)) { BLOCK_INPUT; XQueryPointer (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window, @@ -11097,10 +11278,15 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) if (INTEGERP (left)) *root_x = XINT (left); - else if (*root_x + XINT (dx) + width > FRAME_X_DISPLAY_INFO (f)->width) + else if (*root_x + XINT (dx) + width <= FRAME_X_DISPLAY_INFO (f)->width) + /* It fits to the right of the pointer. */ + *root_x += XINT (dx); + else if (width + XINT (dx) <= *root_x) + /* It fits to the left of the pointer. */ *root_x -= width + XINT (dx); else - *root_x += XINT (dx); + /* Put it left-justified on the screen--it ought to fit that way. */ + *root_x = 0; } @@ -11137,7 +11323,7 @@ Text larger than the specified size is clipped. */) int i, width, height; struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; int old_windows_or_buffers_changed = windows_or_buffers_changed; - int count = BINDING_STACK_SIZE (); + int count = SPECPDL_INDEX (); specbind (Qinhibit_redisplay, Qt); @@ -11330,7 +11516,7 @@ Value is t if tooltip was open, nil otherwise. */) GCPRO2 (frame, timer); tip_frame = tip_timer = deleted = Qnil; - count = BINDING_STACK_SIZE (); + count = SPECPDL_INDEX (); specbind (Qinhibit_redisplay, Qt); specbind (Qinhibit_quit, Qt); @@ -11419,7 +11605,7 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) int ac = 0; extern XtAppContext Xt_app_con; XmString dir_xmstring, pattern_xmstring; - int count = specpdl_ptr - specpdl; + int count = SPECPDL_INDEX (); struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; GCPRO5 (prompt, dir, default_filename, mustmatch, file); @@ -11434,10 +11620,10 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) /* Create the dialog with PROMPT as title, using DIR as initial directory and using "*" as pattern. */ dir = Fexpand_file_name (dir, Qnil); - dir_xmstring = XmStringCreateLocalized (XSTRING (dir)->data); + dir_xmstring = XmStringCreateLocalized (SDATA (dir)); pattern_xmstring = XmStringCreateLocalized ("*"); - XtSetArg (al[ac], XmNtitle, XSTRING (prompt)->data); ++ac; + XtSetArg (al[ac], XmNtitle, SDATA (prompt)); ++ac; XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac; XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac; XtSetArg (al[ac], XmNresizePolicy, XmRESIZE_GROW); ++ac; @@ -11488,7 +11674,7 @@ selection dialog's entry field, if MUSTMATCH is non-nil. */) int item_pos; default_xmstring - = XmStringCreateLocalized (XSTRING (default_filename)->data); + = XmStringCreateLocalized (SDATA (default_filename)); if (!XmListItemExists (list, default_xmstring)) { @@ -11656,6 +11842,8 @@ syms_of_xfns () staticpro (&Qauto_lower); Qbar = intern ("bar"); staticpro (&Qbar); + Qhbar = intern ("hbar"); + staticpro (&Qhbar); Qborder_color = intern ("border-color"); staticpro (&Qborder_color); Qborder_width = intern ("border-width"); @@ -11726,6 +11914,14 @@ syms_of_xfns () staticpro (&Qcancel_timer); Qwait_for_wm = intern ("wait-for-wm"); staticpro (&Qwait_for_wm); + Qfullscreen = intern ("fullscreen"); + staticpro (&Qfullscreen); + Qfullwidth = intern ("fullwidth"); + staticpro (&Qfullwidth); + Qfullheight = intern ("fullheight"); + staticpro (&Qfullheight); + Qfullboth = intern ("fullboth"); + staticpro (&Qfullboth); /* This is the end of symbol initialization. */ /* Text property `display' should be nonsticky by default. */ @@ -11938,8 +12134,6 @@ meaning don't clear the cache. */); /* Images. */ Qxbm = intern ("xbm"); staticpro (&Qxbm); - QCtype = intern (":type"); - staticpro (&QCtype); QCconversion = intern (":conversion"); staticpro (&QCconversion); QCheuristic_mask = intern (":heuristic-mask");