/* Graphical user interface functions for the Microsoft Windows API.
-Copyright (C) 1989, 1992-2013 Free Software Foundation, Inc.
+Copyright (C) 1989, 1992-2015 Free Software Foundation, Inc.
This file is part of GNU Emacs.
rect->right = mi.rcMonitor.right;
rect->bottom = mi.rcMonitor.bottom;
break;
- case FULLSCREEN_MAXIMIZED:
- rect->left = mi.rcWork.left;
- rect->top = mi.rcWork.top;
- rect->right = mi.rcWork.right;
- rect->bottom = mi.rcWork.bottom;
- break;
case FULLSCREEN_WIDTH:
rect->left = mi.rcWork.left;
rect->top = normal.top;
rect->right = normal.right;
rect->bottom = mi.rcWork.bottom;
break;
- case FULLSCREEN_NONE:
default:
*rect = normal;
break;
horizontal_drag_cursor
= XCreateFontCursor (FRAME_X_DISPLAY (f), XC_sb_h_double_arrow);
+ if (!NILP (Vx_window_vertical_drag_shape))
+ {
+ CHECK_NUMBER (Vx_window_vertical_drag_shape);
+ vertical_drag_cursor
+ = XCreateFontCursor (FRAME_X_DISPLAY (f),
+ XINT (Vx_window_vertical_drag_shape));
+ }
+ else
+ vertical_drag_cursor
+ = XCreateFontCursor (FRAME_X_DISPLAY (f), XC_sb_v_double_arrow);
+
/* Check and report errors with the above calls. */
x_check_errors (FRAME_W32_DISPLAY (f), "can't set cursor shape: %s");
x_uncatch_errors (FRAME_W32_DISPLAY (f), count);
nlines = 0;
FRAME_MENU_BAR_LINES (f) = 0;
+ FRAME_MENU_BAR_HEIGHT (f) = 0;
if (nlines)
FRAME_EXTERNAL_MENU_BAR (f) = 1;
else
/* Adjust the frame size so that the client (text) dimensions
remain the same. This depends on FRAME_EXTERNAL_MENU_BAR being
set correctly. */
- x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
+ x_set_window_size (f, 0, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 1);
do_pending_window_change (0);
}
adjust_frame_glyphs (f);
/* Set the number of lines used for the tool bar of frame F to VALUE.
- VALUE not an integer, or < 0 means set the lines to zero. OLDVAL
- is the old number of tool bar lines. This function changes the
- height of all windows on frame F to match the new tool bar height.
- The frame's height doesn't change. */
+ VALUE not an integer, or < 0 means set the lines to zero. OLDVAL is
+ the old number of tool bar lines (and is unused). This function may
+ change the height of all windows on frame F to match the new tool bar
+ height. By design, the frame's height doesn't change (but maybe it
+ should if we don't get enough space otherwise). */
void
x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
int delta, nlines, root_height;
- Lisp_Object root_window;
+ int unit = FRAME_LINE_HEIGHT (f);
/* Treat tool bars like menu bars. */
if (FRAME_MINIBUF_ONLY_P (f))
/* Make sure we redisplay all windows in this frame. */
windows_or_buffers_changed = 23;
- delta = nlines - FRAME_TOOL_BAR_LINES (f);
+ /* DELTA is in pixels now. */
+ delta = (nlines - FRAME_TOOL_BAR_LINES (f)) * unit;
- /* Don't resize the tool-bar to more than we have room for. */
- root_window = FRAME_ROOT_WINDOW (f);
- root_height = WINDOW_TOTAL_LINES (XWINDOW (root_window));
- if (root_height - delta < 1)
+ /* Don't resize the tool-bar to more than we have room for. Note: The
+ calculations below and the subsequent call to resize_frame_windows
+ are inherently flawed because they can make the toolbar higher than
+ the containing frame. */
+ if (delta > 0)
{
- delta = root_height - 1;
- nlines = FRAME_TOOL_BAR_LINES (f) + delta;
+ root_height = WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_ROOT_WINDOW (f)));
+ if (root_height - delta < unit)
+ {
+ delta = root_height - unit;
+ /* When creating a new frame and toolbar mode is enabled, we
+ need at least one toolbar line. */
+ nlines = max (FRAME_TOOL_BAR_LINES (f) + delta / unit, 1);
+ }
}
FRAME_TOOL_BAR_LINES (f) = nlines;
- resize_frame_windows (f, FRAME_LINES (f), 0);
+ FRAME_TOOL_BAR_HEIGHT (f) = nlines * FRAME_LINE_HEIGHT (f);
+ ++windows_or_buffers_changed;
+ resize_frame_windows (f, FRAME_TEXT_HEIGHT (f), 0, 1);
adjust_frame_glyphs (f);
/* We also have to make sure that the internal border at the top of
below the tool bar if one is displayed, but is below the menu bar
if there isn't a tool bar. The tool bar draws into the area
below the menu bar. */
- if (FRAME_W32_WINDOW (f) && FRAME_TOOL_BAR_LINES (f) == 0)
+ if (FRAME_W32_WINDOW (f) && FRAME_TOOL_BAR_HEIGHT (f) == 0)
{
clear_frame (f);
clear_current_matrices (f);
/* If the tool bar gets smaller, the internal border below it
has to be cleared. It was formerly part of the display
of the larger tool bar, and updating windows won't clear it. */
- if (delta < 0)
+ if (FRAME_INTERNAL_BORDER_WIDTH (f) != 0 && FRAME_VISIBLE_P (f))
{
int height = FRAME_INTERNAL_BORDER_WIDTH (f);
int width = FRAME_PIXEL_WIDTH (f);
- int y = nlines * FRAME_LINE_HEIGHT (f);
+ int y = nlines * unit;
+ HDC hdc = get_frame_dc (f);
block_input ();
- {
- HDC hdc = get_frame_dc (f);
- w32_clear_area (f, hdc, 0, y, width, height);
- release_frame_dc (f, hdc);
- }
+ w32_clear_area (f, hdc, 0, y, width, height);
+ release_frame_dc (f, hdc);
unblock_input ();
-
- if (WINDOWP (f->tool_bar_window))
- clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
}
- run_window_configuration_change_hook (f);
+ if (delta < 0 && WINDOWP (f->tool_bar_window))
+ clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
+ run_window_configuration_change_hook (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
x_set_scroll_bar_default_width (struct frame *f)
{
- int wid = FRAME_COLUMN_WIDTH (f);
+ int unit = FRAME_COLUMN_WIDTH (f);
FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
- FRAME_CONFIG_SCROLL_BAR_COLS (f) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) +
- wid - 1) / wid;
+ FRAME_CONFIG_SCROLL_BAR_COLS (f)
+ = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + unit - 1) / unit;
}
\f
{
return CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE,
/* Position and size of scroll bar. */
- XINT (bar->left), XINT (bar->top),
- XINT (bar->width), XINT (bar->height),
+ bar->left, bar->top, bar->width, bar->height,
FRAME_W32_WINDOW (f), NULL, hinst, NULL);
}
static void
-w32_createwindow (struct frame *f)
+w32_createwindow (struct frame *f, int *coords)
{
HWND hwnd;
RECT rect;
- Lisp_Object top = Qunbound;
- Lisp_Object left = Qunbound;
- struct w32_display_info *dpyinfo = &one_w32_display_info;
+ int top;
+ int left;
rect.left = rect.top = 0;
rect.right = FRAME_PIXEL_WIDTH (f);
if (f->size_hint_flags & USPosition || f->size_hint_flags & PPosition)
{
- XSETINT (left, f->left_pos);
- XSETINT (top, f->top_pos);
+ left = f->left_pos;
+ top = f->top_pos;
}
- else if (EQ (left, Qunbound) && EQ (top, Qunbound))
+ else
{
- /* When called with RES_TYPE_NUMBER, w32_get_arg will return zero
- for anything that is not a number and is not Qunbound. */
- left = x_get_arg (dpyinfo, Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER);
- top = x_get_arg (dpyinfo, Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER);
+ left = coords[0];
+ top = coords[1];
}
FRAME_W32_WINDOW (f) = hwnd
= CreateWindow (EMACS_CLASS,
f->namebuf,
f->output_data.w32->dwStyle | WS_CLIPCHILDREN,
- EQ (left, Qunbound) ? CW_USEDEFAULT : XINT (left),
- EQ (top, Qunbound) ? CW_USEDEFAULT : XINT (top),
- rect.right - rect.left,
- rect.bottom - rect.top,
+ left, top,
+ rect.right - rect.left, rect.bottom - rect.top,
NULL,
NULL,
hinst,
SetWindowLong (hwnd, WND_FONTWIDTH_INDEX, FRAME_COLUMN_WIDTH (f));
SetWindowLong (hwnd, WND_LINEHEIGHT_INDEX, FRAME_LINE_HEIGHT (f));
SetWindowLong (hwnd, WND_BORDER_INDEX, FRAME_INTERNAL_BORDER_WIDTH (f));
- SetWindowLong (hwnd, WND_SCROLLBAR_INDEX, f->scroll_bar_actual_width);
+ SetWindowLong (hwnd, WND_SCROLLBAR_INDEX, FRAME_SCROLL_BAR_AREA_WIDTH (f));
SetWindowLong (hwnd, WND_BACKGROUND_INDEX, FRAME_BACKGROUND_PIXEL (f));
/* Enable drag-n-drop. */
#define CURRENT_STATE(key) ((GetAsyncKeyState (key) & 0x8000) >> 8)
+ memset (keystate, 0, sizeof (keystate));
GetKeyboardState (keystate);
keystate[VK_SHIFT] = CURRENT_STATE (VK_SHIFT);
keystate[VK_CONTROL] = CURRENT_STATE (VK_CONTROL);
the patch for XP is not publicly available until XP SP3,
and older versions will never be patched. */
CoInitialize (NULL);
- w32_createwindow ((struct frame *) msg.wParam);
+ w32_createwindow ((struct frame *) msg.wParam,
+ (int *) msg.lParam);
if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
emacs_abort ();
break;
- WINDOW_RIGHT_MARGIN_WIDTH (w)
- WINDOW_RIGHT_FRINGE_WIDTH (w));
form.rcArea.bottom = (WINDOW_BOTTOM_EDGE_Y (w)
+ - WINDOW_BOTTOM_DIVIDER_WIDTH (w)
- w32_system_caret_mode_height);
/* Punt if the window was deleted behind our back. */
tme.cbSize = sizeof (tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hwnd;
+ tme.dwHoverTime = HOVER_DEFAULT;
track_mouse_event_fn (&tme);
track_mouse_window = hwnd;
case WM_WINDOWPOSCHANGING:
/* Don't restrict the sizing of tip frames. */
- if (hwnd == tip_window)
+ if (frame_resize_pixelwise || hwnd == tip_window)
return 0;
/* Don't restrict the sizing of fullscreened frames, allowing them to be
wp.length = sizeof (WINDOWPLACEMENT);
GetWindowPlacement (hwnd, &wp);
- if (wp.showCmd != SW_SHOWMINIMIZED && (lppos->flags & SWP_NOSIZE) == 0)
+ if (wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED
+ && (lppos->flags & SWP_NOSIZE) == 0)
{
RECT rect;
int wdiff;
my_create_window (struct frame * f)
{
MSG msg;
+ static int coords[2];
+ Lisp_Object left, top;
+ struct w32_display_info *dpyinfo = &one_w32_display_info;
- if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW, (WPARAM)f, 0))
+ /* When called with RES_TYPE_NUMBER, x_get_arg will return zero for
+ anything that is not a number and is not Qunbound. */
+ left = x_get_arg (dpyinfo, Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER);
+ top = x_get_arg (dpyinfo, Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER);
+ if (EQ (left, Qunbound))
+ coords[0] = CW_USEDEFAULT;
+ else
+ coords[0] = XINT (left);
+ if (EQ (top, Qunbound))
+ coords[1] = CW_USEDEFAULT;
+ else
+ coords[1] = XINT (top);
+
+ if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW,
+ (WPARAM)f, (LPARAM)coords))
emacs_abort ();
GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
}
{
#ifdef GLYPH_DEBUG
struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
+
+ /* If the frame's image cache refcount is still the same as our
+ private shadow variable, it means we are unwinding a frame
+ for which we didn't yet call init_frame_faces, where the
+ refcount is incremented. Therefore, we increment it here, so
+ that free_frame_faces, called in x_free_frame_resources
+ below, will not mistakenly decrement the counter that was not
+ incremented yet to account for this new frame. */
+ if (FRAME_IMAGE_CACHE (f) != NULL
+ && FRAME_IMAGE_CACHE (f)->refcount == image_cache_refcount)
+ FRAME_IMAGE_CACHE (f)->refcount++;
#endif
x_free_frame_resources (f);
#ifdef GLYPH_DEBUG
/* Check that reference counts are indeed correct. */
eassert (dpyinfo->reference_count == dpyinfo_refcount);
- eassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount);
+ eassert ((dpyinfo->terminal->image_cache == NULL
+ && image_cache_refcount == 0)
+ || (dpyinfo->terminal->image_cache != NULL
+ && dpyinfo->terminal->image_cache->refcount == image_cache_refcount));
#endif
return Qt;
}
unwind_create_frame (frame);
}
+static void
+unwind_create_frame_1 (Lisp_Object val)
+{
+ inhibit_lisp_code = val;
+}
+
static void
x_default_font_parameter (struct frame *f, Lisp_Object parms)
{
Lisp_Object parent;
struct kboard *kb;
+ if (!FRAME_W32_P (SELECTED_FRAME ())
+ && !FRAME_INITIAL_P (SELECTED_FRAME ()))
+ error ("Cannot create a GUI frame in a -nw session");
+
/* Make copy of frame parameters because the original is in pure
storage now. */
parameters = Fcopy_alist (parameters);
frame = Qnil;
GCPRO4 (parameters, parent, name, frame);
tem = x_get_arg (dpyinfo, parameters, Qminibuffer, "minibuffer", "Minibuffer",
- RES_TYPE_SYMBOL);
+ RES_TYPE_SYMBOL);
if (EQ (tem, Qnone) || NILP (tem))
f = make_frame_without_minibuffer (Qnil, kb, display);
else if (EQ (tem, Qonly))
XSETFRAME (frame, f);
/* By default, make scrollbars the system standard width. */
- FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = GetSystemMetrics (SM_CXVSCROLL);
+ x_set_scroll_bar_default_width (f);
f->terminal = dpyinfo->terminal;
if (! STRINGP (f->icon_name))
fset_icon_name (f, Qnil);
-/* FRAME_DISPLAY_INFO (f) = dpyinfo; */
+ /* FRAME_DISPLAY_INFO (f) = dpyinfo; */
/* With FRAME_DISPLAY_INFO set up, this unwind-protect is safe. */
record_unwind_protect (do_unwind_create_frame, frame);
+
#ifdef GLYPH_DEBUG
image_cache_refcount =
FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
Lisp_Object value;
value = x_get_arg (dpyinfo, parameters, Qinternal_border_width,
- "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
+ "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
if (! EQ (value, Qunbound))
parameters = Fcons (Fcons (Qinternal_border_width, value),
parameters);
/* Default internalBorderWidth to 0 on Windows to match other programs. */
x_default_parameter (f, parameters, Qinternal_border_width, make_number (0),
"internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER);
+ x_default_parameter (f, parameters, Qright_divider_width, make_number (0),
+ NULL, NULL, RES_TYPE_NUMBER);
+ x_default_parameter (f, parameters, Qbottom_divider_width, make_number (0),
+ NULL, NULL, RES_TYPE_NUMBER);
x_default_parameter (f, parameters, Qvertical_scroll_bars, Qright,
"verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
"leftFringe", "LeftFringe", RES_TYPE_NUMBER);
x_default_parameter (f, parameters, Qright_fringe, Qnil,
"rightFringe", "RightFringe", RES_TYPE_NUMBER);
+ /* Process alpha here (Bug#16619). */
+ x_default_parameter (f, parameters, Qalpha, Qnil,
+ "alpha", "Alpha", RES_TYPE_NUMBER);
/* Init faces before x_default_parameter is called for scroll-bar
parameters because that function calls x_set_scroll_bar_width,
happen. */
init_frame_faces (f);
- /* The X resources controlling the menu-bar and tool-bar are
- processed specially at startup, and reflected in the mode
- variables; ignore them here. */
- x_default_parameter (f, parameters, Qmenu_bar_lines,
- NILP (Vmenu_bar_mode)
- ? make_number (0) : make_number (1),
- NULL, NULL, RES_TYPE_NUMBER);
- x_default_parameter (f, parameters, Qtool_bar_lines,
- NILP (Vtool_bar_mode)
- ? make_number (0) : make_number (1),
- NULL, NULL, RES_TYPE_NUMBER);
+ /* Avoid calling window-configuration-change-hook; otherwise we
+ could get an infloop in next_frame since the frame is not yet in
+ Vframe_list. */
+ {
+ ptrdiff_t count2 = SPECPDL_INDEX ();
+
+ record_unwind_protect (unwind_create_frame_1, inhibit_lisp_code);
+ inhibit_lisp_code = Qt;
+
+ /* PXW: This is a duplicate from below. We have to do it here since
+ otherwise x_set_tool_bar_lines will work with the character sizes
+ installed by init_frame_faces while the frame's pixel size is still
+ calculated from a character size of 1 and we subsequently hit the
+ eassert (height >= 0) assertion in window_box_height. The
+ non-pixelwise code apparently worked around this because it had one
+ frame line vs one toolbar line which left us with a zero root
+ window height which was obviously wrong as well ... */
+ change_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
+ FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 1, 0, 0, 1);
+
+ /* The X resources controlling the menu-bar and tool-bar are
+ processed specially at startup, and reflected in the mode
+ variables; ignore them here. */
+ x_default_parameter (f, parameters, Qmenu_bar_lines,
+ NILP (Vmenu_bar_mode)
+ ? make_number (0) : make_number (1),
+ NULL, NULL, RES_TYPE_NUMBER);
+ x_default_parameter (f, parameters, Qtool_bar_lines,
+ NILP (Vtool_bar_mode)
+ ? make_number (0) : make_number (1),
+ NULL, NULL, RES_TYPE_NUMBER);
+
+ unbind_to (count2, Qnil);
+ }
x_default_parameter (f, parameters, Qbuffer_predicate, Qnil,
"bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
f->output_data.w32->hand_cursor = w32_load_cursor (IDC_HAND);
f->output_data.w32->hourglass_cursor = w32_load_cursor (IDC_WAIT);
f->output_data.w32->horizontal_drag_cursor = w32_load_cursor (IDC_SIZEWE);
+ f->output_data.w32->vertical_drag_cursor = w32_load_cursor (IDC_SIZENS);
f->output_data.w32->current_cursor = f->output_data.w32->nontext_cursor;
"cursorType", "CursorType", RES_TYPE_SYMBOL);
x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
"scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
- x_default_parameter (f, parameters, Qalpha, Qnil,
- "alpha", "Alpha", RES_TYPE_NUMBER);
/* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
Change will not be effected unless different from the current
FRAME_LINES (f). */
- width = FRAME_COLS (f);
- height = FRAME_LINES (f);
-
- FRAME_LINES (f) = 0;
- SET_FRAME_COLS (f, 0);
- change_frame_size (f, height, width, 1, 0, 0);
+ width = FRAME_TEXT_WIDTH (f);
+ height = FRAME_TEXT_HEIGHT (f);
+ FRAME_TEXT_HEIGHT (f) = 0;
+ SET_FRAME_WIDTH (f, 0);
+ change_frame_size (f, width, height, 1, 0, 0, 1);
/* 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
}
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);
}
x_default_parameter (f, parms, Qinternal_border_width, make_number (1),
"internalBorderWidth", "internalBorderWidth",
RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qright_divider_width, make_number (0),
+ NULL, NULL, RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qbottom_divider_width, make_number (0),
+ NULL, NULL, RES_TYPE_NUMBER);
/* Also do the stuff which must be set before the window exists. */
x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
x_default_parameter (f, parms, Qcursor_type, Qbox,
"cursorType", "CursorType", RES_TYPE_SYMBOL);
- /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
- Change will not be effected unless different from the current
- FRAME_LINES (f). */
+ /* Dimensions, especially FRAME_LINES (f), must be done via
+ change_frame_size. Change will not be effected unless different
+ from the current FRAME_LINES (f). */
width = FRAME_COLS (f);
height = FRAME_LINES (f);
FRAME_LINES (f) = 0;
SET_FRAME_COLS (f, 0);
- change_frame_size (f, height, width, 1, 0, 0);
+ change_frame_size (f, width, height, 1, 0, 0, 0);
/* Add `tooltip' frame parameter's default value. */
if (NILP (Fframe_parameter (frame, Qtooltip)))
/* Put tooltip in topmost group and in position. */
SetWindowPos (FRAME_W32_WINDOW (f), HWND_TOPMOST,
root_x, root_y, 0, 0,
- SWP_NOSIZE | SWP_NOACTIVATE);
+ SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
/* Ensure tooltip is on top of other topmost windows (eg menus). */
SetWindowPos (FRAME_W32_WINDOW (f), HWND_TOP,
0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ SWP_NOMOVE | SWP_NOSIZE
+ | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
unblock_input ();
goto start_timer;
parms = Fcons (Fcons (Qname, build_string ("tooltip")), parms);
if (NILP (Fassq (Qinternal_border_width, parms)))
parms = Fcons (Fcons (Qinternal_border_width, make_number (3)), parms);
+ if (NILP (Fassq (Qright_divider_width, parms)))
+ parms = Fcons (Fcons (Qright_divider_width, make_number (0)), parms);
+ if (NILP (Fassq (Qbottom_divider_width, parms)))
+ parms = Fcons (Fcons (Qbottom_divider_width, make_number (0)), parms);
if (NILP (Fassq (Qborder_width, parms)))
parms = Fcons (Fcons (Qborder_width, make_number (1)), parms);
if (NILP (Fassq (Qborder_color, parms)))
w = XWINDOW (FRAME_ROOT_WINDOW (f));
w->left_col = 0;
w->top_line = 0;
+ w->pixel_left = 0;
+ w->pixel_top = 0;
if (CONSP (Vx_max_tooltip_size)
&& INTEGERP (XCAR (Vx_max_tooltip_size))
w->total_lines = 40;
}
+ w->pixel_width = w->total_cols * FRAME_COLUMN_WIDTH (f);
+ w->pixel_height = w->total_lines * FRAME_LINE_HEIGHT (f);
+
FRAME_TOTAL_COLS (f) = WINDOW_TOTAL_COLS (w);
adjust_frame_glyphs (f);
w->pseudo_window_p = 1;
width of the frame. */
if (seen_reversed_p)
{
- /* w->total_cols and FRAME_TOTAL_COLS want the width in columns,
+ /* PXW: Why do we do the pixel-to-cols conversion only if
+ seen_reversed_p holds? Don't we have to set other fields of
+ the window/frame structure?
+
+ w->total_cols and FRAME_TOTAL_COLS want the width in columns,
not in pixels. */
+ w->pixel_width = width;
width /= WINDOW_FRAME_COLUMN_WIDTH (w);
w->total_cols = width;
FRAME_TOTAL_COLS (f) = width;
+ SET_FRAME_WIDTH (f, width);
adjust_frame_glyphs (f);
w->pseudo_window_p = 1;
clear_glyph_matrix (w->desired_matrix);
}
}
- /* Round up the height to an integral multiple of FRAME_LINE_HEIGHT. */
- if (height % FRAME_LINE_HEIGHT (f) != 0)
- height += FRAME_LINE_HEIGHT (f) - height % FRAME_LINE_HEIGHT (f);
/* Add the frame's internal border to the width and height the w32
window should have. */
height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
width += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
/* Move the tooltip window where the mouse pointer is. Resize and
- show it. */
+ show it.
+
+ PXW: This should use the frame's pixel coordinates. */
compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
{
SetWindowPos (FRAME_W32_WINDOW (f), HWND_TOPMOST,
root_x, root_y,
rect.right - rect.left + FRAME_COLUMN_WIDTH (f),
- rect.bottom - rect.top, SWP_NOACTIVATE);
+ rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER);
/* Ensure tooltip is on top of other topmost windows (eg menus). */
SetWindowPos (FRAME_W32_WINDOW (f), HWND_TOP,
0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ SWP_NOMOVE | SWP_NOSIZE
+ | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
/* Let redisplay know that we have made the frame visible already. */
SET_FRAME_VISIBLE (f, 1);
This function is only defined on NS, MS Windows, and X Windows with the
Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
-Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
+Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.
+On Windows 7 and later, the file selection dialog "remembers" the last
+directory where the user selected a file, and will open that directory
+instead of DIR on subsequent invocations of this function with the same
+value of DIR as in previous invocations; this is standard Windows behavior. */)
(Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
{
/* Filter index: 1: All Files, 2: Directories only */
if (errno == ENOENT && filename_buf_w[MAX_PATH - 1] != 0)
report_file_error ("filename too long", default_filename);
}
- len = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
- SSDATA (prompt), -1, NULL, 0);
+ len = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ SSDATA (prompt), -1, NULL, 0);
if (len > 32768)
len = 32768;
prompt_w = alloca (len * sizeof (wchar_t));
- MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
- SSDATA (prompt), -1, prompt_w, len);
+ pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ SSDATA (prompt), -1, prompt_w, len);
}
else
{
if (errno == ENOENT && filename_buf_a[MAX_PATH - 1] != 0)
report_file_error ("filename too long", default_filename);
}
- len = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
- SSDATA (prompt), -1, NULL, 0);
+ len = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ SSDATA (prompt), -1, NULL, 0);
if (len > 32768)
len = 32768;
prompt_w = alloca (len * sizeof (wchar_t));
- MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
- SSDATA (prompt), -1, prompt_w, len);
- len = WideCharToMultiByte (CP_ACP, 0, prompt_w, -1, NULL, 0, NULL, NULL);
+ pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+ SSDATA (prompt), -1, prompt_w, len);
+ len = pWideCharToMultiByte (CP_ACP, 0, prompt_w, -1, NULL, 0, NULL, NULL);
if (len > 32768)
len = 32768;
prompt_a = alloca (len);
- WideCharToMultiByte (CP_ACP, 0, prompt_w, -1, prompt_a, len, NULL, NULL);
+ pWideCharToMultiByte (CP_ACP, 0, prompt_w, -1, prompt_a, len, NULL, NULL);
}
#endif /* NTGUI_UNICODE */
file_details_w->lpstrFilter = filter_w;
#ifdef NTGUI_UNICODE
file_details_w->lpstrInitialDir = (wchar_t*) SDATA (dir);
- file_details->lpstrTitle = (guichar_t*) SDATA (prompt);
+ file_details_w->lpstrTitle = (guichar_t*) SDATA (prompt);
#else
file_details_w->lpstrInitialDir = dir_w;
file_details_w->lpstrTitle = prompt_w;
file_details_w->Flags |= OFN_FILEMUSTEXIST;
}
}
+#ifndef NTGUI_UNICODE
else
{
memset (&new_file_details_a, 0, sizeof (new_file_details_a));
file_details_a->Flags |= OFN_FILEMUSTEXIST;
}
}
+#endif /* !NTGUI_UNICODE */
{
int count = SPECPDL_INDEX ();
file_opened = GetOpenFileNameW (file_details_w);
}
+#ifndef NTGUI_UNICODE
else
{
file_details_a->lpfnHook = file_dialog_callback;
file_opened = GetOpenFileNameA (file_details_a);
}
+#endif /* !NTGUI_UNICODE */
unblock_input ();
unbind_to (count, Qnil);
}
/* Strip the dummy filename off the end of the string if we
added it to select a directory. */
- if (use_unicode && file_details_w->nFilterIndex == 2
- || !use_unicode && file_details_a->nFilterIndex == 2)
+ if ((use_unicode && file_details_w->nFilterIndex == 2)
+#ifndef NTGUI_UNICODE
+ || (!use_unicode && file_details_a->nFilterIndex == 2)
+#endif
+ )
filename = Ffile_name_directory (filename);
}
/* User canceled the dialog without making a selection. */
operations:
\"open\" - open DOCUMENT, which could be a file, a directory, or an
- executable program. If it is an application, that
- application is launched in the current buffer's default
+ executable program (application). If it is an application,
+ that application is launched in the current buffer's default
directory. Otherwise, the application associated with
DOCUMENT is launched in the buffer's default directory.
- \"print\" - print DOCUMENT, which must be a file
- \"explore\" - start the Windows Explorer on DOCUMENT
+ \"opennew\" - like \"open\", but instruct the application to open
+ DOCUMENT in a new window.
+ \"openas\" - open the \"Open With\" dialog for DOCUMENT.
+ \"print\" - print DOCUMENT, which must be a file.
+ \"printto\" - print DOCUMENT, which must be a file, to a specified printer.
+ The printer should be provided in PARAMETERS, see below.
+ \"explore\" - start the Windows Explorer on DOCUMENT.
\"edit\" - launch an editor and open DOCUMENT for editing; which
editor is launched depends on the association for the
- specified DOCUMENT
- \"find\" - initiate search starting from DOCUMENT which must specify
- a directory
+ specified DOCUMENT.
+ \"find\" - initiate search starting from DOCUMENT, which must specify
+ a directory.
+ \"runas\" - run DOCUMENT, which must be an excutable file, with
+ elevated privileges (a.k.a. \"as Administrator\").
+ \"properties\"
+ - open the the property sheet dialog for DOCUMENT; works
+ for *.lnk desktop shortcuts, and little or nothing else.
nil - invoke the default OPERATION, or \"open\" if default is
- not defined or unavailable
+ not defined or unavailable.
DOCUMENT is typically the name of a document file or a URL, but can
-also be a program executable to run, or a directory to open in the
-Windows Explorer.
+also be an executable program to run, or a directory to open in the
+Windows Explorer. If it is a file, it must be a local one; this
+function does not support remote file names.
-If DOCUMENT is a program executable, the optional third arg PARAMETERS
+If DOCUMENT is an executable program, the optional third arg PARAMETERS
can be a string containing command line parameters that will be passed
-to the program; otherwise, PARAMETERS should be nil or unspecified.
+to the program. Some values of OPERATION also require parameters (e.g.,
+\"printto\" requires the printer address). Otherwise, PARAMETERS should
+be nil or unspecified.
Optional fourth argument SHOW-FLAG can be used to control how the
application will be displayed when it is invoked. If SHOW-FLAG is nil
-or unspecified, the application is displayed normally, otherwise it is
-an integer representing a ShowWindow flag:
+or unspecified, the application is displayed as if SHOW-FLAG of 10 was
+specified, otherwise it is an integer between 0 and 11 representing
+a ShowWindow flag:
0 - start hidden
- 1 - start normally
- 3 - start maximized
- 6 - start minimized */)
+ 1 - start as normal-size window
+ 3 - start in a maximized window
+ 6 - start in a minimized window
+ 10 - start as the application itself specifies; this is the default. */)
(Lisp_Object operation, Lisp_Object document, Lisp_Object parameters, Lisp_Object show_flag)
{
char *errstr;
Lisp_Object current_dir = BVAR (current_buffer, directory);;
wchar_t *doc_w = NULL, *params_w = NULL, *ops_w = NULL;
- int result;
+ intptr_t result;
#ifndef CYGWIN
int use_unicode = w32_unicode_filenames;
char *doc_a = NULL, *params_a = NULL, *ops_a = NULL;
+ Lisp_Object absdoc, handler;
+ struct gcpro gcpro1;
#endif
CHECK_STRING (document);
#ifdef CYGWIN
current_dir = Fcygwin_convert_file_name_to_windows (current_dir, Qt);
- if (STRINGP (document))
- document = Fcygwin_convert_file_name_to_windows (document, Qt);
+ document = Fcygwin_convert_file_name_to_windows (document, Qt);
/* Encode filename, current directory and parameters. */
current_dir = GUI_ENCODE_FILE (current_dir);
- if (STRINGP (document))
- {
- document = GUI_ENCODE_FILE (document);
- doc_w = GUI_SDATA (document);
- }
+ document = GUI_ENCODE_FILE (document);
+ doc_w = GUI_SDATA (document);
if (STRINGP (parameters))
{
parameters = GUI_ENCODE_SYSTEM (parameters);
operation = GUI_ENCODE_SYSTEM (operation);
ops_w = GUI_SDATA (operation);
}
- result = (int) ShellExecuteW (NULL, ops_w, doc_w, params_w,
- GUI_SDATA (current_dir),
- (INTEGERP (show_flag)
- ? XINT (show_flag) : SW_SHOWDEFAULT));
+ result = (intptr_t) ShellExecuteW (NULL, ops_w, doc_w, params_w,
+ GUI_SDATA (current_dir),
+ (INTEGERP (show_flag)
+ ? XINT (show_flag) : SW_SHOWDEFAULT));
#else /* !CYGWIN */
+ current_dir = ENCODE_FILE (current_dir);
+ /* 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
+ will fail to find it. So we need to make the file name is
+ absolute. But DOCUMENT does not have to be a file, it can be a
+ URL, for example. So we make it absolute only if it is an
+ existing file; if it is a file that does not exist, tough. */
+ GCPRO1 (absdoc);
+ absdoc = Fexpand_file_name (document, Qnil);
+ /* Don't call file handlers for file-exists-p, since they might
+ attempt to access the file, which could fail or produce undesired
+ consequences, see bug#16558 for an example. */
+ handler = Ffind_file_name_handler (absdoc, Qfile_exists_p);
+ if (NILP (handler))
+ {
+ Lisp_Object absdoc_encoded = ENCODE_FILE (absdoc);
+
+ if (faccessat (AT_FDCWD, SSDATA (absdoc_encoded), F_OK, AT_EACCESS) == 0)
+ {
+ /* ShellExecute fails if DOCUMENT is a UNC with forward
+ slashes (expand-file-name above converts all backslashes
+ to forward slashes). Now that we know DOCUMENT is a
+ file, we can mirror all forward slashes into backslashes. */
+ unixtodos_filename (SSDATA (absdoc_encoded));
+ document = absdoc_encoded;
+ }
+ else
+ document = ENCODE_FILE (document);
+ }
+ else
+ document = ENCODE_FILE (document);
+ UNGCPRO;
if (use_unicode)
{
wchar_t document_w[MAX_PATH], current_dir_w[MAX_PATH];
/* Encode filename, current directory and parameters, and
convert operation to UTF-16. */
- current_dir = ENCODE_FILE (current_dir);
filename_to_utf16 (SSDATA (current_dir), current_dir_w);
- if (STRINGP (document))
- {
- document = ENCODE_FILE (document);
- filename_to_utf16 (SSDATA (document), document_w);
- doc_w = document_w;
- }
+ filename_to_utf16 (SSDATA (document), document_w);
+ doc_w = document_w;
if (STRINGP (parameters))
{
int len;
parameters = ENCODE_SYSTEM (parameters);
- len = MultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS,
- SSDATA (parameters), -1, NULL, 0);
+ len = pMultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS,
+ SSDATA (parameters), -1, NULL, 0);
if (len > 32768)
len = 32768;
params_w = alloca (len * sizeof (wchar_t));
- MultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS,
- SSDATA (parameters), -1, params_w, len);
+ pMultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS,
+ SSDATA (parameters), -1, params_w, len);
}
if (STRINGP (operation))
{
*d++ = *s++;
*d = 0;
}
- result = (int) ShellExecuteW (NULL, ops_w, doc_w, params_w,
- current_dir_w,
- (INTEGERP (show_flag)
- ? XINT (show_flag) : SW_SHOWDEFAULT));
+ result = (intptr_t) ShellExecuteW (NULL, ops_w, doc_w, params_w,
+ current_dir_w,
+ (INTEGERP (show_flag)
+ ? XINT (show_flag) : SW_SHOWDEFAULT));
}
else
{
char document_a[MAX_PATH], current_dir_a[MAX_PATH];
- current_dir = ENCODE_FILE (current_dir);
filename_to_ansi (SSDATA (current_dir), current_dir_a);
- if (STRINGP (document))
- {
- ENCODE_FILE (document);
- filename_to_ansi (SSDATA (document), document_a);
- doc_a = document_a;
- }
+ filename_to_ansi (SSDATA (document), document_a);
+ doc_a = document_a;
if (STRINGP (parameters))
{
- int len;
-
parameters = ENCODE_SYSTEM (parameters);
params_a = SSDATA (parameters);
}
/* Assume OPERATION is pure ASCII. */
ops_a = SSDATA (operation);
}
- result = (int) ShellExecuteA (NULL, ops_a, doc_a, params_a,
- current_dir_a,
- (INTEGERP (show_flag)
- ? XINT (show_flag) : SW_SHOWDEFAULT));
+ result = (intptr_t) ShellExecuteA (NULL, ops_a, doc_a, params_a,
+ current_dir_a,
+ (INTEGERP (show_flag)
+ ? XINT (show_flag) : SW_SHOWDEFAULT));
}
#endif /* !CYGWIN */
return Qt;
}
+DEFUN ("w32-frame-rect", Fw32_frame_rect, Sw32_frame_rect, 0, 2, 0,
+ doc: /* Return boundary rectangle of FRAME in screen coordinates.
+FRAME must be a live frame and defaults to the selected one.
+
+The boundary rectangle is a list of four elements, specifying the left,
+top, right and bottom screen coordinates of FRAME including menu and
+title bar and decorations. Optional argument CLIENT non-nil means to
+return the boundaries of the client rectangle which excludes menu and
+title bar and decorations. */)
+ (Lisp_Object frame, Lisp_Object client)
+{
+ struct frame *f = decode_live_frame (frame);
+ RECT rect;
+
+ if (!NILP (client))
+ GetClientRect (FRAME_W32_WINDOW (f), &rect);
+ else
+ GetWindowRect (FRAME_W32_WINDOW (f), &rect);
+
+ return list4 (make_number (rect.left), make_number (rect.top),
+ make_number (rect.right), make_number (rect.bottom));
+}
+
DEFUN ("w32-battery-status", Fw32_battery_status, Sw32_battery_status, 0, 0, 0,
doc: /* Get power status information from Windows system.
added rather late on. */
{
HMODULE hKernel = GetModuleHandle ("kernel32");
- BOOL (*pfn_GetDiskFreeSpaceEx)
+ BOOL (WINAPI *pfn_GetDiskFreeSpaceExW)
+ (wchar_t *, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER)
+ = GetProcAddress (hKernel, "GetDiskFreeSpaceExW");
+ BOOL (WINAPI *pfn_GetDiskFreeSpaceExA)
(char *, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER)
- = (void *) GetProcAddress (hKernel, "GetDiskFreeSpaceEx");
+ = GetProcAddress (hKernel, "GetDiskFreeSpaceExA");
+ bool have_pfn_GetDiskFreeSpaceEx =
+ (w32_unicode_filenames && pfn_GetDiskFreeSpaceExW
+ || !w32_unicode_filenames && pfn_GetDiskFreeSpaceExA);
/* On Windows, we may need to specify the root directory of the
volume holding FILENAME. */
- char rootname[MAX_PATH];
+ char rootname[MAX_UTF8_PATH];
+ wchar_t rootname_w[MAX_PATH];
+ char rootname_a[MAX_PATH];
char *name = SDATA (encoded);
+ BOOL result;
/* find the root name of the volume if given */
if (isalpha (name[0]) && name[1] == ':')
*str = 0;
}
- if (pfn_GetDiskFreeSpaceEx)
+ if (w32_unicode_filenames)
+ filename_to_utf16 (rootname, rootname_w);
+ else
+ filename_to_ansi (rootname, rootname_a);
+
+ if (have_pfn_GetDiskFreeSpaceEx)
{
/* Unsigned large integers cannot be cast to double, so
use signed ones instead. */
LARGE_INTEGER freebytes;
LARGE_INTEGER totalbytes;
- if (pfn_GetDiskFreeSpaceEx (rootname,
- (ULARGE_INTEGER *)&availbytes,
- (ULARGE_INTEGER *)&totalbytes,
- (ULARGE_INTEGER *)&freebytes))
+ if (w32_unicode_filenames)
+ result = pfn_GetDiskFreeSpaceExW (rootname_w,
+ (ULARGE_INTEGER *)&availbytes,
+ (ULARGE_INTEGER *)&totalbytes,
+ (ULARGE_INTEGER *)&freebytes);
+ else
+ result = pfn_GetDiskFreeSpaceExA (rootname_a,
+ (ULARGE_INTEGER *)&availbytes,
+ (ULARGE_INTEGER *)&totalbytes,
+ (ULARGE_INTEGER *)&freebytes);
+ if (result)
value = list3 (make_float ((double) totalbytes.QuadPart),
make_float ((double) freebytes.QuadPart),
make_float ((double) availbytes.QuadPart));
DWORD free_clusters;
DWORD total_clusters;
- if (GetDiskFreeSpace (rootname,
- §ors_per_cluster,
- &bytes_per_sector,
- &free_clusters,
- &total_clusters))
+ if (w32_unicode_filenames)
+ result = GetDiskFreeSpaceW (rootname_w,
+ §ors_per_cluster,
+ &bytes_per_sector,
+ &free_clusters,
+ &total_clusters);
+ else
+ result = GetDiskFreeSpaceA (rootname_a,
+ §ors_per_cluster,
+ &bytes_per_sector,
+ &free_clusters,
+ &total_clusters);
+ if (result)
value = list3 (make_float ((double) total_clusters
* sectors_per_cluster * bytes_per_sector),
make_float ((double) free_clusters
#endif /* WINDOWSNT */
\f
+#ifdef WINDOWSNT
DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
0, 0, 0, doc: /* Return the name of Windows default printer device. */)
(void)
return DECODE_FILE (build_unibyte_string (pname_buf));
}
+#endif /* WINDOWSNT */
\f
/* Equivalent of strerror for W32 error codes. */
x_set_icon_name,
x_set_icon_type,
x_set_internal_border_width,
+ x_set_right_divider_width,
+ x_set_bottom_divider_width,
x_set_menu_bar_lines,
x_set_mouse_color,
x_explicitly_set_name,
This variable takes effect when you create a new frame
or when you set the mouse color. */);
Vx_window_horizontal_drag_shape = Qnil;
+
+ DEFVAR_LISP ("x-window-vertical-drag-cursor",
+ Vx_window_vertical_drag_shape,
+ doc: /* Pointer shape to use for indicating a window can be dragged vertically.
+This variable takes effect when you create a new frame
+or when you set the mouse color. */);
+ Vx_window_vertical_drag_shape = Qnil;
#endif
DEFVAR_LISP ("x-cursor-fore-pixel", Vx_cursor_fore_pixel,
defsubr (&Sw32_reconstruct_hot_key);
defsubr (&Sw32_toggle_lock_key);
defsubr (&Sw32_window_exists_p);
+ defsubr (&Sw32_frame_rect);
defsubr (&Sw32_battery_status);
#ifdef WINDOWSNT
defsubr (&Sfile_system_info);
+ defsubr (&Sdefault_printer_name);
#endif
- defsubr (&Sdefault_printer_name);
defsubr (&Sset_message_beep);
hourglass_hwnd = NULL;
#endif
}
+\f
-/*
- globals_of_w32fns is used to initialize those global variables that
- must always be initialized on startup even when the global variable
- initialized is non zero (see the function main in emacs.c).
- globals_of_w32fns is called from syms_of_w32fns when the global
- variable initialized is 0 and directly from main when initialized
- is non zero.
- */
-void
-globals_of_w32fns (void)
-{
- HMODULE user32_lib = GetModuleHandle ("user32.dll");
- /*
- TrackMouseEvent not available in all versions of Windows, so must load
- it dynamically. Do it once, here, instead of every time it is used.
- */
- track_mouse_event_fn = (TrackMouseEvent_Proc)
- GetProcAddress (user32_lib, "TrackMouseEvent");
-
- monitor_from_point_fn = (MonitorFromPoint_Proc)
- GetProcAddress (user32_lib, "MonitorFromPoint");
- get_monitor_info_fn = (GetMonitorInfo_Proc)
- GetProcAddress (user32_lib, "GetMonitorInfoA");
- monitor_from_window_fn = (MonitorFromWindow_Proc)
- GetProcAddress (user32_lib, "MonitorFromWindow");
- enum_display_monitors_fn = (EnumDisplayMonitors_Proc)
- GetProcAddress (user32_lib, "EnumDisplayMonitors");
-
- {
- HMODULE imm32_lib = GetModuleHandle ("imm32.dll");
- get_composition_string_fn = (ImmGetCompositionString_Proc)
- GetProcAddress (imm32_lib, "ImmGetCompositionStringW");
- get_ime_context_fn = (ImmGetContext_Proc)
- GetProcAddress (imm32_lib, "ImmGetContext");
- release_ime_context_fn = (ImmReleaseContext_Proc)
- GetProcAddress (imm32_lib, "ImmReleaseContext");
- set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
- GetProcAddress (imm32_lib, "ImmSetCompositionWindow");
- }
- DEFVAR_INT ("w32-ansi-code-page",
- w32_ansi_code_page,
- doc: /* The ANSI code page used by the system. */);
- w32_ansi_code_page = GetACP ();
-
- if (os_subtype == OS_NT)
- w32_unicode_gui = 1;
- else
- w32_unicode_gui = 0;
+/* Crashing and reporting backtrace. */
- /* MessageBox does not work without this when linked to comctl32.dll 6.0. */
- InitCommonControls ();
+#ifndef CYGWIN
+static LONG CALLBACK my_exception_handler (EXCEPTION_POINTERS *);
+static LPTOP_LEVEL_EXCEPTION_FILTER prev_exception_handler;
+#endif
+static DWORD except_code;
+static PVOID except_addr;
- syms_of_w32uniscribe ();
+#ifndef CYGWIN
+/* This handler records the exception code and the address where it
+ was triggered so that this info could be included in the backtrace.
+ Without that, the backtrace in some cases has no information
+ whatsoever about the offending code, and looks as if the top-level
+ exception handler in the MinGW startup code di the one that
+ crashed. */
+static LONG CALLBACK
+my_exception_handler (EXCEPTION_POINTERS * exception_data)
+{
+ except_code = exception_data->ExceptionRecord->ExceptionCode;
+ except_addr = exception_data->ExceptionRecord->ExceptionAddress;
+
+ if (prev_exception_handler)
+ return prev_exception_handler (exception_data);
+ return EXCEPTION_EXECUTE_HANDLER;
}
+#endif
typedef USHORT (WINAPI * CaptureStackBackTrace_proc) (ULONG, ULONG, PVOID *,
PULONG);
if (i)
{
+ int errfile_fd = -1;
+ int j;
+ char buf[sizeof ("\r\nException at this address:\r\n\r\n")
+ /* The type below should really be 'void *', but
+ INT_BUFSIZE_BOUND cannot handle that without
+ triggering compiler warnings (under certain
+ pedantic warning switches), it wants an
+ integer type. */
+ + 2 * INT_BUFSIZE_BOUND (intptr_t)];
#ifdef CYGWIN
int stderr_fd = 2;
#else
HANDLE errout = GetStdHandle (STD_ERROR_HANDLE);
int stderr_fd = -1;
-#endif
- int errfile_fd = -1;
- int j;
-#ifndef CYGWIN
if (errout && errout != INVALID_HANDLE_VALUE)
stderr_fd = _open_osfhandle ((intptr_t)errout, O_APPEND | O_BINARY);
#endif
+
+ /* We use %p, not 0x%p, as %p produces a leading "0x" on XP,
+ but not on Windows 7. addr2line doesn't mind a missing
+ "0x", but will be confused by an extra one. */
+ if (except_addr)
+ sprintf (buf, "\r\nException 0x%lx at this address:\r\n%p\r\n",
+ except_code, except_addr);
if (stderr_fd >= 0)
- write (stderr_fd, "\r\nBacktrace:\r\n", 14);
+ {
+ if (except_addr)
+ write (stderr_fd, buf, strlen (buf));
+ write (stderr_fd, "\r\nBacktrace:\r\n", 14);
+ }
#ifdef CYGWIN
#define _open open
#endif
if (errfile_fd >= 0)
{
lseek (errfile_fd, 0L, SEEK_END);
+ if (except_addr)
+ write (errfile_fd, buf, strlen (buf));
write (errfile_fd, "\r\nBacktrace:\r\n", 14);
}
for (j = 0; j < i; j++)
{
- char buf[INT_BUFSIZE_BOUND (void *)];
-
/* stack[] gives the return addresses, whereas we want
the address of the call, so decrease each address
by approximate size of 1 CALL instruction. */
- sprintf (buf, "0x%p\r\n", (char *)stack[j] - sizeof(void *));
+ sprintf (buf, "%p\r\n", (char *)stack[j] - sizeof(void *));
if (stderr_fd >= 0)
write (stderr_fd, buf, strlen (buf));
if (errfile_fd >= 0)
}
}
+\f
+
+/* Initialization. */
+
+/*
+ globals_of_w32fns is used to initialize those global variables that
+ must always be initialized on startup even when the global variable
+ initialized is non zero (see the function main in emacs.c).
+ globals_of_w32fns is called from syms_of_w32fns when the global
+ variable initialized is 0 and directly from main when initialized
+ is non zero.
+ */
+void
+globals_of_w32fns (void)
+{
+ HMODULE user32_lib = GetModuleHandle ("user32.dll");
+ /*
+ TrackMouseEvent not available in all versions of Windows, so must load
+ it dynamically. Do it once, here, instead of every time it is used.
+ */
+ track_mouse_event_fn = (TrackMouseEvent_Proc)
+ GetProcAddress (user32_lib, "TrackMouseEvent");
+
+ monitor_from_point_fn = (MonitorFromPoint_Proc)
+ GetProcAddress (user32_lib, "MonitorFromPoint");
+ get_monitor_info_fn = (GetMonitorInfo_Proc)
+ GetProcAddress (user32_lib, "GetMonitorInfoA");
+ monitor_from_window_fn = (MonitorFromWindow_Proc)
+ GetProcAddress (user32_lib, "MonitorFromWindow");
+ enum_display_monitors_fn = (EnumDisplayMonitors_Proc)
+ GetProcAddress (user32_lib, "EnumDisplayMonitors");
+
+ {
+ HMODULE imm32_lib = GetModuleHandle ("imm32.dll");
+ get_composition_string_fn = (ImmGetCompositionString_Proc)
+ GetProcAddress (imm32_lib, "ImmGetCompositionStringW");
+ get_ime_context_fn = (ImmGetContext_Proc)
+ GetProcAddress (imm32_lib, "ImmGetContext");
+ release_ime_context_fn = (ImmReleaseContext_Proc)
+ GetProcAddress (imm32_lib, "ImmReleaseContext");
+ set_ime_composition_window_fn = (ImmSetCompositionWindow_Proc)
+ GetProcAddress (imm32_lib, "ImmSetCompositionWindow");
+ }
+
+ except_code = 0;
+ except_addr = 0;
+#ifndef CYGWIN
+ prev_exception_handler = SetUnhandledExceptionFilter (my_exception_handler);
+#endif
+
+ DEFVAR_INT ("w32-ansi-code-page",
+ w32_ansi_code_page,
+ doc: /* The ANSI code page used by the system. */);
+ w32_ansi_code_page = GetACP ();
+
+ if (os_subtype == OS_NT)
+ w32_unicode_gui = 1;
+ else
+ w32_unicode_gui = 0;
+
+ /* MessageBox does not work without this when linked to comctl32.dll 6.0. */
+ InitCommonControls ();
+
+ syms_of_w32uniscribe ();
+}
+
#ifdef NTGUI_UNICODE
Lisp_Object