/* Convert (0, 0) in the client area to screen co-ordinates. */
ClientToScreen (FRAME_W32_WINDOW (f), &pt);
- /* Remember x_pixels_diff and y_pixels_diff. */
- f->x_pixels_diff = pt.x - rect.left;
- f->y_pixels_diff = pt.y - rect.top;
-
*xptr = rect.left;
*yptr = rect.top;
}
If ALLOC is nonzero, allocate a new colormap cell. */
int
-w32_defined_color (struct frame *f, const char *color, XColor *color_def, int alloc)
+w32_defined_color (struct frame *f, const char *color, XColor *color_def,
+ bool alloc_p)
{
register Lisp_Object tem;
COLORREF w32_color_ref;
entry = entry->next;
}
- if (entry == NULL && alloc)
+ if (entry == NULL && alloc_p)
{
/* not already mapped, so add to list */
entry = xmalloc (sizeof (struct w32_palette_entry));
/* w32_defined_color is responsible for coping with failures
by looking for a near-miss. */
- if (w32_defined_color (f, SDATA (arg), &cdef, 1))
+ if (w32_defined_color (f, SDATA (arg), &cdef, true))
return cdef.pixel;
/* defined_color failed; return an ultimate default. */
void
x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
- int result;
+ bool result;
if (NILP (arg) && NILP (oldval))
return;
if (FRAME_X_WINDOW (f) != 0)
{
- adjust_frame_size (f, -1, -1, 3, 0, Qinternal_border_width);
+ adjust_frame_size (f, -1, -1, 3, false, Qinternal_border_width);
if (FRAME_VISIBLE_P (f))
x_clear_under_internal_border (f);
of the outer rectangle (including decorations) unchanged, and a
second time because we want to keep the height of the inner
rectangle (without the decorations unchanged). */
- adjust_frame_size (f, -1, -1, 2, 1, Qmenu_bar_lines);
+ adjust_frame_size (f, -1, -1, 2, true, Qmenu_bar_lines);
/* Not sure whether this is needed. */
x_clear_under_internal_border (f);
int old_height = FRAME_TOOL_BAR_HEIGHT (f);
int lines = (height + unit - 1) / unit;
int old_text_height = FRAME_TEXT_HEIGHT (f);
+ Lisp_Object fullscreen;
/* Make sure we redisplay all windows in this frame. */
windows_or_buffers_changed = 23;
/* Recalculate toolbar height. */
f->n_tool_bar_rows = 0;
- adjust_frame_size (f, -1, -1, (old_height == 0 || height == 0) ? 2 : 4, 0,
- Qtool_bar_lines);
+ adjust_frame_size (f, -1, -1,
+ ((!f->tool_bar_redisplayed_once
+ && (NILP (fullscreen =
+ get_frame_param (f, Qfullscreen))
+ || EQ (fullscreen, Qfullwidth))) ? 1
+ : (old_height == 0 || height == 0) ? 2
+ : 4),
+ false, Qtool_bar_lines);
/* adjust_frame_size might not have done anything, garbage frame
here. */
x_clear_under_internal_border (f);
}
+static void
+w32_set_title_bar_text (struct frame *f, Lisp_Object name)
+{
+ if (FRAME_W32_WINDOW (f))
+ {
+ block_input ();
+#ifdef __CYGWIN__
+ GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
+ GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
+#else
+ /* The frame's title many times shows the name of the file
+ visited in the selected window's buffer, so it makes sense to
+ support non-ASCII characters outside of the current system
+ codepage in the title. */
+ if (w32_unicode_filenames)
+ {
+ Lisp_Object encoded_title = ENCODE_UTF_8 (name);
+ wchar_t *title_w;
+ int tlen = pMultiByteToWideChar (CP_UTF8, 0, SSDATA (encoded_title),
+ -1, NULL, 0);
+
+ if (tlen > 0)
+ {
+ /* Windows truncates the title text beyond what fits on
+ a single line, so we can limit the length to some
+ reasonably large value, and use alloca. */
+ if (tlen > 10000)
+ tlen = 10000;
+ title_w = alloca ((tlen + 1) * sizeof (wchar_t));
+ pMultiByteToWideChar (CP_UTF8, 0, SSDATA (encoded_title), -1,
+ title_w, tlen);
+ title_w[tlen] = L'\0';
+ SetWindowTextW (FRAME_W32_WINDOW (f), title_w);
+ }
+ else /* Conversion to UTF-16 failed, so we punt. */
+ SetWindowTextA (FRAME_W32_WINDOW (f),
+ SSDATA (ENCODE_SYSTEM (name)));
+ }
+ else
+ SetWindowTextA (FRAME_W32_WINDOW (f), SSDATA (ENCODE_SYSTEM (name)));
+#endif
+ unblock_input ();
+ }
+}
/* Change the name of frame F to NAME. If NAME is nil, set F's name to
w32_id_name.
F->explicit_name is set, ignore the new name; otherwise, set it. */
void
-x_set_name (struct frame *f, Lisp_Object name, int explicit)
+x_set_name (struct frame *f, Lisp_Object name, bool explicit)
{
/* Make sure that requests from lisp code override requests from
Emacs redisplay code. */
if (! NILP (f->title))
name = f->title;
- if (FRAME_W32_WINDOW (f))
- {
- block_input ();
- GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
- GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
- unblock_input ();
- }
+ w32_set_title_bar_text (f, name);
}
/* This function should be called when the user's lisp code has
void
x_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
- x_set_name (f, arg, 1);
+ x_set_name (f, arg, true);
}
/* This function should be called by Emacs redisplay code to set the
void
x_implicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
- x_set_name (f, arg, 0);
+ x_set_name (f, arg, false);
}
\f
/* Change the title of frame F to NAME.
if (NILP (name))
name = f->name;
- if (FRAME_W32_WINDOW (f))
- {
- block_input ();
- GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
- GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
- unblock_input ();
- }
+ w32_set_title_bar_text (f, name);
}
void
thread-safe. The next line is okay because the cons
cell is never made into garbage and is not relocated by
GC. */
- XSETCAR (XIL ((EMACS_INT) msg.lParam), Qnil);
+ XSETCAR (make_lisp_ptr ((void *)msg.lParam, Lisp_Cons), Qnil);
if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
emacs_abort ();
break;
{
int vk_code = (int) msg.wParam;
int cur_state = (GetKeyState (vk_code) & 1);
- Lisp_Object new_state = XIL ((EMACS_INT) msg.lParam);
-
- /* NB: This code must be thread-safe. It is safe to
- call NILP because symbols are not relocated by GC,
- and pointer here is not touched by GC (so the markbit
- can't be set). Numbers are safe because they are
- immediate values. */
- if (NILP (new_state)
- || (NUMBERP (new_state)
- && ((XUINT (new_state)) & 1) != cur_state))
+ int new_state = msg.lParam;
+
+ if (new_state == -1
+ || ((new_state & 1) != cur_state))
{
one_w32_display_info.faked_key = vk_code;
field being reset to nil. */
f = x_window_to_frame (dpyinfo, hwnd);
if (!(f && FRAME_LIVE_P (f)))
- break;
+ goto dflt;
w = XWINDOW (FRAME_SELECTED_WINDOW (f));
/* Punt if someone changed the frame's selected window
behind our back. */
if (w != w32_system_caret_window)
- break;
+ goto dflt;
form.dwStyle = CFS_RECT;
form.ptCurrentPos.x = w32_system_caret_x;
/* Punt if the window was deleted behind our back. */
if (!BUFFERP (w->contents))
- break;
+ goto dflt;
context = get_ime_context_fn (hwnd);
if (!context)
- break;
+ goto dflt;
set_ime_composition_window_fn (context, &form);
release_ime_context_fn (hwnd, context);
}
- break;
+ /* Pass WM_IME_STARTCOMPOSITION to DefWindowProc, so that the
+ composition window will actually be displayed. */
+ goto dflt;
case WM_IME_ENDCOMPOSITION:
ignore_ime_char = 0;
/* Create and set up the w32 window for frame F. */
static void
-w32_window (struct frame *f, long window_prompting, int minibuffer_only)
+w32_window (struct frame *f, long window_prompting, bool minibuffer_only)
{
block_input ();
for the window manager, so GC relocation won't bother it.
Elsewhere we specify the window name for the window manager. */
- f->namebuf = xstrdup (SSDATA (Vx_resource_name));
+ f->namebuf = xlispstrdup (Vx_resource_name);
my_create_window (f);
struct frame *f;
Lisp_Object frame, tem;
Lisp_Object name;
- int minibuffer_only = 0;
+ bool minibuffer_only = false;
long window_prompting = 0;
ptrdiff_t count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
else if (EQ (tem, Qonly))
{
f = make_minibuffer_frame ();
- minibuffer_only = 1;
+ minibuffer_only = true;
}
else if (WINDOWP (tem))
f = make_frame_without_minibuffer (tem, kb, display);
else
- f = make_frame (1);
+ f = make_frame (true);
XSETFRAME (frame, f);
/* Specify the parent under which to make this window. */
if (!NILP (parent))
{
- f->output_data.w32->parent_desc = (Window) XFASTINT (parent);
- f->output_data.w32->explicit_parent = 1;
+ /* Cast to UINT_PTR shuts up compiler warnings about cast to
+ pointer from integer of different size. */
+ f->output_data.w32->parent_desc = (Window) (UINT_PTR) XFASTINT (parent);
+ f->output_data.w32->explicit_parent = true;
}
else
{
f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
- f->output_data.w32->explicit_parent = 0;
+ f->output_data.w32->explicit_parent = false;
}
/* Set the name; the functions to which we pass f expect the name to
if (EQ (name, Qunbound) || NILP (name))
{
fset_name (f, build_string (dpyinfo->w32_id_name));
- f->explicit_name = 0;
+ f->explicit_name = false;
}
else
{
fset_name (f, name);
- f->explicit_name = 1;
+ f->explicit_name = true;
/* Use the frame's title when getting resources for this frame. */
specbind (Qx_resource_name, name);
}
had one frame line vs one toolbar line which left us with a zero
root window height which was obviously wrong as well ... */
adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
- FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, Qnil);
+ FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, true,
+ Qx_create_frame_1);
/* The X resources controlling the menu-bar and tool-bar are
processed specially at startup, and reflected in the mode
"bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
x_default_parameter (f, parameters, Qtitle, Qnil,
"title", "Title", RES_TYPE_STRING);
- x_default_parameter (f, parameters, Qfullscreen, Qnil,
- "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
f->output_data.w32->dwStyle = WS_OVERLAPPEDWINDOW;
f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
f->output_data.w32->current_cursor = f->output_data.w32->nontext_cursor;
- window_prompting = x_figure_window_size (f, parameters, 1);
+ window_prompting = x_figure_window_size (f, parameters, true);
tem = x_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
f->no_split = minibuffer_only || EQ (tem, Qt);
/* Allow x_set_window_size, now. */
f->can_x_set_window_size = true;
- adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, Qnil);
+ adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true,
+ Qx_create_frame_2);
/* Tell the server what size and position, etc, we want, and how
badly we want them. This should be done after we have the menu
bar so that its size can be taken into account. */
block_input ();
- x_wm_set_size_hint (f, window_prompting, 0);
+ x_wm_set_size_hint (f, window_prompting, false);
unblock_input ();
+ /* Process fullscreen parameter here in the hope that normalizing a
+ fullheight/fullwidth frame will produce the size set by the last
+ adjust_frame_size call. */
+ x_default_parameter (f, parameters, Qfullscreen, Qnil,
+ "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
+
/* Make the window appear on the frame and enable display, unless
the caller says not to. However, with explicit parent, Emacs
cannot control visibility, so don't try. */
CHECK_STRING (color);
- if (w32_defined_color (f, SDATA (color), &foo, 0))
+ if (w32_defined_color (f, SDATA (color), &foo, false))
return Qt;
else
return Qnil;
CHECK_STRING (color);
- if (w32_defined_color (f, SDATA (color), &foo, 0))
+ if (w32_defined_color (f, SDATA (color), &foo, false))
return list3i ((GetRValue (foo.pixel) << 8) | GetRValue (foo.pixel),
(GetGValue (foo.pixel) << 8) | GetGValue (foo.pixel),
(GetBValue (foo.pixel) << 8) | GetBValue (foo.pixel));
}
DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
- doc: /* Return the "vendor ID" string of the W32 system (Microsoft).
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
+ doc: /* Return the "vendor ID" string of the GUI software on TERMINAL.
+
+\(Labeling every distributor as a "vendor" embodies the false assumption
+that operating systems cannot be developed and distributed noncommercially.)
+
+For GNU and Unix systems, this queries the X server software; for
+MS-Windows, this queries the OS.
+
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal object, a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
- (Lisp_Object display)
+ (Lisp_Object terminal)
{
return build_string ("Microsoft Corp.");
}
DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
- doc: /* Return the version numbers of the server of DISPLAY.
-The value is a list of three integers: the major and minor
-version numbers of the X Protocol in use, and the distributor-specific
-release number. See also the function `x-server-vendor'.
+ doc: /* Return the version numbers of the GUI software on TERMINAL.
+The value is a list of three integers specifying the version of the GUI
+software in use.
-The optional argument DISPLAY specifies which display to ask about.
-DISPLAY should be either a frame or a display name (a string).
+For GNU and Unix system, the first 2 numbers are the version of the X
+Protocol used on TERMINAL and the 3rd number is the distributor-specific
+release number. For MS-Windows, the 3 numbers report the version and
+the build number of the OS.
+
+See also the function `x-server-vendor'.
+
+The optional argument TERMINAL specifies which display to ask about.
+TERMINAL should be a terminal object, a frame or a display name (a string).
If omitted or nil, that stands for the selected frame's display. */)
- (Lisp_Object display)
+ (Lisp_Object terminal)
{
return list3i (w32_major_version, w32_minor_version, w32_build_number);
}
ptrdiff_t count = SPECPDL_INDEX ();
struct gcpro gcpro1, gcpro2, gcpro3;
struct kboard *kb;
- int face_change_count_before = face_change_count;
+ bool face_change_before = face_change;
Lisp_Object buffer;
struct buffer *old_buffer;
frame = Qnil;
GCPRO3 (parms, name, frame);
/* Make a frame without minibuffer nor mode-line. */
- f = make_frame (0);
+ f = make_frame (false);
f->wants_modeline = 0;
XSETFRAME (frame, f);
buffer = Fget_buffer_create (tip);
/* Use set_window_buffer instead of Fset_window_buffer (see
discussion of bug#11984, bug#12025, bug#12026). */
- set_window_buffer (FRAME_ROOT_WINDOW (f), buffer, 0, 0);
+ set_window_buffer (FRAME_ROOT_WINDOW (f), buffer, false, false);
old_buffer = current_buffer;
set_buffer_internal_1 (XBUFFER (buffer));
bset_truncate_lines (current_buffer, Qnil);
#endif /* GLYPH_DEBUG */
FRAME_KBOARD (f) = kb;
f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
- f->output_data.w32->explicit_parent = 0;
+ f->output_data.w32->explicit_parent = false;
/* Set the name; the functions to which we pass f expect the name to
be set. */
if (EQ (name, Qunbound) || NILP (name))
{
fset_name (f, build_string (dpyinfo->w32_id_name));
- f->explicit_name = 0;
+ f->explicit_name = false;
}
else
{
fset_name (f, name);
- f->explicit_name = 1;
+ f->explicit_name = true;
/* use the frame's title when getting resources for this frame. */
specbind (Qx_resource_name, name);
}
f->output_data.w32->dwStyle = WS_BORDER | WS_POPUP | WS_DISABLED;
f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
- window_prompting = x_figure_window_size (f, parms, 0);
+ window_prompting = x_figure_window_size (f, parms, false);
/* No fringes on tip frame. */
f->fringe_cols = 0;
SET_FRAME_COLS (f, 0);
SET_FRAME_LINES (f, 0);
adjust_frame_size (f, width * FRAME_COLUMN_WIDTH (f),
- height * FRAME_LINE_HEIGHT (f), 0, 1, Qnil);
+ height * FRAME_LINE_HEIGHT (f), 0, true, Qtip_frame);
/* Add `tooltip' frame parameter's default value. */
if (NILP (Fframe_parameter (frame, Qtooltip)))
Fmodify_frame_parameters (frame, colors);
}
- f->no_split = 1;
+ f->no_split = true;
UNGCPRO;
f->can_x_set_window_size = true;
/* Setting attributes of faces of the tooltip frame from resources
- and similar will increment face_change_count, which leads to the
+ and similar will set face_change, which leads to the
clearing of all current matrices. Since this isn't necessary
- here, avoid it by resetting face_change_count to the value it
+ here, avoid it by resetting face_change to the value it
had before we created the tip frame. */
- face_change_count = face_change_count_before;
+ face_change = face_change_before;
/* Discard the unwind_protect. */
return unbind_to (count, frame);
int root_x, root_y;
struct buffer *old_buffer;
struct text_pos pos;
- int i, width, height, seen_reversed_p;
+ int i, width, height;
+ bool seen_reversed_p;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
int old_windows_or_buffers_changed = windows_or_buffers_changed;
ptrdiff_t count = SPECPDL_INDEX ();
FRAME_TOTAL_COLS (f) = WINDOW_TOTAL_COLS (w);
adjust_frame_glyphs (f);
- w->pseudo_window_p = 1;
+ w->pseudo_window_p = true;
/* Display the tooltip text in a temporary buffer. */
old_buffer = current_buffer;
try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
/* Compute width and height of the tooltip. */
- width = height = seen_reversed_p = 0;
+ width = height = 0;
+ seen_reversed_p = false;
for (i = 0; i < w->desired_matrix->nrows; ++i)
{
struct glyph_row *row = &w->desired_matrix->rows[i];
break;
/* Let the row go over the full width of the frame. */
- row->full_width_p = 1;
+ row->full_width_p = true;
row_width = row->pixel_width;
if (row->used[TEXT_AREA])
if (g->type == STRETCH_GLYPH && NILP (g->object))
{
row_width -= g->pixel_width;
- seen_reversed_p = 1;
+ seen_reversed_p = true;
}
}
}
if (!row->enabled_p || !MATRIX_ROW_DISPLAYS_TEXT_P (row))
break;
- row->full_width_p = 1;
+ row->full_width_p = true;
row_width = row->pixel_width;
if (row->used[TEXT_AREA] && !row->reversed_p)
{
/* Notify input thread about new hot-key definition, so that it
takes effect without needing to switch focus. */
PostThreadMessage (dwWindowsThreadId, WM_EMACS_REGISTER_HOT_KEY,
- (WPARAM) XLI (key), 0);
+ (WPARAM) XINT (key), 0);
}
return key;
if (!NILP (item))
{
+ LPARAM lparam;
+
+ eassert (CONSP (item));
+ /* Pass the tail of the list as a pointer to a Lisp_Cons cell,
+ so that it works in a --with-wide-int build as well. */
+ lparam = (LPARAM) XUNTAG (item, Lisp_Cons);
+
/* Notify input thread about hot-key definition being removed, so
that it takes effect without needing focus switch. */
if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY,
- (WPARAM) XINT (XCAR (item)), (LPARAM) XLI (item)))
+ (WPARAM) XINT (XCAR (item)), lparam))
{
MSG msg;
GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
doc: /* Toggle the state of the lock key KEY.
KEY can be `capslock', `kp-numlock', or `scroll'.
If the optional parameter NEW-STATE is a number, then the state of KEY
-is set to off if the low bit of NEW-STATE is zero, otherwise on. */)
+is set to off if the low bit of NEW-STATE is zero, otherwise on.
+If NEW-STATE is omitted or nil, the function toggles the state,
+
+Value is the new state of the key, or nil if the function failed
+to change the state. */)
(Lisp_Object key, Lisp_Object new_state)
{
int vk_code;
+ LPARAM lparam;
if (EQ (key, intern ("capslock")))
vk_code = VK_CAPITAL;
if (!dwWindowsThreadId)
return make_number (w32_console_toggle_lock_key (vk_code, new_state));
+ if (NILP (new_state))
+ lparam = -1;
+ else
+ lparam = (XUINT (new_state)) & 1;
if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_TOGGLE_LOCK_KEY,
- (WPARAM) vk_code, (LPARAM) XLI (new_state)))
+ (WPARAM) vk_code, lparam))
{
MSG msg;
GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
menu_bar_height = single_bar_height;
return
- listn (CONSTYPE_PURE, 10,
+ listn (CONSTYPE_HEAP, 10,
Fcons (Qframe_position,
Fcons (make_number (frame_outer_edges.left),
make_number (frame_outer_edges.top))),