aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2014-09-30 16:53:24 +0300
committerEli Zaretskii2014-09-30 16:53:24 +0300
commit572fe798cd0a00ad4a9050a7962cf8e8fbcc209b (patch)
treec08a6041773d15fb13f03458575c1b37f319d84f /src
parent42d4302f246931b0f92aa5341fe1a8cd9745db08 (diff)
downloademacs-572fe798cd0a00ad4a9050a7962cf8e8fbcc209b.tar.gz
emacs-572fe798cd0a00ad4a9050a7962cf8e8fbcc209b.zip
Fix creation of frames on MS-Windows: don't cons Lisp objects in input thread.
src/w32fns.c (w32_createwindow): Accept an additional argument, an array of 2 values specifying the coordinates of the frame's top-left corner. Use these values instead of calling x_get_arg, which can cons Lisp objects, and therefore cannot be called except from the main thread. Remove redundant tests for the default values. (my_create_window): Move the calculation of the coordinates of the frame's top-left edge here. Pass them to the input thread via the second parameter of the WM_EMACS_CREATEWINDOW message. See http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00892.html for the details.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/w32fns.c47
2 files changed, 44 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cc04e0cd826..fdc30da96b6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12014-09-30 Eli Zaretskii <eliz@gnu.org>
2
3 * w32fns.c (w32_createwindow): Accept an additional argument, an
4 array of 2 values specifying the coordinates of the frame's
5 top-left corner. Use these values instead of calling x_get_arg,
6 which can cons Lisp objects, and therefore cannot be called except
7 from the main thread. Remove redundant tests for the default
8 values.
9 (my_create_window): Move the calculation of the coordinates of the
10 frame's top-left edge here. Pass them to the input thread via the
11 second parameter of the WM_EMACS_CREATEWINDOW message. See
12 http://lists.gnu.org/archive/html/emacs-devel/2014-09/msg00892.html
13 for the details.
14
12014-09-29 Eli Zaretskii <eliz@gnu.org> 152014-09-29 Eli Zaretskii <eliz@gnu.org>
2 16
3 * xdisp.c (cursor_row_fully_visible_p): Update commentary. 17 * xdisp.c (cursor_row_fully_visible_p): Update commentary.
diff --git a/src/w32fns.c b/src/w32fns.c
index 1c73cda469a..bc95005f52a 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1911,13 +1911,12 @@ w32_createscrollbar (struct frame *f, struct scroll_bar * bar)
1911} 1911}
1912 1912
1913static void 1913static void
1914w32_createwindow (struct frame *f) 1914w32_createwindow (struct frame *f, int *coords)
1915{ 1915{
1916 HWND hwnd; 1916 HWND hwnd;
1917 RECT rect; 1917 RECT rect;
1918 Lisp_Object top = Qunbound; 1918 int top;
1919 Lisp_Object left = Qunbound; 1919 int left;
1920 struct w32_display_info *dpyinfo = &one_w32_display_info;
1921 1920
1922 rect.left = rect.top = 0; 1921 rect.left = rect.top = 0;
1923 rect.right = FRAME_PIXEL_WIDTH (f); 1922 rect.right = FRAME_PIXEL_WIDTH (f);
@@ -1932,25 +1931,21 @@ w32_createwindow (struct frame *f)
1932 1931
1933 if (f->size_hint_flags & USPosition || f->size_hint_flags & PPosition) 1932 if (f->size_hint_flags & USPosition || f->size_hint_flags & PPosition)
1934 { 1933 {
1935 XSETINT (left, f->left_pos); 1934 left = f->left_pos;
1936 XSETINT (top, f->top_pos); 1935 top = f->top_pos;
1937 } 1936 }
1938 else if (EQ (left, Qunbound) && EQ (top, Qunbound)) 1937 else
1939 { 1938 {
1940 /* When called with RES_TYPE_NUMBER, w32_get_arg will return zero 1939 left = coords[0];
1941 for anything that is not a number and is not Qunbound. */ 1940 top = coords[1];
1942 left = x_get_arg (dpyinfo, Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER);
1943 top = x_get_arg (dpyinfo, Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER);
1944 } 1941 }
1945 1942
1946 FRAME_W32_WINDOW (f) = hwnd 1943 FRAME_W32_WINDOW (f) = hwnd
1947 = CreateWindow (EMACS_CLASS, 1944 = CreateWindow (EMACS_CLASS,
1948 f->namebuf, 1945 f->namebuf,
1949 f->output_data.w32->dwStyle | WS_CLIPCHILDREN, 1946 f->output_data.w32->dwStyle | WS_CLIPCHILDREN,
1950 EQ (left, Qunbound) ? CW_USEDEFAULT : XINT (left), 1947 left, top,
1951 EQ (top, Qunbound) ? CW_USEDEFAULT : XINT (top), 1948 rect.right - rect.left, rect.bottom - rect.top,
1952 rect.right - rect.left,
1953 rect.bottom - rect.top,
1954 NULL, 1949 NULL,
1955 NULL, 1950 NULL,
1956 hinst, 1951 hinst,
@@ -2468,7 +2463,8 @@ w32_msg_pump (deferred_msg * msg_buf)
2468 the patch for XP is not publicly available until XP SP3, 2463 the patch for XP is not publicly available until XP SP3,
2469 and older versions will never be patched. */ 2464 and older versions will never be patched. */
2470 CoInitialize (NULL); 2465 CoInitialize (NULL);
2471 w32_createwindow ((struct frame *) msg.wParam); 2466 w32_createwindow ((struct frame *) msg.wParam,
2467 (int *) msg.lParam);
2472 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 2468 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
2473 emacs_abort (); 2469 emacs_abort ();
2474 break; 2470 break;
@@ -4069,8 +4065,25 @@ static void
4069my_create_window (struct frame * f) 4065my_create_window (struct frame * f)
4070{ 4066{
4071 MSG msg; 4067 MSG msg;
4068 static int coords[2];
4069 Lisp_Object left, top;
4070 struct w32_display_info *dpyinfo = &one_w32_display_info;
4071
4072 /* When called with RES_TYPE_NUMBER, x_get_arg will return zero for
4073 anything that is not a number and is not Qunbound. */
4074 left = x_get_arg (dpyinfo, Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER);
4075 top = x_get_arg (dpyinfo, Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER);
4076 if (EQ (left, Qunbound))
4077 coords[0] = CW_USEDEFAULT;
4078 else
4079 coords[0] = XINT (left);
4080 if (EQ (top, Qunbound))
4081 coords[1] = CW_USEDEFAULT;
4082 else
4083 coords[1] = XINT (top);
4072 4084
4073 if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW, (WPARAM)f, 0)) 4085 if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW,
4086 (WPARAM)f, (LPARAM)coords))
4074 emacs_abort (); 4087 emacs_abort ();
4075 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); 4088 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
4076} 4089}