diff options
Diffstat (limited to 'src/w32fns.c')
| -rw-r--r-- | src/w32fns.c | 157 |
1 files changed, 119 insertions, 38 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 808503547f1..04358b77bf5 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | /* Graphical user interface functions for the Microsoft W32 API. | 1 | /* Graphical user interface functions for the Microsoft W32 API. |
| 2 | Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, | 2 | |
| 3 | 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 3 | Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
| 4 | Free Software Foundation, Inc. | 4 | 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
| 5 | Free Software Foundation, Inc. | ||
| 5 | 6 | ||
| 6 | This file is part of GNU Emacs. | 7 | This file is part of GNU Emacs. |
| 7 | 8 | ||
| @@ -81,7 +82,7 @@ extern const char *map_w32_filename (const char *, const char **); | |||
| 81 | 82 | ||
| 82 | extern int quit_char; | 83 | extern int quit_char; |
| 83 | 84 | ||
| 84 | extern char *lispy_function_keys[]; | 85 | extern const char *const lispy_function_keys[]; |
| 85 | 86 | ||
| 86 | /* The colormap for converting color names to RGB values */ | 87 | /* The colormap for converting color names to RGB values */ |
| 87 | Lisp_Object Vw32_color_map; | 88 | Lisp_Object Vw32_color_map; |
| @@ -4344,8 +4345,6 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 4344 | "background", "Background", RES_TYPE_STRING); | 4345 | "background", "Background", RES_TYPE_STRING); |
| 4345 | x_default_parameter (f, parameters, Qmouse_color, build_string ("black"), | 4346 | x_default_parameter (f, parameters, Qmouse_color, build_string ("black"), |
| 4346 | "pointerColor", "Foreground", RES_TYPE_STRING); | 4347 | "pointerColor", "Foreground", RES_TYPE_STRING); |
| 4347 | x_default_parameter (f, parameters, Qcursor_color, build_string ("black"), | ||
| 4348 | "cursorColor", "Foreground", RES_TYPE_STRING); | ||
| 4349 | x_default_parameter (f, parameters, Qborder_color, build_string ("black"), | 4348 | x_default_parameter (f, parameters, Qborder_color, build_string ("black"), |
| 4350 | "borderColor", "BorderColor", RES_TYPE_STRING); | 4349 | "borderColor", "BorderColor", RES_TYPE_STRING); |
| 4351 | x_default_parameter (f, parameters, Qscreen_gamma, Qnil, | 4350 | x_default_parameter (f, parameters, Qscreen_gamma, Qnil, |
| @@ -4510,7 +4509,8 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, | |||
| 4510 | 4509 | ||
| 4511 | 4510 | ||
| 4512 | DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, | 4511 | DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, |
| 4513 | doc: /* Internal function called by `color-defined-p', which see. */) | 4512 | doc: /* Internal function called by `color-defined-p', which see. |
| 4513 | \(Note that the Nextstep version of this function ignores FRAME.) */) | ||
| 4514 | (Lisp_Object color, Lisp_Object frame) | 4514 | (Lisp_Object color, Lisp_Object frame) |
| 4515 | { | 4515 | { |
| 4516 | XColor foo; | 4516 | XColor foo; |
| @@ -4850,11 +4850,12 @@ x_display_info_for_name (Lisp_Object name) | |||
| 4850 | } | 4850 | } |
| 4851 | 4851 | ||
| 4852 | DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, | 4852 | DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, |
| 4853 | 1, 3, 0, doc: /* Open a connection to a server. | 4853 | 1, 3, 0, doc: /* Open a connection to a display server. |
| 4854 | DISPLAY is the name of the display to connect to. | 4854 | DISPLAY is the name of the display to connect to. |
| 4855 | Optional second arg XRM-STRING is a string of resources in xrdb format. | 4855 | Optional second arg XRM-STRING is a string of resources in xrdb format. |
| 4856 | If the optional third arg MUST-SUCCEED is non-nil, | 4856 | If the optional third arg MUST-SUCCEED is non-nil, |
| 4857 | terminate Emacs if we can't open the connection. */) | 4857 | terminate Emacs if we can't open the connection. |
| 4858 | \(In the Nextstep version, the last two arguments are currently ignored.) */) | ||
| 4858 | (Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed) | 4859 | (Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed) |
| 4859 | { | 4860 | { |
| 4860 | unsigned char *xrm_option; | 4861 | unsigned char *xrm_option; |
| @@ -4974,7 +4975,17 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, | |||
| 4974 | } | 4975 | } |
| 4975 | 4976 | ||
| 4976 | DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0, | 4977 | DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0, |
| 4977 | doc: /* This is a noop on W32 systems. */) | 4978 | doc: /* If ON is non-nil, report X errors as soon as the erring request is made. |
| 4979 | This function only has an effect on X Windows. With MS Windows, it is | ||
| 4980 | defined but does nothing. | ||
| 4981 | |||
| 4982 | If ON is nil, allow buffering of requests. | ||
| 4983 | Turning on synchronization prohibits the Xlib routines from buffering | ||
| 4984 | requests and seriously degrades performance, but makes debugging much | ||
| 4985 | easier. | ||
| 4986 | The optional second argument TERMINAL specifies which display to act on. | ||
| 4987 | TERMINAL should be a terminal object, a frame or a display name (a string). | ||
| 4988 | If TERMINAL is omitted or nil, that stands for the selected frame's display. */) | ||
| 4978 | (Lisp_Object on, Lisp_Object display) | 4989 | (Lisp_Object on, Lisp_Object display) |
| 4979 | { | 4990 | { |
| 4980 | return Qnil; | 4991 | return Qnil; |
| @@ -4989,11 +5000,12 @@ DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0, | |||
| 4989 | DEFUN ("x-change-window-property", Fx_change_window_property, | 5000 | DEFUN ("x-change-window-property", Fx_change_window_property, |
| 4990 | Sx_change_window_property, 2, 6, 0, | 5001 | Sx_change_window_property, 2, 6, 0, |
| 4991 | doc: /* Change window property PROP to VALUE on the X window of FRAME. | 5002 | doc: /* Change window property PROP to VALUE on the X window of FRAME. |
| 4992 | VALUE may be a string or a list of conses, numbers and/or strings. | 5003 | PROP must be a string. VALUE may be a string or a list of conses, |
| 4993 | If an element in the list is a string, it is converted to | 5004 | numbers and/or strings. If an element in the list is a string, it is |
| 4994 | an Atom and the value of the Atom is used. If an element is a cons, | 5005 | converted to an atom and the value of the Atom is used. If an element |
| 4995 | it is converted to a 32 bit number where the car is the 16 top bits and the | 5006 | is a cons, it is converted to a 32 bit number where the car is the 16 |
| 4996 | cdr is the lower 16 bits. | 5007 | top bits and the cdr is the lower 16 bits. |
| 5008 | |||
| 4997 | FRAME nil or omitted means use the selected frame. | 5009 | FRAME nil or omitted means use the selected frame. |
| 4998 | If TYPE is given and non-nil, it is the name of the type of VALUE. | 5010 | If TYPE is given and non-nil, it is the name of the type of VALUE. |
| 4999 | If TYPE is not given or nil, the type is STRING. | 5011 | If TYPE is not given or nil, the type is STRING. |
| @@ -5001,9 +5013,7 @@ FORMAT gives the size in bits of each element if VALUE is a list. | |||
| 5001 | It must be one of 8, 16 or 32. | 5013 | It must be one of 8, 16 or 32. |
| 5002 | If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8. | 5014 | If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8. |
| 5003 | If OUTER_P is non-nil, the property is changed for the outer X window of | 5015 | If OUTER_P is non-nil, the property is changed for the outer X window of |
| 5004 | FRAME. Default is to change on the edit X window. | 5016 | FRAME. Default is to change on the edit X window. */) |
| 5005 | |||
| 5006 | Value is VALUE. */) | ||
| 5007 | (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, Lisp_Object type, Lisp_Object format, Lisp_Object outer_p) | 5017 | (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, Lisp_Object type, Lisp_Object format, Lisp_Object outer_p) |
| 5008 | { | 5018 | { |
| 5009 | #if 0 /* TODO : port window properties to W32 */ | 5019 | #if 0 /* TODO : port window properties to W32 */ |
| @@ -5057,9 +5067,20 @@ FRAME nil or omitted means use the selected frame. Value is PROP. */) | |||
| 5057 | DEFUN ("x-window-property", Fx_window_property, Sx_window_property, | 5067 | DEFUN ("x-window-property", Fx_window_property, Sx_window_property, |
| 5058 | 1, 2, 0, | 5068 | 1, 2, 0, |
| 5059 | doc: /* Value is the value of window property PROP on FRAME. | 5069 | doc: /* Value is the value of window property PROP on FRAME. |
| 5060 | If FRAME is nil or omitted, use the selected frame. Value is nil | 5070 | If FRAME is nil or omitted, use the selected frame. |
| 5061 | if FRAME hasn't a property with name PROP or if PROP has no string | 5071 | |
| 5062 | value. */) | 5072 | On MS Windows, this function only accepts the PROP and FRAME arguments. |
| 5073 | |||
| 5074 | On X Windows, the following optional arguments are also accepted: | ||
| 5075 | If TYPE is nil or omitted, get the property as a string. | ||
| 5076 | Otherwise TYPE is the name of the atom that denotes the type expected. | ||
| 5077 | If SOURCE is non-nil, get the property on that window instead of from | ||
| 5078 | FRAME. The number 0 denotes the root window. | ||
| 5079 | If DELETE_P is non-nil, delete the property after retreiving it. | ||
| 5080 | If VECTOR_RET_P is non-nil, don't return a string but a vector of values. | ||
| 5081 | |||
| 5082 | Value is nil if FRAME hasn't a property with name PROP or if PROP has | ||
| 5083 | no value of TYPE (always string in the MS Windows case). */) | ||
| 5063 | (Lisp_Object prop, Lisp_Object frame) | 5084 | (Lisp_Object prop, Lisp_Object frame) |
| 5064 | { | 5085 | { |
| 5065 | #if 0 /* TODO : port window properties to W32 */ | 5086 | #if 0 /* TODO : port window properties to W32 */ |
| @@ -5634,7 +5655,7 @@ Text larger than the specified size is clipped. */) | |||
| 5634 | int root_x, root_y; | 5655 | int root_x, root_y; |
| 5635 | struct buffer *old_buffer; | 5656 | struct buffer *old_buffer; |
| 5636 | struct text_pos pos; | 5657 | struct text_pos pos; |
| 5637 | int i, width, height; | 5658 | int i, width, height, seen_reversed_p; |
| 5638 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 5659 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 5639 | int old_windows_or_buffers_changed = windows_or_buffers_changed; | 5660 | int old_windows_or_buffers_changed = windows_or_buffers_changed; |
| 5640 | int count = SPECPDL_INDEX (); | 5661 | int count = SPECPDL_INDEX (); |
| @@ -5764,7 +5785,7 @@ Text larger than the specified size is clipped. */) | |||
| 5764 | try_window (FRAME_ROOT_WINDOW (f), pos, 0); | 5785 | try_window (FRAME_ROOT_WINDOW (f), pos, 0); |
| 5765 | 5786 | ||
| 5766 | /* Compute width and height of the tooltip. */ | 5787 | /* Compute width and height of the tooltip. */ |
| 5767 | width = height = 0; | 5788 | width = height = seen_reversed_p = 0; |
| 5768 | for (i = 0; i < w->desired_matrix->nrows; ++i) | 5789 | for (i = 0; i < w->desired_matrix->nrows; ++i) |
| 5769 | { | 5790 | { |
| 5770 | struct glyph_row *row = &w->desired_matrix->rows[i]; | 5791 | struct glyph_row *row = &w->desired_matrix->rows[i]; |
| @@ -5778,24 +5799,83 @@ Text larger than the specified size is clipped. */) | |||
| 5778 | /* Let the row go over the full width of the frame. */ | 5799 | /* Let the row go over the full width of the frame. */ |
| 5779 | row->full_width_p = 1; | 5800 | row->full_width_p = 1; |
| 5780 | 5801 | ||
| 5781 | #ifdef TODO /* Investigate why some fonts need more width than is | 5802 | row_width = row->pixel_width; |
| 5782 | calculated for some tooltips. */ | ||
| 5783 | /* There's a glyph at the end of rows that is use to place | ||
| 5784 | the cursor there. Don't include the width of this glyph. */ | ||
| 5785 | if (row->used[TEXT_AREA]) | 5803 | if (row->used[TEXT_AREA]) |
| 5786 | { | 5804 | { |
| 5787 | last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | 5805 | if (!row->reversed_p) |
| 5788 | row_width = row->pixel_width - last->pixel_width; | 5806 | { |
| 5789 | } | 5807 | #ifdef TODO /* Investigate why some fonts need more width than is |
| 5790 | else | 5808 | calculated for some tooltips. */ |
| 5809 | |||
| 5810 | /* There's a glyph at the end of rows that is used to | ||
| 5811 | place the cursor there. Don't include the width of | ||
| 5812 | this glyph. */ | ||
| 5813 | last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | ||
| 5814 | if (INTEGERP (last->object)) | ||
| 5815 | row_width -= last->pixel_width; | ||
| 5791 | #endif | 5816 | #endif |
| 5792 | row_width = row->pixel_width; | 5817 | } |
| 5818 | else | ||
| 5819 | { | ||
| 5820 | /* There could be a stretch glyph at the beginning of R2L | ||
| 5821 | rows that is produced by extend_face_to_end_of_line. | ||
| 5822 | Don't count that glyph. */ | ||
| 5823 | struct glyph *g = row->glyphs[TEXT_AREA]; | ||
| 5824 | |||
| 5825 | if (g->type == STRETCH_GLYPH && INTEGERP (g->object)) | ||
| 5826 | { | ||
| 5827 | row_width -= g->pixel_width; | ||
| 5828 | seen_reversed_p = 1; | ||
| 5829 | } | ||
| 5830 | } | ||
| 5831 | } | ||
| 5793 | 5832 | ||
| 5794 | /* TODO: find why tips do not draw along baseline as instructed. */ | 5833 | /* TODO: find why tips do not draw along baseline as instructed. */ |
| 5795 | height += row->height; | 5834 | height += row->height; |
| 5796 | width = max (width, row_width); | 5835 | width = max (width, row_width); |
| 5797 | } | 5836 | } |
| 5798 | 5837 | ||
| 5838 | /* If we've seen partial-length R2L rows, we need to re-adjust the | ||
| 5839 | tool-tip frame width and redisplay it again, to avoid over-wide | ||
| 5840 | tips due to the stretch glyph that extends R2L lines to full | ||
| 5841 | width of the frame. */ | ||
| 5842 | if (seen_reversed_p) | ||
| 5843 | { | ||
| 5844 | /* w->total_cols and FRAME_TOTAL_COLS want the width in columns, | ||
| 5845 | not in pixels. */ | ||
| 5846 | width /= WINDOW_FRAME_COLUMN_WIDTH (w); | ||
| 5847 | w->total_cols = make_number (width); | ||
| 5848 | FRAME_TOTAL_COLS (f) = width; | ||
| 5849 | adjust_glyphs (f); | ||
| 5850 | clear_glyph_matrix (w->desired_matrix); | ||
| 5851 | clear_glyph_matrix (w->current_matrix); | ||
| 5852 | try_window (FRAME_ROOT_WINDOW (f), pos, 0); | ||
| 5853 | width = height = 0; | ||
| 5854 | /* Recompute width and height of the tooltip. */ | ||
| 5855 | for (i = 0; i < w->desired_matrix->nrows; ++i) | ||
| 5856 | { | ||
| 5857 | struct glyph_row *row = &w->desired_matrix->rows[i]; | ||
| 5858 | struct glyph *last; | ||
| 5859 | int row_width; | ||
| 5860 | |||
| 5861 | if (!row->enabled_p || !row->displays_text_p) | ||
| 5862 | break; | ||
| 5863 | row->full_width_p = 1; | ||
| 5864 | row_width = row->pixel_width; | ||
| 5865 | #ifdef TODO /* See above. */ | ||
| 5866 | if (row->used[TEXT_AREA] && !row->reversed_p) | ||
| 5867 | { | ||
| 5868 | last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; | ||
| 5869 | if (INTEGERP (last->object)) | ||
| 5870 | row_width -= last->pixel_width; | ||
| 5871 | } | ||
| 5872 | #endif | ||
| 5873 | |||
| 5874 | height += row->height; | ||
| 5875 | width = max (width, row_width); | ||
| 5876 | } | ||
| 5877 | } | ||
| 5878 | |||
| 5799 | /* Add the frame's internal border to the width and height the X | 5879 | /* Add the frame's internal border to the width and height the X |
| 5800 | window should have. */ | 5880 | window should have. */ |
| 5801 | height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f); | 5881 | height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f); |
| @@ -5948,10 +6028,13 @@ typedef struct | |||
| 5948 | 6028 | ||
| 5949 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, | 6029 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, |
| 5950 | doc: /* Read file name, prompting with PROMPT in directory DIR. | 6030 | doc: /* Read file name, prompting with PROMPT in directory DIR. |
| 5951 | Use a file selection dialog. | 6031 | Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file |
| 5952 | Select DEFAULT-FILENAME in the dialog's file selection box, if | 6032 | selection box, if specified. If MUSTMATCH is non-nil, the returned file |
| 5953 | specified. Ensure that file exists if MUSTMATCH is non-nil. | 6033 | or directory must exist. |
| 5954 | If ONLY-DIR-P is non-nil, the user can only select directories. */) | 6034 | |
| 6035 | This function is only defined on MS Windows, and X Windows with the | ||
| 6036 | Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored. | ||
| 6037 | Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) | ||
| 5955 | (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) | 6038 | (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) |
| 5956 | { | 6039 | { |
| 5957 | struct frame *f = SELECTED_FRAME (); | 6040 | struct frame *f = SELECTED_FRAME (); |
| @@ -7243,5 +7326,3 @@ w32_last_error (void) | |||
| 7243 | return GetLastError (); | 7326 | return GetLastError (); |
| 7244 | } | 7327 | } |
| 7245 | 7328 | ||
| 7246 | /* arch-tag: 707589ab-b9be-4638-8cdd-74629cc9b446 | ||
| 7247 | (do not change this comment) */ | ||