aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorKaroly Lorentey2007-01-13 22:59:28 +0000
committerKaroly Lorentey2007-01-13 22:59:28 +0000
commit38db5c8d522cc1faa8190e77dbc932a5560e6aad (patch)
treeefe4c81d7210843bb208282461ebce12c5bd3daf /src/xterm.c
parent191ae1cf7cd2571277635b3b8e488e773ca5c9b9 (diff)
parentb4ec8cb4e66f94547e8215a1c1eb6cda3b83ca63 (diff)
downloademacs-38db5c8d522cc1faa8190e77dbc932a5560e6aad.tar.gz
emacs-38db5c8d522cc1faa8190e77dbc932a5560e6aad.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-592 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-593 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-594 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-595 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-596 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-597 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-598 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-186 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-187 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-188 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-189 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-190 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-191 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-593
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c173
1 files changed, 135 insertions, 38 deletions
diff --git a/src/xterm.c b/src/xterm.c
index e16fb852873..122d9b7c3de 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -276,6 +276,10 @@ static Lisp_Object last_mouse_scroll_bar;
276 276
277static Time last_mouse_movement_time; 277static Time last_mouse_movement_time;
278 278
279/* Time for last user interaction as returned in X events. */
280
281static Time last_user_time;
282
279/* Incremented by XTread_socket whenever it really tries to read 283/* Incremented by XTread_socket whenever it really tries to read
280 events. */ 284 events. */
281 285
@@ -5882,6 +5886,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5882 break; 5886 break;
5883 5887
5884 case SelectionNotify: 5888 case SelectionNotify:
5889 last_user_time = event.xselection.time;
5885#ifdef USE_X_TOOLKIT 5890#ifdef USE_X_TOOLKIT
5886 if (! x_window_to_frame (dpyinfo, event.xselection.requestor)) 5891 if (! x_window_to_frame (dpyinfo, event.xselection.requestor))
5887 goto OTHER; 5892 goto OTHER;
@@ -5890,6 +5895,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5890 break; 5895 break;
5891 5896
5892 case SelectionClear: /* Someone has grabbed ownership. */ 5897 case SelectionClear: /* Someone has grabbed ownership. */
5898 last_user_time = event.xselectionclear.time;
5893#ifdef USE_X_TOOLKIT 5899#ifdef USE_X_TOOLKIT
5894 if (! x_window_to_frame (dpyinfo, event.xselectionclear.window)) 5900 if (! x_window_to_frame (dpyinfo, event.xselectionclear.window))
5895 goto OTHER; 5901 goto OTHER;
@@ -5906,6 +5912,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5906 break; 5912 break;
5907 5913
5908 case SelectionRequest: /* Someone wants our selection. */ 5914 case SelectionRequest: /* Someone wants our selection. */
5915 last_user_time = event.xselectionrequest.time;
5909#ifdef USE_X_TOOLKIT 5916#ifdef USE_X_TOOLKIT
5910 if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner)) 5917 if (!x_window_to_frame (dpyinfo, event.xselectionrequest.owner))
5911 goto OTHER; 5918 goto OTHER;
@@ -5926,6 +5933,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5926 break; 5933 break;
5927 5934
5928 case PropertyNotify: 5935 case PropertyNotify:
5936 last_user_time = event.xproperty.time;
5929#if 0 /* This is plain wrong. In the case that we are waiting for a 5937#if 0 /* This is plain wrong. In the case that we are waiting for a
5930 PropertyNotify used as an ACK in incremental selection 5938 PropertyNotify used as an ACK in incremental selection
5931 transfer, the property will be on the receiver's window. */ 5939 transfer, the property will be on the receiver's window. */
@@ -5949,6 +5957,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5949 5957
5950 /* Perhaps reparented due to a WM restart. Reset this. */ 5958 /* Perhaps reparented due to a WM restart. Reset this. */
5951 FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN; 5959 FRAME_X_DISPLAY_INFO (f)->wm_type = X_WMTYPE_UNKNOWN;
5960 FRAME_X_DISPLAY_INFO (f)->net_supported_window = 0;
5952 } 5961 }
5953 goto OTHER; 5962 goto OTHER;
5954 5963
@@ -6107,6 +6116,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6107 6116
6108 case KeyPress: 6117 case KeyPress:
6109 6118
6119 last_user_time = event.xkey.time;
6110 ignore_next_mouse_click_timeout = 0; 6120 ignore_next_mouse_click_timeout = 0;
6111 6121
6112#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 6122#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
@@ -6497,6 +6507,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6497#endif 6507#endif
6498 6508
6499 case KeyRelease: 6509 case KeyRelease:
6510 last_user_time = event.xkey.time;
6500#ifdef HAVE_X_I18N 6511#ifdef HAVE_X_I18N
6501 /* Don't dispatch this event since XtDispatchEvent calls 6512 /* Don't dispatch this event since XtDispatchEvent calls
6502 XFilterEvent, and two calls in a row may freeze the 6513 XFilterEvent, and two calls in a row may freeze the
@@ -6507,6 +6518,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6507#endif 6518#endif
6508 6519
6509 case EnterNotify: 6520 case EnterNotify:
6521 last_user_time = event.xcrossing.time;
6510 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6522 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6511 6523
6512 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window); 6524 f = x_any_window_to_frame (dpyinfo, event.xcrossing.window);
@@ -6547,6 +6559,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6547 goto OTHER; 6559 goto OTHER;
6548 6560
6549 case LeaveNotify: 6561 case LeaveNotify:
6562 last_user_time = event.xcrossing.time;
6550 x_detect_focus_change (dpyinfo, &event, &inev.ie); 6563 x_detect_focus_change (dpyinfo, &event, &inev.ie);
6551 6564
6552 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window); 6565 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
@@ -6580,6 +6593,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6580 6593
6581 case MotionNotify: 6594 case MotionNotify:
6582 { 6595 {
6596 last_user_time = event.xmotion.time;
6583 previous_help_echo_string = help_echo_string; 6597 previous_help_echo_string = help_echo_string;
6584 help_echo_string = Qnil; 6598 help_echo_string = Qnil;
6585 6599
@@ -6728,6 +6742,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
6728 6742
6729 bzero (&compose_status, sizeof (compose_status)); 6743 bzero (&compose_status, sizeof (compose_status));
6730 last_mouse_glyph_frame = 0; 6744 last_mouse_glyph_frame = 0;
6745 last_user_time = event.xbutton.time;
6731 6746
6732 if (dpyinfo->grabbed 6747 if (dpyinfo->grabbed
6733 && last_mouse_frame 6748 && last_mouse_frame
@@ -8336,40 +8351,111 @@ x_set_offset (f, xoff, yoff, change_gravity)
8336 UNBLOCK_INPUT; 8351 UNBLOCK_INPUT;
8337} 8352}
8338 8353
8339/* Do fullscreen as specified in extended window manager hints */ 8354/* Return non-zero if _NET_SUPPORTING_WM_CHECK window exists and _NET_SUPPORTED
8355 on the root window for frame F contains ATOMNAME.
8356 This is how a WM check shall be done according to the Window Manager
8357 Specification/Extended Window Manager Hints at
8358 http://freedesktop.org/wiki/Standards_2fwm_2dspec. */
8359
8340static int 8360static int
8341do_ewmh_fullscreen (f) 8361wm_supports (f, atomname)
8342 struct frame *f; 8362 struct frame *f;
8363 const char *atomname;
8343{ 8364{
8344 int have_net_atom = FRAME_X_DISPLAY_INFO (f)->have_net_atoms; 8365 Atom actual_type;
8366 unsigned long actual_size, bytes_remaining;
8367 int i, rc, actual_format;
8368 Atom prop_atom;
8369 Window wmcheck_window;
8370 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
8371 Window target_window = dpyinfo->root_window;
8372 long max_len = 65536;
8373 Display *dpy = FRAME_X_DISPLAY (f);
8374 unsigned char *tmp_data = NULL;
8375 Atom target_type = XA_WINDOW;
8376 Atom want_atom;
8377
8378 BLOCK_INPUT;
8379
8380 prop_atom = XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", False);
8381
8382 x_catch_errors (dpy);
8383 rc = XGetWindowProperty (dpy, target_window,
8384 prop_atom, 0, max_len, False, target_type,
8385 &actual_type, &actual_format, &actual_size,
8386 &bytes_remaining, &tmp_data);
8387
8388 if (rc != Success || actual_type != XA_WINDOW || x_had_errors_p (dpy))
8389 {
8390 if (tmp_data) XFree (tmp_data);
8391 x_uncatch_errors ();
8392 UNBLOCK_INPUT;
8393 return 0;
8394 }
8395
8396 wmcheck_window = *(Window *) tmp_data;
8397 XFree (tmp_data);
8345 8398
8346 if (!have_net_atom) 8399 /* Check if window exists. */
8400 XSelectInput (dpy, wmcheck_window, StructureNotifyMask);
8401 x_sync (f);
8402 if (x_had_errors_p (dpy))
8347 { 8403 {
8348 int num; 8404 x_uncatch_errors ();
8349 Atom *atoms = XListProperties (FRAME_X_DISPLAY (f), 8405 UNBLOCK_INPUT;
8350 FRAME_X_DISPLAY_INFO (f)->root_window, 8406 return 0;
8351 &num); 8407 }
8352 if (atoms && num > 0) 8408
8409 if (dpyinfo->net_supported_window != wmcheck_window)
8410 {
8411 /* Window changed, reload atoms */
8412 if (dpyinfo->net_supported_atoms != NULL)
8413 XFree (dpyinfo->net_supported_atoms);
8414 dpyinfo->net_supported_atoms = NULL;
8415 dpyinfo->nr_net_supported_atoms = 0;
8416 dpyinfo->net_supported_window = 0;
8417
8418 target_type = XA_ATOM;
8419 prop_atom = XInternAtom (dpy, "_NET_SUPPORTED", False);
8420 tmp_data = NULL;
8421 rc = XGetWindowProperty (dpy, target_window,
8422 prop_atom, 0, max_len, False, target_type,
8423 &actual_type, &actual_format, &actual_size,
8424 &bytes_remaining, &tmp_data);
8425
8426 if (rc != Success || actual_type != XA_ATOM || x_had_errors_p (dpy))
8353 { 8427 {
8354 char **names = (char **) xmalloc (num * sizeof(*names)); 8428 if (tmp_data) XFree (tmp_data);
8355 if (XGetAtomNames (FRAME_X_DISPLAY (f), atoms, num, names)) 8429 x_uncatch_errors ();
8356 { 8430 UNBLOCK_INPUT;
8357 int i; 8431 return 0;
8358 for (i = 0; i < num; ++i)
8359 {
8360 if (!have_net_atom)
8361 have_net_atom = strncmp (names[i], "_NET_", 5) == 0;
8362 XFree (names[i]);
8363 }
8364 }
8365 xfree (names);
8366 } 8432 }
8367 if (atoms)
8368 XFree (atoms);
8369 8433
8370 FRAME_X_DISPLAY_INFO (f)->have_net_atoms = have_net_atom; 8434 dpyinfo->net_supported_atoms = (Atom *)tmp_data;
8435 dpyinfo->nr_net_supported_atoms = actual_size;
8436 dpyinfo->net_supported_window = wmcheck_window;
8371 } 8437 }
8372 8438
8439 rc = 0;
8440 want_atom = XInternAtom (dpy, atomname, False);
8441
8442 for (i = 0; rc == 0 && i < dpyinfo->nr_net_supported_atoms; ++i)
8443 rc = dpyinfo->net_supported_atoms[i] == want_atom;
8444
8445 x_uncatch_errors ();
8446 UNBLOCK_INPUT;
8447
8448 return rc;
8449}
8450
8451/* Do fullscreen as specified in extended window manager hints */
8452
8453static int
8454do_ewmh_fullscreen (f)
8455 struct frame *f;
8456{
8457 int have_net_atom = wm_supports (f, "_NET_WM_STATE");
8458
8373 if (have_net_atom) 8459 if (have_net_atom)
8374 { 8460 {
8375 Lisp_Object frame; 8461 Lisp_Object frame;
@@ -8396,6 +8482,9 @@ do_ewmh_fullscreen (f)
8396 break; 8482 break;
8397 } 8483 }
8398 8484
8485 if (!wm_supports (f, what)) return 0;
8486
8487
8399 Fx_send_client_event (frame, make_number (0), frame, 8488 Fx_send_client_event (frame, make_number (0), frame,
8400 make_unibyte_string (atom, strlen (atom)), 8489 make_unibyte_string (atom, strlen (atom)),
8401 make_number (32), 8490 make_number (32),
@@ -8796,23 +8885,27 @@ XTframe_raise_lower (f, raise_flag)
8796 /* The following code is needed for `raise-frame' to work on 8885 /* The following code is needed for `raise-frame' to work on
8797 some versions of metacity; see Window Manager 8886 some versions of metacity; see Window Manager
8798 Specification/Extended Window Manager Hints at 8887 Specification/Extended Window Manager Hints at
8799 http://freedesktop.org/wiki/Standards_2fwm_2dspec 8888 http://freedesktop.org/wiki/Standards_2fwm_2dspec */
8800 8889
8801 However, on other versions (metacity 2.17.2-1.fc7), it 8890#if 0
8891 /* However, on other versions (metacity 2.17.2-1.fc7), it
8802 reportedly causes hangs when resizing frames. */ 8892 reportedly causes hangs when resizing frames. */
8803 8893
8804 /* Lisp_Object frame; 8894 const char *atom = "_NET_ACTIVE_WINDOW";
8805 const char *atom = "_NET_ACTIVE_WINDOW"; */ 8895 if (f->async_visible && wm_supports (f, atom))
8806 8896 {
8807 x_raise_frame (f); 8897 Lisp_Object frame;
8808 8898 XSETFRAME (frame, f);
8809 /* XSETFRAME (frame, f); 8899 Fx_send_client_event (frame, make_number (0), frame,
8810 Fx_send_client_event (frame, make_number (0), frame, 8900 make_unibyte_string (atom, strlen (atom)),
8811 make_unibyte_string (atom, strlen (atom)), 8901 make_number (32),
8812 make_number (32), 8902 Fcons (make_number (1),
8813 Fcons (make_number (1), 8903 Fcons (make_number (last_user_time),
8814 Fcons (make_number (time (NULL) * 1000), 8904 Qnil)));
8815 Qnil))); */ 8905 }
8906 else
8907#endif
8908 x_raise_frame (f);
8816 } 8909 }
8817 else 8910 else
8818 x_lower_frame (f); 8911 x_lower_frame (f);
@@ -10807,6 +10900,10 @@ x_term_init (display_name, xrm_option, resource_name)
10807 dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms) 10900 dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms)
10808 * dpyinfo->x_dnd_atoms_size); 10901 * dpyinfo->x_dnd_atoms_size);
10809 10902
10903 dpyinfo->net_supported_atoms = NULL;
10904 dpyinfo->nr_net_supported_atoms = 0;
10905 dpyinfo->net_supported_window = 0;
10906
10810 connection = ConnectionNumber (dpyinfo->display); 10907 connection = ConnectionNumber (dpyinfo->display);
10811 dpyinfo->connection = connection; 10908 dpyinfo->connection = connection;
10812 10909