Mercurial > emacs
comparison src/xterm.c @ 103665:340c701162a6
* emacs.c (USAGE3, standard_args): Add -mm and --maximized.
* frame.c: Qmaximized is new.
(x_set_frame_parameters): Do not handle fullscreen specially.
Only set width and height if explicitly set.
(x_set_fullscreen): Handle Qmaximized.
(x_set_font, x_figure_window_size): Do not handle fullscreen specially.
(syms_of_frame): Initialize Qmaximized.
* frame.h (fullscreen_type): Add FULLSCREEN_MAXIMIZED. Declare
Qfullwidth, Qfullheight, Qfullboth, Qmaximized.
* xterm.c (handle_one_xevent): Remove call to x_check_fullscreen
for Expose event. Add call to x_check_fullscreen for MapNotify event.
Remove all code w.r.t. fullscreen from ConfigureNotify event. Do not
set gravity to NorthWestGravity when USE_GTK.
(set_wm_state): New function.
(do_ewmh_fullscreen): Use set_wm_state. Also handle FULLSCREEN_MAXIMIZED.
(x_handle_net_wm_state): Handle FULLSCREEN_MAXIMIZED.
(x_check_fullscreen): Simplify so we only handle EMWH type of fullscreen
or the case when no window manager is running. That means remove calls
to x_real_positions and x_fullscreen_adjust.
* gtkutil.c (flush_and_sync, x_wm_size_hint_off): Remove.
(xg_frame_set_char_size): Remove calls to x_wm_size_hint_off and
flush_and_sync.
(xg_height_changed): New function.
(xg_create_frame_widgets): Remove call to gtk_widget_set_size_request
and gtk_window_set_policy. Set frame gravity after parsing the geometry
string.
(xg_update_frame_menubar, free_frame_menubar)
(xg_tool_bar_detach_callback, xg_tool_bar_attach_callback)
(update_frame_tool_bar, free_frame_tool_bar): Call xg_height_changed.
Remove calls to xg_frame_set_char_size.
* startup.el (command-line-x-option-alist): Add -mm and --maximized.
* NEWS: Mention maximized.
* frames.texi (Size Parameters): Mention maximized for fullscreen.
* xresources.texi (Table of Resources): Mention maximized for
fullscreen.
* cmdargs.texi (Window Size X): -mm/--maximized is new.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Wed, 01 Jul 2009 14:02:27 +0000 |
parents | 64011e3b89f5 |
children | 1867be80e595 |
comparison
equal
deleted
inserted
replaced
103664:fa336161482c | 103665:340c701162a6 |
---|---|
6057 | 6057 |
6058 case Expose: | 6058 case Expose: |
6059 f = x_window_to_frame (dpyinfo, event.xexpose.window); | 6059 f = x_window_to_frame (dpyinfo, event.xexpose.window); |
6060 if (f) | 6060 if (f) |
6061 { | 6061 { |
6062 x_check_fullscreen (f); | |
6063 | |
6064 #ifdef USE_GTK | 6062 #ifdef USE_GTK |
6065 /* This seems to be needed for GTK 2.6. */ | 6063 /* This seems to be needed for GTK 2.6. */ |
6066 x_clear_area (event.xexpose.display, | 6064 x_clear_area (event.xexpose.display, |
6067 event.xexpose.window, | 6065 event.xexpose.window, |
6068 event.xexpose.x, event.xexpose.y, | 6066 event.xexpose.x, event.xexpose.y, |
6203 && ! NILP (XCDR (Vframe_list))) | 6201 && ! NILP (XCDR (Vframe_list))) |
6204 /* Force a redisplay sooner or later | 6202 /* Force a redisplay sooner or later |
6205 to update the frame titles | 6203 to update the frame titles |
6206 in case this is the second frame. */ | 6204 in case this is the second frame. */ |
6207 record_asynch_buffer_change (); | 6205 record_asynch_buffer_change (); |
6206 | |
6207 /* Check if fullscreen was specified before we where mapped. */ | |
6208 x_check_fullscreen (f); | |
6208 } | 6209 } |
6209 goto OTHER; | 6210 goto OTHER; |
6210 | 6211 |
6211 case KeyPress: | 6212 case KeyPress: |
6212 | 6213 |
6703 #endif | 6704 #endif |
6704 if (f) | 6705 if (f) |
6705 { | 6706 { |
6706 #ifndef USE_X_TOOLKIT | 6707 #ifndef USE_X_TOOLKIT |
6707 #ifndef USE_GTK | 6708 #ifndef USE_GTK |
6708 /* If there is a pending resize for fullscreen, don't | |
6709 do this one, the right one will come later. | |
6710 The toolkit version doesn't seem to need this, but we | |
6711 need to reset it below. */ | |
6712 int dont_resize | |
6713 = ((f->want_fullscreen & FULLSCREEN_WAIT) | |
6714 && f->new_text_cols != 0); | |
6715 int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, event.xconfigure.height); | 6709 int rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, event.xconfigure.height); |
6716 int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, event.xconfigure.width); | 6710 int columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, event.xconfigure.width); |
6717 | |
6718 if (dont_resize) | |
6719 goto OTHER; | |
6720 | 6711 |
6721 /* In the toolkit version, change_frame_size | 6712 /* In the toolkit version, change_frame_size |
6722 is called by the code that handles resizing | 6713 is called by the code that handles resizing |
6723 of the EmacsFrame widget. */ | 6714 of the EmacsFrame widget. */ |
6724 | 6715 |
6746 if (FRAME_GTK_OUTER_WIDGET (f) | 6737 if (FRAME_GTK_OUTER_WIDGET (f) |
6747 && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f))) | 6738 && GTK_WIDGET_MAPPED (FRAME_GTK_OUTER_WIDGET (f))) |
6748 #endif | 6739 #endif |
6749 { | 6740 { |
6750 x_real_positions (f, &f->left_pos, &f->top_pos); | 6741 x_real_positions (f, &f->left_pos, &f->top_pos); |
6751 | |
6752 if (f->want_fullscreen & FULLSCREEN_WAIT) | |
6753 f->want_fullscreen &= ~(FULLSCREEN_WAIT|FULLSCREEN_BOTH); | |
6754 } | 6742 } |
6755 | 6743 |
6756 #ifdef HAVE_X_I18N | 6744 #ifdef HAVE_X_I18N |
6757 if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) | 6745 if (FRAME_XIC (f) && (FRAME_XIC_STYLE (f) & XIMStatusArea)) |
6758 xic_set_statusarea (f); | 6746 xic_set_statusarea (f); |
6759 #endif | 6747 #endif |
6760 | 6748 |
6749 #ifndef USE_GTK | |
6761 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) | 6750 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) |
6762 { | 6751 { |
6763 /* Since the WM decorations come below top_pos now, | 6752 /* Since the WM decorations come below top_pos now, |
6764 we must put them below top_pos in the future. */ | 6753 we must put them below top_pos in the future. */ |
6765 f->win_gravity = NorthWestGravity; | 6754 f->win_gravity = NorthWestGravity; |
6766 x_wm_set_size_hint (f, (long) 0, 0); | 6755 x_wm_set_size_hint (f, (long) 0, 0); |
6767 } | 6756 } |
6757 #endif | |
6768 } | 6758 } |
6769 goto OTHER; | 6759 goto OTHER; |
6770 | 6760 |
6771 case ButtonRelease: | 6761 case ButtonRelease: |
6772 case ButtonPress: | 6762 case ButtonPress: |
8442 UNBLOCK_INPUT; | 8432 UNBLOCK_INPUT; |
8443 | 8433 |
8444 return rc; | 8434 return rc; |
8445 } | 8435 } |
8446 | 8436 |
8437 static void | |
8438 set_wm_state (frame, add, what, what2) | |
8439 Lisp_Object frame; | |
8440 int add; | |
8441 const char *what; | |
8442 const char *what2; | |
8443 { | |
8444 const char *atom = "_NET_WM_STATE"; | |
8445 Fx_send_client_event (frame, make_number (0), frame, | |
8446 make_unibyte_string (atom, strlen (atom)), | |
8447 make_number (32), | |
8448 /* 1 = add, 0 = remove */ | |
8449 Fcons | |
8450 (make_number (add ? 1 : 0), | |
8451 Fcons | |
8452 (make_unibyte_string (what, strlen (what)), | |
8453 what2 != 0 | |
8454 ? Fcons (make_unibyte_string (what2, strlen (what2)), | |
8455 Qnil) | |
8456 : Qnil))); | |
8457 } | |
8458 | |
8447 /* Do fullscreen as specified in extended window manager hints */ | 8459 /* Do fullscreen as specified in extended window manager hints */ |
8448 | 8460 |
8449 static int | 8461 static int |
8450 do_ewmh_fullscreen (f) | 8462 do_ewmh_fullscreen (f) |
8451 struct frame *f; | 8463 struct frame *f; |
8458 have_net_atom = wm_supports (f, "_NET_WM_STATE_FULLSCREEN"); | 8470 have_net_atom = wm_supports (f, "_NET_WM_STATE_FULLSCREEN"); |
8459 | 8471 |
8460 if (have_net_atom) | 8472 if (have_net_atom) |
8461 { | 8473 { |
8462 Lisp_Object frame; | 8474 Lisp_Object frame; |
8463 const char *atom = "_NET_WM_STATE"; | |
8464 const char *fs = "_NET_WM_STATE_FULLSCREEN"; | 8475 const char *fs = "_NET_WM_STATE_FULLSCREEN"; |
8465 const char *fw = "_NET_WM_STATE_MAXIMIZED_HORZ"; | 8476 const char *fw = "_NET_WM_STATE_MAXIMIZED_HORZ"; |
8466 const char *fh = "_NET_WM_STATE_MAXIMIZED_VERT"; | 8477 const char *fh = "_NET_WM_STATE_MAXIMIZED_VERT"; |
8467 const char *what = NULL; | |
8468 | 8478 |
8469 XSETFRAME (frame, f); | 8479 XSETFRAME (frame, f); |
8470 | 8480 |
8481 set_wm_state (frame, 0, fs, NULL); | |
8482 set_wm_state (frame, 0, fh, NULL); | |
8483 set_wm_state (frame, 0, fw, NULL); | |
8484 | |
8471 /* If there are _NET_ atoms we assume we have extended window manager | 8485 /* If there are _NET_ atoms we assume we have extended window manager |
8472 hints. */ | 8486 hints. */ |
8473 switch (f->want_fullscreen) | 8487 switch (f->want_fullscreen) |
8474 { | 8488 { |
8475 case FULLSCREEN_BOTH: | 8489 case FULLSCREEN_BOTH: |
8476 what = fs; | 8490 set_wm_state (frame, 1, fs, NULL); |
8477 break; | 8491 break; |
8478 case FULLSCREEN_WIDTH: | 8492 case FULLSCREEN_WIDTH: |
8479 what = fw; | 8493 set_wm_state (frame, 1, fw, NULL); |
8480 break; | 8494 break; |
8481 case FULLSCREEN_HEIGHT: | 8495 case FULLSCREEN_HEIGHT: |
8482 what = fh; | 8496 set_wm_state (frame, 1, fh, NULL); |
8497 break; | |
8498 case FULLSCREEN_MAXIMIZED: | |
8499 set_wm_state (frame, 1, fw, fh); | |
8483 break; | 8500 break; |
8484 } | 8501 } |
8485 | 8502 |
8486 if (what != NULL && !wm_supports (f, what)) return 0; | |
8487 | |
8488 | |
8489 Fx_send_client_event (frame, make_number (0), frame, | |
8490 make_unibyte_string (atom, strlen (atom)), | |
8491 make_number (32), | |
8492 Fcons (make_number (0), /* Remove */ | |
8493 Fcons | |
8494 (make_unibyte_string (fs, | |
8495 strlen (fs)), | |
8496 Qnil))); | |
8497 Fx_send_client_event (frame, make_number (0), frame, | |
8498 make_unibyte_string (atom, strlen (atom)), | |
8499 make_number (32), | |
8500 Fcons (make_number (0), /* Remove */ | |
8501 Fcons | |
8502 (make_unibyte_string (fh, | |
8503 strlen (fh)), | |
8504 Qnil))); | |
8505 Fx_send_client_event (frame, make_number (0), frame, | |
8506 make_unibyte_string (atom, strlen (atom)), | |
8507 make_number (32), | |
8508 Fcons (make_number (0), /* Remove */ | |
8509 Fcons | |
8510 (make_unibyte_string (fw, | |
8511 strlen (fw)), | |
8512 Qnil))); | |
8513 f->want_fullscreen = FULLSCREEN_NONE; | 8503 f->want_fullscreen = FULLSCREEN_NONE; |
8514 if (what != NULL) | 8504 |
8515 Fx_send_client_event (frame, make_number (0), frame, | |
8516 make_unibyte_string (atom, strlen (atom)), | |
8517 make_number (32), | |
8518 Fcons (make_number (1), /* Add */ | |
8519 Fcons | |
8520 (make_unibyte_string (what, | |
8521 strlen (what)), | |
8522 Qnil))); | |
8523 } | 8505 } |
8524 | 8506 |
8525 return have_net_atom; | 8507 return have_net_atom; |
8526 } | 8508 } |
8527 | 8509 |
8530 FRAME_PTR f; | 8512 FRAME_PTR f; |
8531 { | 8513 { |
8532 if (f->async_visible) | 8514 if (f->async_visible) |
8533 { | 8515 { |
8534 BLOCK_INPUT; | 8516 BLOCK_INPUT; |
8535 do_ewmh_fullscreen (f); | 8517 x_check_fullscreen (f); |
8536 x_sync (f); | 8518 x_sync (f); |
8537 UNBLOCK_INPUT; | 8519 UNBLOCK_INPUT; |
8538 } | 8520 } |
8539 } | 8521 } |
8540 | 8522 |
8541 | 8523 |
8542 extern Lisp_Object Qfullwidth, Qfullheight, Qfullboth; | |
8543 static void | 8524 static void |
8544 x_handle_net_wm_state (f, event) | 8525 x_handle_net_wm_state (f, event) |
8545 struct frame *f; | 8526 struct frame *f; |
8546 XPropertyEvent *event; | 8527 XPropertyEvent *event; |
8547 { | 8528 { |
8548 Atom actual_type; | 8529 Atom actual_type; |
8549 unsigned long actual_size, bytes_remaining; | 8530 unsigned long actual_size, bytes_remaining; |
8550 int i, rc, actual_format, value = 0; | 8531 int i, rc, actual_format, value = FULLSCREEN_NONE; |
8551 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | 8532 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
8552 long max_len = 65536; | 8533 long max_len = 65536; |
8553 Display *dpy = FRAME_X_DISPLAY (f); | 8534 Display *dpy = FRAME_X_DISPLAY (f); |
8554 unsigned char *tmp_data = NULL; | 8535 unsigned char *tmp_data = NULL; |
8555 Atom target_type = XA_ATOM; | 8536 Atom target_type = XA_ATOM; |
8573 x_uncatch_errors (); | 8554 x_uncatch_errors (); |
8574 | 8555 |
8575 for (i = 0; i < actual_size; ++i) | 8556 for (i = 0; i < actual_size; ++i) |
8576 { | 8557 { |
8577 Atom a = ((Atom*)tmp_data)[i]; | 8558 Atom a = ((Atom*)tmp_data)[i]; |
8578 if (a == dpyinfo->Xatom_net_wm_state_maximized_horz) | 8559 if (a == dpyinfo->Xatom_net_wm_state_maximized_horz) |
8579 value |= FULLSCREEN_WIDTH; | 8560 { |
8561 if (value == FULLSCREEN_HEIGHT) | |
8562 value = FULLSCREEN_MAXIMIZED; | |
8563 else | |
8564 value = FULLSCREEN_WIDTH; | |
8565 } | |
8580 else if (a == dpyinfo->Xatom_net_wm_state_maximized_vert) | 8566 else if (a == dpyinfo->Xatom_net_wm_state_maximized_vert) |
8581 value |= FULLSCREEN_HEIGHT; | 8567 { |
8568 if (value == FULLSCREEN_WIDTH) | |
8569 value = FULLSCREEN_MAXIMIZED; | |
8570 else | |
8571 value = FULLSCREEN_HEIGHT; | |
8572 } | |
8582 else if (a == dpyinfo->Xatom_net_wm_state_fullscreen_atom) | 8573 else if (a == dpyinfo->Xatom_net_wm_state_fullscreen_atom) |
8583 value |= FULLSCREEN_BOTH; | 8574 value = FULLSCREEN_BOTH; |
8584 } | 8575 } |
8585 | 8576 |
8586 lval = Qnil; | 8577 lval = Qnil; |
8587 switch (value) | 8578 switch (value) |
8588 { | 8579 { |
8593 lval = Qfullheight; | 8584 lval = Qfullheight; |
8594 break; | 8585 break; |
8595 case FULLSCREEN_BOTH: | 8586 case FULLSCREEN_BOTH: |
8596 lval = Qfullboth; | 8587 lval = Qfullboth; |
8597 break; | 8588 break; |
8589 case FULLSCREEN_MAXIMIZED: | |
8590 lval = Qmaximized; | |
8591 break; | |
8598 } | 8592 } |
8599 | 8593 |
8600 store_frame_param (f, Qfullscreen, lval); | 8594 store_frame_param (f, Qfullscreen, lval); |
8601 | 8595 |
8602 if (tmp_data) XFree (tmp_data); | 8596 if (tmp_data) XFree (tmp_data); |
8607 If so needed, resize the frame. */ | 8601 If so needed, resize the frame. */ |
8608 static void | 8602 static void |
8609 x_check_fullscreen (f) | 8603 x_check_fullscreen (f) |
8610 struct frame *f; | 8604 struct frame *f; |
8611 { | 8605 { |
8612 if (f->want_fullscreen & FULLSCREEN_BOTH) | 8606 if (do_ewmh_fullscreen (f)) |
8613 { | 8607 return; |
8614 int width, height, ign; | 8608 |
8615 | 8609 if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) |
8616 if (do_ewmh_fullscreen (f)) | 8610 return; // Only fullscreen without WM or with EWM hints (above). |
8617 return; | 8611 |
8618 | 8612 if (f->want_fullscreen != FULLSCREEN_NONE) |
8619 x_real_positions (f, &f->left_pos, &f->top_pos); | 8613 { |
8620 | 8614 int width = FRAME_COLS (f), height = FRAME_LINES (f); |
8621 x_fullscreen_adjust (f, &width, &height, &ign, &ign); | 8615 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
8622 | 8616 |
8623 /* We do not need to move the window, it shall be taken care of | 8617 switch (f->want_fullscreen) |
8624 when setting WM manager hints. | 8618 { |
8625 If the frame is visible already, the position is checked by | 8619 /* No difference between these two when there is no WM */ |
8626 x_check_expected_move. */ | 8620 case FULLSCREEN_BOTH: |
8621 case FULLSCREEN_MAXIMIZED: | |
8622 width = x_display_pixel_width (dpyinfo); | |
8623 height = x_display_pixel_height (dpyinfo); | |
8624 break; | |
8625 case FULLSCREEN_WIDTH: | |
8626 width = x_display_pixel_width (dpyinfo); | |
8627 break; | |
8628 case FULLSCREEN_HEIGHT: | |
8629 height = x_display_pixel_height (dpyinfo); | |
8630 } | |
8631 | |
8627 if (FRAME_COLS (f) != width || FRAME_LINES (f) != height) | 8632 if (FRAME_COLS (f) != width || FRAME_LINES (f) != height) |
8628 { | 8633 { |
8629 change_frame_size (f, height, width, 0, 1, 0); | 8634 change_frame_size (f, height, width, 0, 1, 0); |
8630 SET_FRAME_GARBAGED (f); | 8635 SET_FRAME_GARBAGED (f); |
8631 cancel_mouse_face (f); | 8636 cancel_mouse_face (f); |
8632 | |
8633 /* Wait for the change of frame size to occur */ | |
8634 f->want_fullscreen |= FULLSCREEN_WAIT; | |
8635 } | 8637 } |
8636 } | 8638 } |
8637 } | 8639 } |
8638 | 8640 |
8639 /* This function is called by x_set_offset to determine whether the window | 8641 /* This function is called by x_set_offset to determine whether the window |
8656 window manager window around the frame. */ | 8658 window manager window around the frame. */ |
8657 | 8659 |
8658 x_real_positions (f, ¤t_left, ¤t_top); | 8660 x_real_positions (f, ¤t_left, ¤t_top); |
8659 | 8661 |
8660 if (current_left != expected_left || current_top != expected_top) | 8662 if (current_left != expected_left || current_top != expected_top) |
8661 { | 8663 { |
8662 /* It's a "Type A" window manager. */ | 8664 /* It's a "Type A" window manager. */ |
8663 | 8665 |
8664 int adjusted_left; | 8666 int adjusted_left; |
8665 int adjusted_top; | 8667 int adjusted_top; |
8666 | 8668 |
8675 | 8677 |
8676 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), | 8678 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), |
8677 adjusted_left, adjusted_top); | 8679 adjusted_left, adjusted_top); |
8678 | 8680 |
8679 x_sync_with_move (f, expected_left, expected_top, 0); | 8681 x_sync_with_move (f, expected_left, expected_top, 0); |
8680 } | 8682 } |
8681 else | 8683 else |
8682 /* It's a "Type B" window manager. We don't have to adjust the | 8684 /* It's a "Type B" window manager. We don't have to adjust the |
8683 frame's position. */ | 8685 frame's position. */ |
8684 | 8686 |
8685 FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_B; | 8687 FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_B; |