#include <fcntl.h>
#include <unistd.h>
+#include <c-ctype.h>
+
#include "lisp.h"
#include "w32term.h"
#include "frame.h"
typedef LONG (WINAPI * ImmGetCompositionString_Proc)
(IN HIMC context, IN DWORD index, OUT LPVOID buffer, IN DWORD bufLen);
typedef HIMC (WINAPI * ImmGetContext_Proc) (IN HWND window);
-typedef HWND (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context);
-typedef HWND (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context,
+typedef BOOL (WINAPI * ImmReleaseContext_Proc) (IN HWND wnd, IN HIMC context);
+typedef BOOL (WINAPI * ImmSetCompositionWindow_Proc) (IN HIMC context,
IN COMPOSITIONFORM *form);
typedef HMONITOR (WINAPI * MonitorFromPoint_Proc) (IN POINT pt, IN DWORD flags);
typedef BOOL (WINAPI * GetMonitorInfo_Proc)
/* 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;
}
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;
f->n_tool_bar_rows = 0;
adjust_frame_size (f, -1, -1,
- (!f->tool_bar_redisplayed_once ? 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);
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.
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
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
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);
}
+ /* We should "goto dflt" here to pass WM_IME_STARTCOMPOSITION to
+ DefWindowProc, so that the composition window will actually
+ be displayed. But doing so causes trouble with displaying
+ dialog boxes, such as the file selection dialog or font
+ selection dialog. So something else is needed to fix the
+ former without breaking the latter. See bug#11732. */
break;
case WM_IME_ENDCOMPOSITION:
"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;
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. */
}
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;
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, true, Qnil);
+ height * FRAME_LINE_HEIGHT (f), 0, true, Qtip_frame);
/* Add `tooltip' frame parameter's default value. */
if (NILP (Fframe_parameter (frame, Qtooltip)))
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);
#else /* !CYGWIN */
- current_dir = ENCODE_FILE (current_dir);
+ const char file_url_str[] = "file:///";
+ const int file_url_len = sizeof (file_url_str) - 1;
+ if (strncmp (SSDATA (document), file_url_str, file_url_len) == 0)
+ {
+ /* Passing "file:///" URLs to ShellExecute causes shlwapi.dll to
+ start a thread in some rare system configurations, for
+ unknown reasons. That thread is started in the context of
+ the Emacs process, but out of control of our code, and seems
+ to never exit afterwards. Each such thread reserves 8MB of
+ stack space (because that's the value recorded in the Emacs
+ executable at link time: Emacs needs a large stack). So a
+ large enough number of invocations of w32-shell-execute can
+ potentially cause the Emacs process to run out of available
+ address space, which is nasty. To work around this, we
+ convert such URLs to local file names, which seems to prevent
+ those threads from starting. See bug #20220. */
+ char *p = SSDATA (document) + file_url_len;
+
+ if (c_isalpha (*p) && p[1] == ':' && IS_DIRECTORY_SEP (p[2]))
+ document = Fsubstring_no_properties (document,
+ make_number (file_url_len), Qnil);
+ }
/* We have a situation here. If DOCUMENT is a relative file name,
but its name includes leading directories, i.e. it lives not in
CURRENT_DIR, but in its subdirectory, then ShellExecute below
else
document = ENCODE_FILE (document);
UNGCPRO;
+
+ current_dir = ENCODE_FILE (current_dir);
if (use_unicode)
{
wchar_t document_w[MAX_PATH], current_dir_w[MAX_PATH];
- `title-bar-height' is the height of the title bar of FRAME.
-- `menu-bar-external' if `t' means the menu bar is by default external
+- `menu-bar-external' if t means the menu bar is by default external
(not included in the inner size of FRAME).
- `menu-bar-size' is a cons of the width and height of the menu bar of
FRAME.
-- `tool-bar-external' if `t' means the tool bar is by default external
+- `tool-bar-external' if t means the tool bar is by default external
(not included in the inner size of FRAME).
- `tool-bar-side' tells tells on which side the tool bar on FRAME is by
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))),
MessageBeep (sound_type);
}
+DEFUN ("w32--menu-bar-in-use", Fw32__menu_bar_in_use, Sw32__menu_bar_in_use,
+ 0, 0, 0,
+ doc: /* Return non-nil when a menu-bar menu is being used.
+Internal use only. */)
+ (void)
+{
+ return menubar_in_use ? Qt : Qnil;
+}
+
\f
/***********************************************************************
Initialization
defsubr (&Sw32_frame_rect);
defsubr (&Sw32_frame_menu_bar_size);
defsubr (&Sw32_battery_status);
+ defsubr (&Sw32__menu_bar_in_use);
#ifdef WINDOWSNT
defsubr (&Sfile_system_info);