diff options
Diffstat (limited to 'src/xterm.c')
| -rw-r--r-- | src/xterm.c | 162 |
1 files changed, 82 insertions, 80 deletions
diff --git a/src/xterm.c b/src/xterm.c index f0b4c2e983a..32ee1596679 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -6059,8 +6059,6 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 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, |
| @@ -6205,6 +6203,9 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 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 | ||
| @@ -6705,19 +6706,9 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 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 | 6711 | ||
| 6718 | if (dont_resize) | ||
| 6719 | goto OTHER; | ||
| 6720 | |||
| 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. */ |
| @@ -6748,9 +6739,6 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 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 |
| @@ -6758,6 +6746,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 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, |
| @@ -6765,6 +6754,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit) | |||
| 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 | ||
| @@ -8444,6 +8434,28 @@ wm_supports (f, atomname) | |||
| 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 |
| @@ -8460,66 +8472,36 @@ do_ewmh_fullscreen (f) | |||
| 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; |
| @@ -8532,14 +8514,13 @@ XTfullscreen_hook (f) | |||
| 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; |
| @@ -8547,7 +8528,7 @@ x_handle_net_wm_state (f, 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); |
| @@ -8575,12 +8556,22 @@ x_handle_net_wm_state (f, event) | |||
| 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; |
| @@ -8595,6 +8586,9 @@ x_handle_net_wm_state (f, event) | |||
| 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); |
| @@ -8609,29 +8603,37 @@ 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; | ||
| 8615 | |||
| 8616 | if (do_ewmh_fullscreen (f)) | ||
| 8617 | return; | ||
| 8618 | 8608 | ||
| 8619 | x_real_positions (f, &f->left_pos, &f->top_pos); | 8609 | if (f->output_data.x->parent_desc != FRAME_X_DISPLAY_INFO (f)->root_window) |
| 8610 | return; // Only fullscreen without WM or with EWM hints (above). | ||
| 8620 | 8611 | ||
| 8621 | x_fullscreen_adjust (f, &width, &height, &ign, &ign); | 8612 | if (f->want_fullscreen != FULLSCREEN_NONE) |
| 8613 | { | ||
| 8614 | int width = FRAME_COLS (f), height = FRAME_LINES (f); | ||
| 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 | } |
| @@ -8658,7 +8660,7 @@ x_check_expected_move (f, expected_left, expected_top) | |||
| 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; |
| @@ -8677,7 +8679,7 @@ x_check_expected_move (f, expected_left, expected_top) | |||
| 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. */ |