Mercurial > hg > xemacs-beta
comparison src/frame-msw.c @ 294:4b85ae5eabfb r21-0b45
Import from CVS: tag r21-0b45
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:38:01 +0200 |
parents | c9fe270a4101 |
children | 70ad99077275 |
comparison
equal
deleted
inserted
replaced
293:403535bfea94 | 294:4b85ae5eabfb |
---|---|
53 | 53 |
54 /* Default popup size, in characters */ | 54 /* Default popup size, in characters */ |
55 #define POPUP_WIDTH 30 | 55 #define POPUP_WIDTH 30 |
56 #define POPUP_HEIGHT 10 | 56 #define POPUP_HEIGHT 10 |
57 | 57 |
58 /* Default popup size, in characters */ | |
59 #define DEFAULT_FRAME_WIDTH 80 | |
60 #define DEFAULT_FRAME_HEIGHT 35 | |
61 | |
58 #ifdef HAVE_MENUBARS | 62 #ifdef HAVE_MENUBARS |
59 #define ADJR_MENUFLAG TRUE | 63 #define ADJR_MENUFLAG TRUE |
60 #else | 64 #else |
61 #define ADJR_MENUFLAG FALSE | 65 #define ADJR_MENUFLAG FALSE |
62 #endif | 66 #endif |
63 | 67 |
64 /* Default properties to use when creating frames. */ | 68 /* Default properties to use when creating frames. */ |
65 Lisp_Object Vdefault_mswindows_frame_plist; | 69 Lisp_Object Vdefault_mswindows_frame_plist; |
70 Lisp_Object Vmswindows_use_system_frame_size_defaults; | |
66 | 71 |
67 /* Lisp_Object Qname, Qheight, Qwidth, Qinitially_unmapped, Qpopup, Qtop, Qleft; */ | 72 /* Lisp_Object Qname, Qheight, Qwidth, Qinitially_unmapped, Qpopup, Qtop, Qleft; */ |
68 Lisp_Object Qinitially_unmapped, Qpopup; | 73 Lisp_Object Qinitially_unmapped, Qpopup; |
69 | 74 |
70 /* This does not need to be GC protected, as it holds a | 75 /* This does not need to be GC protected, as it holds a |
71 frame Lisp_Object already protected by Fmake_frame */ | 76 frame Lisp_Object already protected by Fmake_frame */ |
72 Lisp_Object Vmswindows_frame_being_created; | 77 Lisp_Object Vmswindows_frame_being_created; |
73 | |
74 /* Geometry, in characters, as specified by proplist during frame | |
75 creation. Memebers are set to -1 for unspecified */ | |
76 XEMACS_RECT_WH mswindows_frame_target_rect; | |
77 | 78 |
78 static void | 79 static void |
79 mswindows_init_frame_1 (struct frame *f, Lisp_Object props) | 80 mswindows_init_frame_1 (struct frame *f, Lisp_Object props) |
80 { | 81 { |
81 Lisp_Object initially_unmapped; | 82 Lisp_Object initially_unmapped; |
109 | 110 |
110 height = Fplist_get (props, Qheight, Qnil); | 111 height = Fplist_get (props, Qheight, Qnil); |
111 if (!NILP (height)) | 112 if (!NILP (height)) |
112 CHECK_INT (height); | 113 CHECK_INT (height); |
113 | 114 |
114 mswindows_frame_target_rect.left = NILP (left) ? -1 : abs (XINT (left)); | |
115 mswindows_frame_target_rect.top = NILP (top) ? -1 : abs (XINT (top)); | |
116 mswindows_frame_target_rect.width = NILP (width) ? -1 : abs (XINT (width)); | |
117 mswindows_frame_target_rect.height = NILP (height) ? -1 : abs (XINT (height)); | |
118 | |
119 f->frame_data = xnew_and_zero (struct mswindows_frame); | 115 f->frame_data = xnew_and_zero (struct mswindows_frame); |
120 | 116 FRAME_MSWINDOWS_TARGET_RECT (f) = xnew_and_zero (XEMACS_RECT_WH); |
117 | |
118 FRAME_MSWINDOWS_TARGET_RECT (f)->left = NILP (left) ? -1 : abs (XINT (left)); | |
119 FRAME_MSWINDOWS_TARGET_RECT (f)->top = NILP (top) ? -1 : abs (XINT (top)); | |
120 FRAME_MSWINDOWS_TARGET_RECT (f)->width = NILP (width) ? -1 : | |
121 abs (XINT (width)); | |
122 FRAME_MSWINDOWS_TARGET_RECT (f)->height = NILP (height) ? -1 : | |
123 abs (XINT (height)); | |
124 | |
121 /* Misc frame stuff */ | 125 /* Misc frame stuff */ |
122 FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0; | 126 FRAME_MSWINDOWS_DATA(f)->button2_need_lbutton = 0; |
123 FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0; | 127 FRAME_MSWINDOWS_DATA(f)->button2_need_rbutton = 0; |
124 FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0; | 128 FRAME_MSWINDOWS_DATA(f)->button2_is_down = 0; |
125 FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0; | 129 FRAME_MSWINDOWS_DATA(f)->ignore_next_lbutton_up = 0; |
148 { | 152 { |
149 style |= WS_VISIBLE; | 153 style |= WS_VISIBLE; |
150 first_frame = 0; | 154 first_frame = 0; |
151 } | 155 } |
152 | 156 |
153 /* We always create am overlapped frame with default size, | |
154 and later adjust only requested geometry parameters. */ | |
155 rect_default.left = rect_default.top = CW_USEDEFAULT; | 157 rect_default.left = rect_default.top = CW_USEDEFAULT; |
156 rect_default.width = rect_default.height = CW_USEDEFAULT; | 158 rect_default.width = rect_default.height = CW_USEDEFAULT; |
157 } | 159 } |
158 else | 160 else |
159 { | 161 { |
201 FRAME_MSWINDOWS_DC(f) = GetDC (hwnd); | 203 FRAME_MSWINDOWS_DC(f) = GetDC (hwnd); |
202 FRAME_MSWINDOWS_CDC(f) = CreateCompatibleDC (FRAME_MSWINDOWS_CDC(f)); | 204 FRAME_MSWINDOWS_CDC(f) = CreateCompatibleDC (FRAME_MSWINDOWS_CDC(f)); |
203 SetTextAlign (FRAME_MSWINDOWS_DC(f), TA_BASELINE | TA_LEFT | TA_NOUPDATECP); | 205 SetTextAlign (FRAME_MSWINDOWS_DC(f), TA_BASELINE | TA_LEFT | TA_NOUPDATECP); |
204 } | 206 } |
205 | 207 |
206 #if 0 /* #### unused */ | |
207 static void | 208 static void |
208 mswindows_init_frame_2 (struct frame *f, Lisp_Object props) | 209 mswindows_init_frame_2 (struct frame *f, Lisp_Object props) |
209 { | 210 { |
210 } | 211 if (NILP (Vmswindows_use_system_frame_size_defaults)) |
211 #endif | 212 { |
213 /* I don't think anything can set the frame size before this | |
214 since we don't have X resources. This may change if we look | |
215 at the registry. Even so these values can get overridden | |
216 later.*/ | |
217 XEMACS_RECT_WH dest = { -1, -1, DEFAULT_FRAME_WIDTH, | |
218 DEFAULT_FRAME_HEIGHT }; | |
219 mswindows_size_frame_internal (f, &dest); | |
220 } | |
221 } | |
212 | 222 |
213 /* Called after frame's properties are set */ | 223 /* Called after frame's properties are set */ |
214 static void | 224 static void |
215 mswindows_init_frame_3 (struct frame *f) | 225 mswindows_init_frame_3 (struct frame *f) |
216 { | 226 { |
262 } | 272 } |
263 f->frame_data = 0; | 273 f->frame_data = 0; |
264 } | 274 } |
265 | 275 |
266 static void | 276 static void |
267 mswindows_set_frame_size (struct frame *f, int cols, int rows) | 277 mswindows_set_frame_size (struct frame *f, int width, int height) |
268 { | 278 { |
269 RECT rect; | 279 RECT rect; |
270 rect.left = rect.top = 0; | 280 rect.left = rect.top = 0; |
271 rect.right = cols; | 281 rect.right = width; |
272 rect.bottom = rows; | 282 rect.bottom = height; |
273 | 283 |
274 AdjustWindowRectEx (&rect, | 284 AdjustWindowRectEx (&rect, |
275 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE), | 285 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE), |
276 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL, | 286 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL, |
277 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE)); | 287 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE)); |
503 } | 513 } |
504 | 514 |
505 static void | 515 static void |
506 mswindows_set_frame_properties (struct frame *f, Lisp_Object plist) | 516 mswindows_set_frame_properties (struct frame *f, Lisp_Object plist) |
507 { | 517 { |
508 int x=0, y=0; | 518 int x=-1, y=-1; |
509 int width = 0, height = 0; | 519 int width = -1, height = -1; |
510 BOOL width_specified_p = FALSE; | 520 BOOL width_specified_p = FALSE; |
511 BOOL height_specified_p = FALSE; | 521 BOOL height_specified_p = FALSE; |
512 BOOL x_specified_p = FALSE; | 522 BOOL x_specified_p = FALSE; |
513 BOOL y_specified_p = FALSE; | 523 BOOL y_specified_p = FALSE; |
514 Lisp_Object tail; | 524 Lisp_Object tail; |
564 } | 574 } |
565 | 575 |
566 /* Now we've extracted the properties, apply them. | 576 /* Now we've extracted the properties, apply them. |
567 Do not apply geometric properties during frame creation. This | 577 Do not apply geometric properties during frame creation. This |
568 is excessive anyways, and this loses becuase WM_SIZE has not | 578 is excessive anyways, and this loses becuase WM_SIZE has not |
569 been sent yet, so frame width and height fields are not initialized | 579 been sent yet, so frame width and height fields are not initialized. |
570 */ | 580 |
571 if (f->init_finished | 581 unfortunately WM_SIZE loses as well since the resize is only |
572 && (width_specified_p || height_specified_p || x_specified_p || y_specified_p)) | 582 applied once and the first time WM_SIZE is applied not everything |
573 { | 583 is initialised in the frame (toolbars for instance). enabling |
574 Lisp_Object frame = Qnil; | 584 this always makes no visible difference and fixes a whole host of |
575 RECT rect; | 585 bugs (and is more consistent with X) so I am going to reenable it. |
576 int pixel_width, pixel_height; | 586 --andyp */ |
577 XSETFRAME (frame, f); | 587 if ( FRAME_PIXWIDTH (f) && FRAME_PIXHEIGHT (f) |
578 | 588 && (width_specified_p || height_specified_p || x_specified_p || y_specified_p)) |
579 char_to_real_pixel_size (f, width, height, &pixel_width, &pixel_height); | 589 { |
580 if (!width_specified_p) | 590 XEMACS_RECT_WH dest = { x, y, width, height }; |
581 pixel_width = FRAME_PIXWIDTH (f); | 591 |
582 if (!height_specified_p) | 592 mswindows_size_frame_internal (f, &dest); |
583 pixel_height = FRAME_PIXHEIGHT (f); | 593 } |
584 | 594 } |
585 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect); | 595 |
586 if (!x_specified_p) | 596 void mswindows_size_frame_internal (struct frame* f, XEMACS_RECT_WH* dest) |
587 x = rect.left; | 597 { |
588 if (!y_specified_p) | 598 RECT rect; |
589 y = rect.top; | 599 int pixel_width, pixel_height; |
590 | 600 int size_p = (dest->width >=0 || dest->height >=0); |
591 rect.left = rect.top = 0; | 601 int move_p = (dest->top >=0 || dest->left >=0); |
592 rect.right = pixel_width; | 602 |
593 rect.bottom = pixel_height; | 603 char_to_real_pixel_size (f, dest->width, dest->height, &pixel_width, &pixel_height); |
594 AdjustWindowRectEx (&rect, | 604 |
595 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE), | 605 if (dest->width < 0) |
596 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL, | 606 pixel_width = FRAME_PIXWIDTH (f); |
597 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE)); | 607 if (dest->height < 0) |
598 | 608 pixel_height = FRAME_PIXHEIGHT (f); |
599 | 609 |
600 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f)) || IsZoomed (FRAME_MSWINDOWS_HANDLE(f))) | 610 GetWindowRect (FRAME_MSWINDOWS_HANDLE(f), &rect); |
601 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE); | 611 if (dest->left < 0) |
602 | 612 dest->left = rect.left; |
603 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL, | 613 if (dest->top < 0) |
604 x, y, rect.right - rect.left, rect.bottom - rect.top, | 614 dest->top = rect.top; |
605 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | 615 |
606 | ((width_specified_p || height_specified_p) ? 0 : SWP_NOSIZE) | 616 rect.left = rect.top = 0; |
607 | ((x_specified_p || y_specified_p) ? 0 : SWP_NOMOVE)); | 617 rect.right = pixel_width; |
608 } | 618 rect.bottom = pixel_height; |
619 | |
620 AdjustWindowRectEx (&rect, | |
621 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_STYLE), | |
622 GetMenu (FRAME_MSWINDOWS_HANDLE(f)) != NULL, | |
623 GetWindowLong (FRAME_MSWINDOWS_HANDLE(f), GWL_EXSTYLE)); | |
624 | |
625 if (IsIconic (FRAME_MSWINDOWS_HANDLE(f)) | |
626 || IsZoomed (FRAME_MSWINDOWS_HANDLE(f))) | |
627 ShowWindow (FRAME_MSWINDOWS_HANDLE(f), SW_RESTORE); | |
628 | |
629 SetWindowPos (FRAME_MSWINDOWS_HANDLE(f), NULL, | |
630 dest->left, dest->top, rect.right - rect.left, rect.bottom - rect.top, | |
631 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING | |
632 | (size_p ? 0 : SWP_NOSIZE) | |
633 | (move_p ? 0 : SWP_NOMOVE)); | |
609 } | 634 } |
610 | 635 |
611 static Lisp_Object | 636 static Lisp_Object |
612 mswindows_get_frame_parent (struct frame *f) | 637 mswindows_get_frame_parent (struct frame *f) |
613 { | 638 { |
639 void | 664 void |
640 console_type_create_frame_mswindows (void) | 665 console_type_create_frame_mswindows (void) |
641 { | 666 { |
642 /* frame methods */ | 667 /* frame methods */ |
643 CONSOLE_HAS_METHOD (mswindows, init_frame_1); | 668 CONSOLE_HAS_METHOD (mswindows, init_frame_1); |
644 /* CONSOLE_HAS_METHOD (mswindows, init_frame_2); */ | 669 CONSOLE_HAS_METHOD (mswindows, init_frame_2); |
645 CONSOLE_HAS_METHOD (mswindows, init_frame_3); | 670 CONSOLE_HAS_METHOD (mswindows, init_frame_3); |
646 CONSOLE_HAS_METHOD (mswindows, after_init_frame); | 671 CONSOLE_HAS_METHOD (mswindows, after_init_frame); |
647 CONSOLE_HAS_METHOD (mswindows, mark_frame); | 672 CONSOLE_HAS_METHOD (mswindows, mark_frame); |
648 CONSOLE_HAS_METHOD (mswindows, focus_on_frame); | 673 CONSOLE_HAS_METHOD (mswindows, focus_on_frame); |
649 CONSOLE_HAS_METHOD (mswindows, delete_frame); | 674 CONSOLE_HAS_METHOD (mswindows, delete_frame); |
681 vars_of_frame_mswindows (void) | 706 vars_of_frame_mswindows (void) |
682 { | 707 { |
683 /* Needn't staticpro -- see comment above. */ | 708 /* Needn't staticpro -- see comment above. */ |
684 Vmswindows_frame_being_created = Qnil; | 709 Vmswindows_frame_being_created = Qnil; |
685 | 710 |
711 DEFVAR_LISP ("mswindows-use-system-frame-size-defaults", &Vmswindows_use_system_frame_size_defaults /* | |
712 Controls whether to use system or XEmacs defaults for frame size. | |
713 If nil then reasonable defaults are used for intial frame sizes. If t | |
714 then the system will choose default sizes for the frame. | |
715 */ ); | |
716 Vmswindows_use_system_frame_size_defaults = Qnil; | |
717 | |
686 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /* | 718 DEFVAR_LISP ("default-mswindows-frame-plist", &Vdefault_mswindows_frame_plist /* |
687 Plist of default frame-creation properties for mswindows frames. | 719 Plist of default frame-creation properties for mswindows frames. |
688 These override what is specified in `default-frame-plist', but are | 720 These override what is specified in `default-frame-plist', but are |
689 overridden by the arguments to the particular call to `make-frame'. | 721 overridden by the arguments to the particular call to `make-frame'. |
690 | 722 |