[gtk+/events-refactor: 1080/1085] Merge branch 'master' into events-refactor



commit b35bdaa81bbed4453e21054fc6f6a214179a2c91
Merge: e1d99c0... bfc8824...
Author: Carlos Garnacho <carlos gnome org>
Date:   Mon Sep 21 20:53:58 2009 +0200

    Merge branch 'master' into events-refactor
    
    New code from gdkevents-x11.c was moved to GdkDisplayX11, the rest of the
    code is unaffected.

 NEWS                                               |   94 +
 autogen.sh                                         |   17 +-
 configure.in                                       |   62 +-
 demos/gtk-demo/Makefile.am                         |    2 +
 demos/gtk-demo/clipboard.c                         |    4 +
 demos/gtk-demo/links.c                             |    8 +-
 demos/gtk-demo/menus.c                             |   35 +-
 demos/gtk-demo/offscreen_window.c                  |  579 +++
 demos/gtk-demo/offscreen_window2.c                 |  500 ++
 docs/reference/gdk/gdk-sections.txt                |    4 +
 docs/reference/gdk/tmpl/cairo_interaction.sgml     |    9 +
 docs/reference/gdk/tmpl/keys.sgml                  |    5 +
 docs/reference/gdk/tmpl/windows.sgml               |   68 +-
 docs/reference/gtk/Makefile.am                     |    2 +
 docs/reference/gtk/gtk-docs.sgml                   |    1 +
 docs/reference/gtk/gtk-sections.txt                |    7 +
 .../reference/gtk/migrating-ClientSideWindows.sgml |   70 +
 docs/reference/gtk/tmpl/gtkrange.sgml              |   18 +
 docs/reference/gtk/tmpl/gtkwidget.sgml             |   45 +
 gdk-pixbuf/io-xpm.c                                |    2 +-
 gdk-pixbuf/queryloaders.c                          |   15 +-
 gdk/directfb/gdkdirectfb.h                         |    2 +
 gdk/directfb/gdkwindow-directfb.c                  |  207 +
 gdk/gdk.c                                          |    9 +-
 gdk/gdk.symbols                                    |    8 +
 gdk/gdkcairo.c                                     |   28 +
 gdk/gdkcairo.h                                     |    2 +
 gdk/gdkdisplay.c                                   |   16 +-
 gdk/gdkevents.h                                    |    2 +
 gdk/gdkgc.c                                        |    9 +-
 gdk/gdkinternals.h                                 |    5 +
 gdk/gdkkeysyms-update.pl                           |   71 +-
 gdk/gdkkeysyms.h                                   | 1467 ++++---
 gdk/gdkoffscreenwindow.c                           |   17 +-
 gdk/gdkprivate.h                                   |    9 +-
 gdk/gdkselection.h                                 |    2 +-
 gdk/gdkwindow.c                                    |  908 +++-
 gdk/gdkwindow.h                                    |    9 +
 gdk/gdkwindowimpl.h                                |    3 +
 gdk/quartz/gdkevents-quartz.c                      |    6 +-
 gdk/quartz/gdkwindow-quartz.c                      |   21 +-
 gdk/win32/gdkwindow-win32.c                        |   17 +-
 gdk/x11/gdkdisplay-x11.c                           |   49 +-
 gdk/x11/gdkdrawable-x11.c                          |   11 +
 gdk/x11/gdkdrawable-x11.h                          |    2 +
 gdk/x11/gdkevents-x11.c                            |   89 +-
 gdk/x11/gdkgeometry-x11.c                          |   21 +-
 gdk/x11/gdkinput-x11.c                             |    4 +-
 gdk/x11/gdkinput-xfree.c                           |   14 +-
 gdk/x11/gdkinput.c                                 |   28 +-
 gdk/x11/gdkpixmap-x11.c                            |    2 +-
 gdk/x11/gdkscreen-x11.c                            |   20 +-
 gdk/x11/gdkscreen-x11.h                            |    1 +
 gdk/x11/gdkwindow-x11.c                            |   32 +-
 gdk/x11/gdkx.h                                     |    6 +-
 gtk/gtk.symbols                                    |    7 +
 gtk/gtkcellrendereraccel.c                         |    1 +
 gtk/gtkcellrendererspin.c                          |   19 +
 gtk/gtkcellrenderertoggle.c                        |    2 +-
 gtk/gtkcellview.c                                  |    2 +
 gtk/gtkclist.c                                     |   10 +-
 gtk/gtkcombobox.c                                  |   10 +
 gtk/gtkcomboboxentry.c                             |    5 +-
 gtk/gtkcustompaperunixdialog.c                     |    9 +-
 gtk/gtkentry.c                                     |   40 +-
 gtk/gtkfilechooser.c                               |    3 +-
 gtk/gtkfilechooserdefault.c                        |    1 +
 gtk/gtkfilechooserdialog.c                         |    9 +-
 gtk/gtkiconfactory.c                               |  481 +-
 gtk/gtkimmodule.c                                  |   10 +-
 gtk/gtkimmulticontext.c                            |   75 +-
 gtk/gtkmain.c                                      |   10 +-
 gtk/gtkmountoperation-x11.c                        |    4 +-
 gtk/gtkprinteroptionwidget.c                       |    2 +-
 gtk/gtkprintoperation-unix.c                       |    9 +-
 gtk/gtkprintsettings.c                             |    8 +-
 gtk/gtkradiobutton.c                               |    4 +-
 gtk/gtkrange.c                                     |   46 +
 gtk/gtkrange.h                                     |    4 +
 gtk/gtkscale.c                                     |    2 +-
 gtk/gtksizegroup.c                                 |    8 +
 gtk/gtkstatusicon.c                                |    4 +
 gtk/gtktestutils.c                                 |    2 +
 gtk/gtktextbuffer.c                                |   11 +-
 gtk/gtktextview.c                                  |   32 +-
 gtk/gtktooltip.c                                   |    9 +-
 gtk/gtktreemodelfilter.c                           |  294 +-
 gtk/gtktreemodelsort.c                             |  169 +-
 gtk/gtktreeview.c                                  |  181 +-
 gtk/gtkwidget.c                                    |  156 +-
 gtk/gtkwidget.h                                    |   15 +-
 gtk/gtkwindow.c                                    |   16 +-
 gtk/tests/Makefile.am                              |    8 +
 gtk/tests/expander.c                               |   94 +
 gtk/tests/filtermodel.c                            | 2722 +++++++++++
 gtk/tests/textbuffer.c                             |   37 +
 gtk/tests/treeview.c                               |   56 +
 gtk/updateiconcache.c                              |    4 +
 modules/other/gail/gailbutton.c                    |    5 -
 modules/other/gail/gailcombobox.c                  |   12 +-
 modules/other/gail/gailscalebutton.c               |    2 -
 modules/printbackends/cups/gtkprintbackendcups.c   |   67 +-
 modules/printbackends/file/gtkprintbackendfile.c   |    5 -
 modules/printbackends/lpr/gtkprintbackendlpr.c     |   21 +-
 modules/printbackends/papi/gtkprintbackendpapi.c   |    5 +-
 modules/printbackends/test/gtkprintbackendtest.c   |    3 -
 po-properties/Makefile.in.in                       |   23 +-
 po-properties/af.po                                |   92 +-
 po-properties/am.po                                |   92 +-
 po-properties/ang.po                               |   92 +-
 po-properties/ar.po                                |   92 +-
 po-properties/as.po                                |  901 ++--
 po-properties/ast.po                               |   92 +-
 po-properties/az.po                                |   92 +-
 po-properties/az_IR.po                             |   92 +-
 po-properties/be.po                                |   92 +-
 po-properties/be latin po                          |   92 +-
 po-properties/bg.po                                |   92 +-
 po-properties/bn.po                                |   92 +-
 po-properties/bn_IN.po                             | 4751 ++++++++++----------
 po-properties/br.po                                |   92 +-
 po-properties/bs.po                                |   92 +-
 po-properties/ca.po                                |   92 +-
 po-properties/ca valencia po                       |   92 +-
 po-properties/crh.po                               |   92 +-
 po-properties/cs.po                                |  208 +-
 po-properties/cy.po                                |   92 +-
 po-properties/da.po                                | 3588 ++++++++--------
 po-properties/de.po                                | 3699 ++++++++--------
 po-properties/dz.po                                |   92 +-
 po-properties/el.po                                |   92 +-
 po-properties/en_CA.po                             |   92 +-
 po-properties/en_GB.po                             | 3612 ++++++++--------
 po-properties/eo.po                                |   92 +-
 po-properties/es.po                                |   92 +-
 po-properties/et.po                                |   92 +-
 po-properties/eu.po                                | 3808 ++++++++--------
 po-properties/fa.po                                |   92 +-
 po-properties/fi.po                                |  208 +-
 po-properties/fr.po                                |  126 +-
 po-properties/ga.po                                |   92 +-
 po-properties/gl.po                                |   92 +-
 po-properties/gu.po                                | 3742 ++++++++--------
 po-properties/he.po                                |  116 +-
 po-properties/hi.po                                | 3664 ++++++++--------
 po-properties/hr.po                                |   92 +-
 po-properties/hu.po                                |  228 +-
 po-properties/hy.po                                |   92 +-
 po-properties/ia.po                                |   92 +-
 po-properties/id.po                                |   92 +-
 po-properties/io.po                                |   92 +-
 po-properties/is.po                                |   92 +-
 po-properties/it.po                                |   92 +-
 po-properties/ja.po                                |  649 ++--
 po-properties/ka.po                                |   92 +-
 po-properties/kn.po                                |  206 +-
 po-properties/ko.po                                |   92 +-
 po-properties/ku.po                                |   92 +-
 po-properties/li.po                                |   92 +-
 po-properties/lt.po                                | 3559 +++++++-------
 po-properties/lv.po                                |   92 +-
 po-properties/mai.po                               | 4270 +++++++++---------
 po-properties/mi.po                                |   92 +-
 po-properties/mk.po                                |   92 +-
 po-properties/ml.po                                | 3805 ++++++++--------
 po-properties/mn.po                                |   92 +-
 po-properties/mr.po                                | 3781 ++++++++--------
 po-properties/ms.po                                |   92 +-
 po-properties/nb.po                                | 3519 +++++++-------
 po-properties/ne.po                                |   92 +-
 po-properties/nl.po                                |   92 +-
 po-properties/nn.po                                |   92 +-
 po-properties/nso.po                               |   92 +-
 po-properties/oc.po                                |   92 +-
 po-properties/or.po                                | 3988 ++++++++--------
 po-properties/pa.po                                |   92 +-
 po-properties/pl.po                                |  455 +-
 po-properties/ps.po                                |   92 +-
 po-properties/pt.po                                |   92 +-
 po-properties/pt_BR.po                             |   92 +-
 po-properties/ro.po                                |  209 +-
 po-properties/ru.po                                |   92 +-
 po-properties/rw.po                                |   92 +-
 po-properties/si.po                                |   92 +-
 po-properties/sk.po                                |   92 +-
 po-properties/sl.po                                | 4842 ++++++++++----------
 po-properties/sq.po                                |   92 +-
 po-properties/sr.po                                |   95 +-
 po-properties/sr ije po                            |   92 +-
 po-properties/sr latin po                          |   95 +-
 po-properties/sv.po                                |   92 +-
 po-properties/ta.po                                | 3675 ++++++++--------
 po-properties/te.po                                |  205 +-
 po-properties/th.po                                |   92 +-
 po-properties/tk.po                                |   92 +-
 po-properties/tr.po                                |   92 +-
 po-properties/tt.po                                |   92 +-
 po-properties/uk.po                                | 3554 +++++++-------
 po-properties/ur.po                                |   92 +-
 po-properties/uz.po                                |   92 +-
 po-properties/uz cyrillic po                       |   92 +-
 po-properties/vi.po                                |   92 +-
 po-properties/wa.po                                |   92 +-
 po-properties/xh.po                                |   92 +-
 po-properties/yi.po                                |   92 +-
 po-properties/zh_CN.po                             | 3593 ++++++++--------
 po-properties/zh_HK.po                             | 3679 ++++++++--------
 po-properties/zh_TW.po                             | 3584 ++++++++--------
 po/Makefile.in.in                                  |   23 +-
 po/af.po                                           |  298 +-
 po/am.po                                           |  298 +-
 po/ang.po                                          |  298 +-
 po/ar.po                                           |  298 +-
 po/as.po                                           |  464 +-
 po/ast.po                                          | 2194 +++++-----
 po/az.po                                           |  298 +-
 po/az_IR.po                                        |  298 +-
 po/be.po                                           |  298 +-
 po/be latin po                                     |  298 +-
 po/bg.po                                           |  298 +-
 po/bn.po                                           |  298 +-
 po/bn_IN.po                                        |  387 +-
 po/br.po                                           |  298 +-
 po/bs.po                                           |  298 +-
 po/ca.po                                           |  298 +-
 po/ca valencia po                                  |  298 +-
 po/crh.po                                          |  298 +-
 po/cs.po                                           |  422 +-
 po/cy.po                                           |  298 +-
 po/da.po                                           | 2313 +++++-----
 po/de.po                                           | 2280 +++++-----
 po/dz.po                                           |  298 +-
 po/el.po                                           | 2690 ++++++------
 po/en_CA.po                                        |  298 +-
 po/en_GB.po                                        | 2343 +++++-----
 po/eo.po                                           |  298 +-
 po/es.po                                           |  298 +-
 po/et.po                                           |  298 +-
 po/eu.po                                           |  298 +-
 po/fa.po                                           |  298 +-
 po/fi.po                                           |  431 +-
 po/fr.po                                           |  325 +-
 po/ga.po                                           |  298 +-
 po/gl.po                                           |  298 +-
 po/gu.po                                           | 2361 +++++-----
 po/he.po                                           |  298 +-
 po/hi.po                                           | 2220 +++++-----
 po/hr.po                                           |  298 +-
 po/hu.po                                           |  435 +-
 po/hy.po                                           |  298 +-
 po/ia.po                                           |  298 +-
 po/id.po                                           |  298 +-
 po/io.po                                           |  298 +-
 po/is.po                                           |  298 +-
 po/it.po                                           | 2578 +++++------
 po/ja.po                                           |  451 +-
 po/ka.po                                           |  298 +-
 po/kn.po                                           |  440 +-
 po/ko.po                                           |  298 +-
 po/ku.po                                           |  298 +-
 po/li.po                                           |  298 +-
 po/lt.po                                           | 2343 +++++-----
 po/lv.po                                           |  298 +-
 po/mai.po                                          | 2377 +++++-----
 po/mi.po                                           |  298 +-
 po/mk.po                                           |  298 +-
 po/ml.po                                           | 2364 +++++-----
 po/mn.po                                           |  298 +-
 po/mr.po                                           | 2401 +++++-----
 po/ms.po                                           |  298 +-
 po/nb.po                                           | 2180 +++++-----
 po/ne.po                                           |  298 +-
 po/nl.po                                           | 3778 ++++++----------
 po/nn.po                                           |  298 +-
 po/nso.po                                          |  298 +-
 po/oc.po                                           |  298 +-
 po/or.po                                           | 2315 +++++-----
 po/pa.po                                           |  298 +-
 po/pl.po                                           | 3413 ++++++---------
 po/ps.po                                           |  298 +-
 po/pt.po                                           |  298 +-
 po/pt_BR.po                                        | 2176 +++++-----
 po/ro.po                                           | 2367 +++++-----
 po/ru.po                                           |  298 +-
 po/rw.po                                           |  298 +-
 po/si.po                                           |  298 +-
 po/sk.po                                           |  298 +-
 po/sl.po                                           | 2899 ++++++-------
 po/sq.po                                           |  298 +-
 po/sr.po                                           |  443 +-
 po/sr ije po                                       |  298 +-
 po/sr latin po                                     |  442 +-
 po/sv.po                                           |  298 +-
 po/ta.po                                           | 2223 +++++-----
 po/te.po                                           |  446 +-
 po/th.po                                           |  298 +-
 po/tk.po                                           |  298 +-
 po/tr.po                                           |  298 +-
 po/tt.po                                           |  298 +-
 po/uk.po                                           | 2228 +++++-----
 po/ur.po                                           |  298 +-
 po/uz.po                                           |  298 +-
 po/uz cyrillic po                                  |  298 +-
 po/vi.po                                           |  298 +-
 po/wa.po                                           |  298 +-
 po/xh.po                                           |  298 +-
 po/yi.po                                           |  298 +-
 po/zh_CN.po                                        | 2299 +++++-----
 po/zh_HK.po                                        | 2253 +++++-----
 po/zh_TW.po                                        | 2237 +++++-----
 tests/Makefile.am                                  |    3 +-
 tests/testwindows.c                                |   45 +-
 312 files changed, 88788 insertions(+), 86609 deletions(-)
---
diff --cc gdk/x11/gdkdisplay-x11.c
index ac0a61e,2b10a93..7b3ab52
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@@ -147,985 -136,6 +147,985 @@@ _gdk_display_x11_init (GdkDisplayX11 *d
  {
  }
  
 +static void
 +gdk_display_x11_event_translator_init (GdkEventTranslatorIface *iface)
 +{
 +  iface->translate_event = gdk_display_x11_translate_event;
 +}
 +
 +static void
 +do_net_wm_state_changes (GdkWindow *window)
 +{
 +  GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
 +  GdkWindowState old_state;
 +
 +  if (GDK_WINDOW_DESTROYED (window) ||
 +      gdk_window_get_window_type (window) != GDK_WINDOW_TOPLEVEL)
 +    return;
 +
 +  old_state = gdk_window_get_state (window);
 +
 +  /* For found_sticky to remain TRUE, we have to also be on desktop
 +   * 0xFFFFFFFF
 +   */
 +  if (old_state & GDK_WINDOW_STATE_STICKY)
 +    {
 +      if (!(toplevel->have_sticky && toplevel->on_all_desktops))
 +        gdk_synthesize_window_state (window,
 +                                     GDK_WINDOW_STATE_STICKY,
 +                                     0);
 +    }
 +  else
 +    {
 +      if (toplevel->have_sticky || toplevel->on_all_desktops)
 +        gdk_synthesize_window_state (window,
 +                                     0,
 +                                     GDK_WINDOW_STATE_STICKY);
 +    }
 +
 +  if (old_state & GDK_WINDOW_STATE_FULLSCREEN)
 +    {
 +      if (!toplevel->have_fullscreen)
 +        gdk_synthesize_window_state (window,
 +                                     GDK_WINDOW_STATE_FULLSCREEN,
 +                                     0);
 +    }
 +  else
 +    {
 +      if (toplevel->have_fullscreen)
 +        gdk_synthesize_window_state (window,
 +                                     0,
 +                                     GDK_WINDOW_STATE_FULLSCREEN);
 +    }
 +
 +  /* Our "maximized" means both vertical and horizontal; if only one,
 +   * we don't expose that via GDK
 +   */
 +  if (old_state & GDK_WINDOW_STATE_MAXIMIZED)
 +    {
 +      if (!(toplevel->have_maxvert && toplevel->have_maxhorz))
 +        gdk_synthesize_window_state (window,
 +                                     GDK_WINDOW_STATE_MAXIMIZED,
 +                                     0);
 +    }
 +  else
 +    {
 +      if (toplevel->have_maxvert && toplevel->have_maxhorz)
 +        gdk_synthesize_window_state (window,
 +                                     0,
 +                                     GDK_WINDOW_STATE_MAXIMIZED);
 +    }
 +}
 +
 +static void
 +gdk_check_wm_desktop_changed (GdkWindow *window)
 +{
 +  GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
 +  GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
 +
 +  Atom type;
 +  gint format;
 +  gulong nitems;
 +  gulong bytes_after;
 +  guchar *data;
 +  gulong *desktop;
 +
 +  type = None;
 +  gdk_error_trap_push ();
 +  XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
 +                      GDK_WINDOW_XID (window),
 +                      gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
 +                      0, G_MAXLONG, False, XA_CARDINAL, &type,
 +                      &format, &nitems,
 +                      &bytes_after, &data);
 +  gdk_error_trap_pop ();
 +
 +  if (type != None)
 +    {
 +      desktop = (gulong *)data;
 +      toplevel->on_all_desktops = (*desktop == 0xFFFFFFFF);
 +      XFree (desktop);
 +    }
 +  else
 +    toplevel->on_all_desktops = FALSE;
 +
 +  do_net_wm_state_changes (window);
 +}
 +
 +static void
 +gdk_check_wm_state_changed (GdkWindow *window)
 +{
 +  GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (window);
 +  GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
 +
 +  Atom type;
 +  gint format;
 +  gulong nitems;
 +  gulong bytes_after;
 +  guchar *data;
 +  Atom *atoms = NULL;
 +  gulong i;
 +
 +  gboolean had_sticky = toplevel->have_sticky;
 +
 +  toplevel->have_sticky = FALSE;
 +  toplevel->have_maxvert = FALSE;
 +  toplevel->have_maxhorz = FALSE;
 +  toplevel->have_fullscreen = FALSE;
 +
 +  type = None;
 +  gdk_error_trap_push ();
 +  XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
 +		      gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"),
 +		      0, G_MAXLONG, False, XA_ATOM, &type, &format, &nitems,
 +		      &bytes_after, &data);
 +  gdk_error_trap_pop ();
 +
 +  if (type != None)
 +    {
 +      Atom sticky_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_STICKY");
 +      Atom maxvert_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_VERT");
 +      Atom maxhorz_atom	= gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_MAXIMIZED_HORZ");
 +      Atom fullscreen_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE_FULLSCREEN");
 +
 +      atoms = (Atom *)data;
 +
 +      i = 0;
 +      while (i < nitems)
 +        {
 +          if (atoms[i] == sticky_atom)
 +            toplevel->have_sticky = TRUE;
 +          else if (atoms[i] == maxvert_atom)
 +            toplevel->have_maxvert = TRUE;
 +          else if (atoms[i] == maxhorz_atom)
 +            toplevel->have_maxhorz = TRUE;
 +          else if (atoms[i] == fullscreen_atom)
 +            toplevel->have_fullscreen = TRUE;
 +
 +          ++i;
 +        }
 +
 +      XFree (atoms);
 +    }
 +
 +  /* When have_sticky is turned on, we have to check the DESKTOP property
 +   * as well.
 +   */
 +  if (toplevel->have_sticky && !had_sticky)
 +    gdk_check_wm_desktop_changed (window);
 +  else
 +    do_net_wm_state_changes (window);
 +}
 +
 +static GdkWindow *
 +get_event_window (GdkEventTranslator *translator,
 +                  XEvent             *xevent)
 +{
 +  GdkDisplay *display;
 +  Window xwindow;
 +
 +  display = (GdkDisplay *) translator;
 +
 +  switch (xevent->type)
 +    {
 +    case DestroyNotify:
 +      xwindow = xevent->xdestroywindow.window;
 +      break;
 +    case UnmapNotify:
 +      xwindow = xevent->xunmap.window;
 +      break;
 +    case MapNotify:
 +      xwindow = xevent->xmap.window;
 +      break;
 +    case ConfigureNotify:
 +      xwindow = xevent->xconfigure.window;
 +      break;
 +    default:
 +      xwindow = xevent->xany.window;
 +    }
 +
 +  return gdk_window_lookup_for_display (display, xwindow);
 +}
 +
 +static gboolean
 +gdk_display_x11_translate_event (GdkEventTranslator *translator,
 +                                 GdkDisplay         *display,
 +                                 GdkEvent           *event,
 +                                 XEvent             *xevent)
 +{
 +  GdkWindow *window;
 +  GdkWindowObject *window_private;
 +  GdkWindowImplX11 *window_impl = NULL;
 +  GdkScreen *screen = NULL;
 +  GdkScreenX11 *screen_x11 = NULL;
 +  GdkToplevelX11 *toplevel = NULL;
 +  GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
 +  gboolean return_val;
 +  Window xwindow = None;
 +
 +  /* Find the GdkWindow that this event relates to.
 +   * Basically this means substructure events
 +   * are reported same as structure events
 +   */
 +  window = get_event_window (translator, xevent);
 +  window_private = (GdkWindowObject *) window;
 +
 +  if (window)
 +    {
 +      /* We may receive events such as NoExpose/GraphicsExpose
 +       * and ShmCompletion for pixmaps
 +       */
 +      if (!GDK_IS_WINDOW (window))
 +        return FALSE;
 +
 +      screen = GDK_WINDOW_SCREEN (window);
 +      screen_x11 = GDK_SCREEN_X11 (screen);
 +      toplevel = _gdk_x11_window_get_toplevel (window);
 +      window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
 +      xwindow = GDK_WINDOW_XID (window);
 +
 +      g_object_ref (window);
 +    }
 +
 +  event->any.window = window;
 +  event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
 +
 +  if (window_private && GDK_WINDOW_DESTROYED (window))
 +    {
 +      if (xevent->type != DestroyNotify)
 +	{
 +	  return_val = FALSE;
 +	  goto done;
 +	}
 +    }
 +
-   /* FIXME: if window is NULL, xwindow should still have something meaningful here? */
-   if (xwindow != None &&
-       screen_x11 && screen_x11->wmspec_check_window != None &&
-       xwindow == screen_x11->wmspec_check_window)
++  if (xevent->type == DestroyNotify)
 +    {
-       if (xevent->type == DestroyNotify)
-         {
-           screen_x11->wmspec_check_window = None;
-           g_free (screen_x11->window_manager_name);
-           screen_x11->window_manager_name = g_strdup ("unknown");
++      int i, n;
 +
-           /* careful, reentrancy */
-           _gdk_x11_screen_window_manager_changed (GDK_SCREEN (screen_x11));
++      n = gdk_display_get_n_screens (display);
++      for (i = 0; i < n; i++)
++        {
++          screen = gdk_display_get_screen (display, i);
++          screen_x11 = GDK_SCREEN_X11 (screen);
++
++          if (screen_x11->wmspec_check_window == xwindow)
++            {
++              screen_x11->wmspec_check_window = None;
++              screen_x11->last_wmspec_check_time = 0;
++              g_free (screen_x11->window_manager_name);
++              screen_x11->window_manager_name = g_strdup ("unknown");
++
++              /* careful, reentrancy */
++              _gdk_x11_screen_window_manager_changed (screen);
++
++              return_val = FALSE;
++              goto done;
++            }
 +        }
- 
-       /* Eat events on this window unless someone had wrapped
-        * it as a foreign window
-        */
-       if (window == NULL)
- 	{
- 	  return_val = FALSE;
- 	  goto done;
- 	}
 +    }
 +
 +  /* We do a "manual" conversion of the XEvent to a
 +   *  GdkEvent. The structures are mostly the same so
 +   *  the conversion is fairly straightforward. We also
 +   *  optionally print debugging info regarding events
 +   *  received.
 +   */
 +
 +  return_val = TRUE;
 +
 +  switch (xevent->type)
 +    {
 +    case KeymapNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("keymap notify"));
 +
 +      /* Not currently handled */
 +      return_val = FALSE;
 +      break;
 +
 +    case Expose:
 +      GDK_NOTE (EVENTS,
 +		g_message ("expose:\t\twindow: %ld  %d	x,y: %d %d  w,h: %d %d%s",
 +			   xevent->xexpose.window, xevent->xexpose.count,
 +			   xevent->xexpose.x, xevent->xexpose.y,
 +			   xevent->xexpose.width, xevent->xexpose.height,
 +			   event->any.send_event ? " (send)" : ""));
 +
 +      if (window_private == NULL)
 +        {
 +          return_val = FALSE;
 +          break;
 +        }
 +
 +      {
 +	GdkRectangle expose_rect;
 +
 +	expose_rect.x = xevent->xexpose.x;
 +	expose_rect.y = xevent->xexpose.y;
 +	expose_rect.width = xevent->xexpose.width;
 +	expose_rect.height = xevent->xexpose.height;
 +
 +        _gdk_window_process_expose (window, xevent->xexpose.serial, &expose_rect);
 +        return_val = FALSE;
 +      }
 +
 +      break;
 +
 +    case GraphicsExpose:
 +      {
 +	GdkRectangle expose_rect;
 +
 +        GDK_NOTE (EVENTS,
 +		  g_message ("graphics expose:\tdrawable: %ld",
 +			     xevent->xgraphicsexpose.drawable));
 +
 +        if (window_private == NULL)
 +          {
 +            return_val = FALSE;
 +            break;
 +          }
 +
 +	expose_rect.x = xevent->xgraphicsexpose.x;
 +	expose_rect.y = xevent->xgraphicsexpose.y;
 +	expose_rect.width = xevent->xgraphicsexpose.width;
 +	expose_rect.height = xevent->xgraphicsexpose.height;
 +
 +        _gdk_window_process_expose (window, xevent->xgraphicsexpose.serial, &expose_rect);
- 
 +        return_val = FALSE;
 +      }
 +      break;
 +
 +    case NoExpose:
 +      GDK_NOTE (EVENTS,
 +		g_message ("no expose:\t\tdrawable: %ld",
 +			   xevent->xnoexpose.drawable));
 +
 +      event->no_expose.type = GDK_NO_EXPOSE;
 +      event->no_expose.window = window;
 +
 +      break;
 +
 +    case VisibilityNotify:
 +#ifdef G_ENABLE_DEBUG
 +      if (_gdk_debug_flags & GDK_DEBUG_EVENTS)
 +	switch (xevent->xvisibility.state)
 +	  {
 +	  case VisibilityFullyObscured:
 +	    g_message ("visibility notify:\twindow: %ld	 none",
 +		       xevent->xvisibility.window);
 +	    break;
 +	  case VisibilityPartiallyObscured:
 +	    g_message ("visibility notify:\twindow: %ld	 partial",
 +		       xevent->xvisibility.window);
 +	    break;
 +	  case VisibilityUnobscured:
 +	    g_message ("visibility notify:\twindow: %ld	 full",
 +		       xevent->xvisibility.window);
 +	    break;
 +	  }
 +#endif /* G_ENABLE_DEBUG */
 +
 +      if (window_private == NULL)
 +        {
 +          return_val = FALSE;
 +          break;
 +        }
 +
 +      event->visibility.type = GDK_VISIBILITY_NOTIFY;
 +      event->visibility.window = window;
 +
 +      switch (xevent->xvisibility.state)
 +	{
 +	case VisibilityFullyObscured:
 +	  event->visibility.state = GDK_VISIBILITY_FULLY_OBSCURED;
 +	  break;
 +
 +	case VisibilityPartiallyObscured:
 +	  event->visibility.state = GDK_VISIBILITY_PARTIAL;
 +	  break;
 +
 +	case VisibilityUnobscured:
 +	  event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
 +	  break;
 +	}
 +
 +      break;
 +
 +    case CreateNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("create notify:\twindow: %ld  x,y: %d %d	w,h: %d %d  b-w: %d  parent: %ld	 ovr: %d",
 +			   xevent->xcreatewindow.window,
 +			   xevent->xcreatewindow.x,
 +			   xevent->xcreatewindow.y,
 +			   xevent->xcreatewindow.width,
 +			   xevent->xcreatewindow.height,
 +			   xevent->xcreatewindow.border_width,
 +			   xevent->xcreatewindow.parent,
 +			   xevent->xcreatewindow.override_redirect));
 +      /* not really handled */
 +      break;
 +
 +    case DestroyNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("destroy notify:\twindow: %ld",
 +			   xevent->xdestroywindow.window));
 +
 +      /* Ignore DestroyNotify from SubstructureNotifyMask */
 +      if (xevent->xdestroywindow.window == xevent->xdestroywindow.event)
 +	{
 +	  event->any.type = GDK_DESTROY;
 +	  event->any.window = window;
 +
 +	  return_val = window_private && !GDK_WINDOW_DESTROYED (window);
 +
 +	  if (window && GDK_WINDOW_XID (window) != screen_x11->xroot_window)
 +	    gdk_window_destroy_notify (window);
 +	}
 +      else
 +	return_val = FALSE;
 +
 +      break;
 +
 +    case UnmapNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("unmap notify:\t\twindow: %ld",
 +			   xevent->xmap.window));
 +
 +      event->any.type = GDK_UNMAP;
 +      event->any.window = window;
 +
 +      /* If we are shown (not withdrawn) and get an unmap, it means we
 +       * were iconified in the X sense. If we are withdrawn, and get
 +       * an unmap, it means we hid the window ourselves, so we
 +       * will have already flipped the iconified bit off.
 +       */
 +      if (window)
 +	{
 +	  if (GDK_WINDOW_IS_MAPPED (window))
 +	    gdk_synthesize_window_state (window,
 +					 0,
 +					 GDK_WINDOW_STATE_ICONIFIED);
 +
 +	  _gdk_xgrab_check_unmap (window, xevent->xany.serial);
 +	}
 +
 +      break;
 +
 +    case MapNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("map notify:\t\twindow: %ld",
 +			   xevent->xmap.window));
 +
 +      event->any.type = GDK_MAP;
 +      event->any.window = window;
 +
 +      /* Unset iconified if it was set */
 +      if (window && (((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_ICONIFIED))
 +        gdk_synthesize_window_state (window,
 +                                     GDK_WINDOW_STATE_ICONIFIED,
 +                                     0);
 +
 +      break;
 +
 +    case ReparentNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("reparent notify:\twindow: %ld  x,y: %d %d  parent: %ld	ovr: %d",
 +			   xevent->xreparent.window,
 +			   xevent->xreparent.x,
 +			   xevent->xreparent.y,
 +			   xevent->xreparent.parent,
 +			   xevent->xreparent.override_redirect));
 +
 +      /* Not currently handled */
 +      return_val = FALSE;
 +      break;
 +
 +    case ConfigureNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("configure notify:\twindow: %ld  x,y: %d %d	w,h: %d %d  b-w: %d  above: %ld	 ovr: %d%s",
 +			   xevent->xconfigure.window,
 +			   xevent->xconfigure.x,
 +			   xevent->xconfigure.y,
 +			   xevent->xconfigure.width,
 +			   xevent->xconfigure.height,
 +			   xevent->xconfigure.border_width,
 +			   xevent->xconfigure.above,
 +			   xevent->xconfigure.override_redirect,
 +			   !window
 +			   ? " (discarding)"
 +			   : GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD
 +			   ? " (discarding child)"
 +			   : xevent->xconfigure.event != xevent->xconfigure.window
 +			   ? " (discarding substructure)"
 +			   : ""));
 +      if (window && GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
 +        {
 +	  window_private->width = xevent->xconfigure.width;
 +	  window_private->height = xevent->xconfigure.height;
 +
 +	  _gdk_window_update_size (window);
 +	  _gdk_x11_drawable_update_size (window_private->impl);
 +	  _gdk_x11_screen_size_changed (screen, xevent);
 +        }
 +
 +#if 0
 +      if (window &&
 +	  xevent->xconfigure.event == xevent->xconfigure.window &&
 +	  !GDK_WINDOW_DESTROYED (window) &&
 +          window_private->input_window != NULL)
 +	_gdk_input_configure_event (&xevent->xconfigure, window);
 +#endif
 +
 +#ifdef HAVE_XSYNC
 +      if (toplevel && display_x11->use_sync && !XSyncValueIsZero (toplevel->pending_counter_value))
 +	{
 +	  toplevel->current_counter_value = toplevel->pending_counter_value;
 +	  XSyncIntToValue (&toplevel->pending_counter_value, 0);
 +	}
 +#endif
 +
 +    if (!window ||
 +	  xevent->xconfigure.event != xevent->xconfigure.window ||
 +          GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD ||
 +          GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
 +	return_val = FALSE;
 +      else
 +	{
 +	  event->configure.type = GDK_CONFIGURE;
 +	  event->configure.window = window;
 +	  event->configure.width = xevent->xconfigure.width;
 +	  event->configure.height = xevent->xconfigure.height;
 +
 +	  if (!xevent->xconfigure.send_event &&
 +	      !xevent->xconfigure.override_redirect &&
 +	      !GDK_WINDOW_DESTROYED (window))
 +	    {
 +	      gint tx = 0;
 +	      gint ty = 0;
 +	      Window child_window = 0;
 +
 +	      gdk_error_trap_push ();
 +	      if (XTranslateCoordinates (GDK_DRAWABLE_XDISPLAY (window),
 +					 GDK_DRAWABLE_XID (window),
 +					 screen_x11->xroot_window,
 +					 0, 0,
 +					 &tx, &ty,
 +					 &child_window))
 +		{
 +		  event->configure.x = tx;
 +		  event->configure.y = ty;
 +		}
 +	      gdk_error_trap_pop ();
 +	    }
 +	  else
 +	    {
 +	      event->configure.x = xevent->xconfigure.x;
 +	      event->configure.y = xevent->xconfigure.y;
 +	    }
 +	  window_private->x = event->configure.x;
 +	  window_private->y = event->configure.y;
 +	  window_private->width = xevent->xconfigure.width;
 +	  window_private->height = xevent->xconfigure.height;
 +
 +	  _gdk_window_update_size (window);
 +	  _gdk_x11_drawable_update_size (window_private->impl);
 +
 +	  if (window_private->resize_count >= 1)
 +	    {
 +	      window_private->resize_count -= 1;
 +
 +	      if (window_private->resize_count == 0)
 +		_gdk_moveresize_configure_done (display, window);
 +	    }
 +	}
 +      break;
 +
 +    case PropertyNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
 +			   xevent->xproperty.window,
 +			   xevent->xproperty.atom,
 +			   "\"",
 +			   gdk_x11_get_xatom_name_for_display (display, xevent->xproperty.atom),
 +			   "\""));
 +
 +      if (window_private == NULL)
 +        {
 +	  return_val = FALSE;
 +          break;
 +        }
 +
 +      /* We compare with the serial of the last time we mapped the
 +       * window to avoid refetching properties that we set ourselves
 +       */
 +      if (toplevel &&
 +	  xevent->xproperty.serial >= toplevel->map_serial)
 +	{
 +	  if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"))
 +	    gdk_check_wm_state_changed (window);
 +
 +	  if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"))
 +	    gdk_check_wm_desktop_changed (window);
 +	}
 +
 +      if (window_private->event_mask & GDK_PROPERTY_CHANGE_MASK)
 +	{
 +	  event->property.type = GDK_PROPERTY_NOTIFY;
 +	  event->property.window = window;
 +	  event->property.atom = gdk_x11_xatom_to_atom_for_display (display, xevent->xproperty.atom);
 +	  event->property.time = xevent->xproperty.time;
 +	  event->property.state = xevent->xproperty.state;
 +	}
 +      else
 +	return_val = FALSE;
 +
 +      break;
 +
 +    case SelectionClear:
 +      GDK_NOTE (EVENTS,
 +		g_message ("selection clear:\twindow: %ld",
 +			   xevent->xproperty.window));
 +
 +      if (_gdk_selection_filter_clear_event (&xevent->xselectionclear))
 +	{
 +	  event->selection.type = GDK_SELECTION_CLEAR;
 +	  event->selection.window = window;
 +	  event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionclear.selection);
 +	  event->selection.time = xevent->xselectionclear.time;
 +	}
 +      else
 +	return_val = FALSE;
 +
 +      break;
 +
 +    case SelectionRequest:
 +      GDK_NOTE (EVENTS,
 +		g_message ("selection request:\twindow: %ld",
 +			   xevent->xproperty.window));
 +
 +      event->selection.type = GDK_SELECTION_REQUEST;
 +      event->selection.window = window;
 +      event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.selection);
 +      event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.target);
 +      event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselectionrequest.property);
 +      event->selection.requestor = xevent->xselectionrequest.requestor;
 +      event->selection.time = xevent->xselectionrequest.time;
 +
 +      break;
 +
 +    case SelectionNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("selection notify:\twindow: %ld",
 +			   xevent->xproperty.window));
 +
 +      event->selection.type = GDK_SELECTION_NOTIFY;
 +      event->selection.window = window;
 +      event->selection.selection = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.selection);
 +      event->selection.target = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.target);
 +      if (xevent->xselection.property == None)
 +        event->selection.property = GDK_NONE;
 +      else
 +        event->selection.property = gdk_x11_xatom_to_atom_for_display (display, xevent->xselection.property);
 +      event->selection.time = xevent->xselection.time;
 +
 +      break;
 +
 +    case ColormapNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("colormap notify:\twindow: %ld",
 +			   xevent->xcolormap.window));
 +
 +      /* Not currently handled */
 +      return_val = FALSE;
 +      break;
 +
 +    case ClientMessage:
 +      {
 +	GList *tmp_list;
 +	GdkFilterReturn result = GDK_FILTER_CONTINUE;
 +	GdkAtom message_type = gdk_x11_xatom_to_atom_for_display (display, xevent->xclient.message_type);
 +
 +	GDK_NOTE (EVENTS,
 +		  g_message ("client message:\twindow: %ld",
 +			     xevent->xclient.window));
 +
 +	tmp_list = display_x11->client_filters;
 +	while (tmp_list)
 +	  {
 +	    GdkClientFilter *filter = tmp_list->data;
 +	    tmp_list = tmp_list->next;
 +
 +	    if (filter->type == message_type)
 +	      {
 +		result = (*filter->function) (xevent, event, filter->data);
 +		if (result != GDK_FILTER_CONTINUE)
 +		  break;
 +	      }
 +	  }
 +
 +	switch (result)
 +	  {
 +	  case GDK_FILTER_REMOVE:
 +	    return_val = FALSE;
 +	    break;
 +	  case GDK_FILTER_TRANSLATE:
 +	    return_val = TRUE;
 +	    break;
 +	  case GDK_FILTER_CONTINUE:
 +	    /* Send unknown ClientMessage's on to Gtk for it to use */
 +            if (window_private == NULL)
 +              {
 +                return_val = FALSE;
 +              }
 +            else
 +              {
 +                event->client.type = GDK_CLIENT_EVENT;
 +                event->client.window = window;
 +                event->client.message_type = message_type;
 +                event->client.data_format = xevent->xclient.format;
 +                memcpy(&event->client.data, &xevent->xclient.data,
 +                       sizeof(event->client.data));
 +              }
 +            break;
 +          }
 +      }
 +
 +      break;
 +
 +    case MappingNotify:
 +      GDK_NOTE (EVENTS,
 +		g_message ("mapping notify"));
 +
 +      /* Let XLib know that there is a new keyboard mapping.
 +       */
 +      XRefreshKeyboardMapping (&xevent->xmapping);
 +      _gdk_keymap_keys_changed (display);
 +      return_val = FALSE;
 +      break;
 +
 +    default:
 +#ifdef HAVE_XFIXES
 +      if (xevent->type - display_x11->xfixes_event_base == XFixesSelectionNotify)
 +	{
 +	  XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent;
 +
 +	  _gdk_x11_screen_process_owner_change (screen, xevent);
 +	  
 +	  event->owner_change.type = GDK_OWNER_CHANGE;
 +	  event->owner_change.window = window;
 +	  event->owner_change.owner = selection_notify->owner;
 +	  event->owner_change.reason = selection_notify->subtype;
 +	  event->owner_change.selection = 
 +	    gdk_x11_xatom_to_atom_for_display (display, 
 +					       selection_notify->selection);
 +	  event->owner_change.time = selection_notify->timestamp;
 +	  event->owner_change.selection_time = selection_notify->selection_timestamp;
 +	  
 +	  return_val = TRUE;
 +	}
 +      else
 +#endif
 +#ifdef HAVE_RANDR
 +      if (xevent->type - display_x11->xrandr_event_base == RRScreenChangeNotify ||
 +          xevent->type - display_x11->xrandr_event_base == RRNotify)
 +	{
 +          if (screen)
 +            _gdk_x11_screen_size_changed (screen, xevent);
 +	}
 +      else
 +#endif
 +#if defined(HAVE_XCOMPOSITE) && defined (HAVE_XDAMAGE) && defined (HAVE_XFIXES)
 +      if (display_x11->have_xdamage && window_private && window_private->composited &&
 +	  xevent->type == display_x11->xdamage_event_base + XDamageNotify &&
 +	  ((XDamageNotifyEvent *) xevent)->damage == window_impl->damage)
 +	{
 +	  XDamageNotifyEvent *damage_event = (XDamageNotifyEvent *) xevent;
 +	  XserverRegion repair;
 +	  GdkRectangle rect;
 +
 +	  rect.x = window_private->x + damage_event->area.x;
 +	  rect.y = window_private->y + damage_event->area.y;
 +	  rect.width = damage_event->area.width;
 +	  rect.height = damage_event->area.height;
 +
 +	  repair = XFixesCreateRegion (display_x11->xdisplay,
 +				       &damage_event->area, 1);
 +	  XDamageSubtract (display_x11->xdisplay,
 +			   window_impl->damage,
 +			   repair, None);
 +	  XFixesDestroyRegion (display_x11->xdisplay, repair);
 +
 +	  if (window_private->parent != NULL)
 +	    _gdk_window_process_expose (GDK_WINDOW (window_private->parent),
 +					damage_event->serial, &rect);
 +
 +	  return_val = TRUE;
 +	}
 +      else
 +#endif
 +        return_val = FALSE;
 +    }
 +
 + done:
 +  if (return_val)
 +    {
 +      if (event->any.window)
 +	g_object_ref (event->any.window);
 +    }
 +  else
 +    {
 +      /* Mark this event as having no resources to be freed */
 +      event->any.window = NULL;
 +      event->any.type = GDK_NOTHING;
 +    }
 +
 +  if (window)
 +    g_object_unref (window);
 +
 +  return return_val;
 +}
 +
 +static GdkFilterReturn
 +gdk_wm_protocols_filter (GdkXEvent *xev,
 +			 GdkEvent  *event,
 +			 gpointer data)
 +{
 +  XEvent *xevent = (XEvent *)xev;
 +  GdkWindow *win = event->any.window;
 +  GdkDisplay *display;
 +  Atom atom;
 +
 +  if (!win)
 +      return GDK_FILTER_REMOVE;
 +
 +  display = GDK_WINDOW_DISPLAY (win);
 +  atom = (Atom)xevent->xclient.data.l[0];
 +
 +  if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"))
 +    {
 +  /* The delete window request specifies a window
 +   *  to delete. We don't actually destroy the
 +   *  window because "it is only a request". (The
 +   *  window might contain vital data that the
 +   *  program does not want destroyed). Instead
 +   *  the event is passed along to the program,
 +   *  which should then destroy the window.
 +   */
 +      GDK_NOTE (EVENTS,
 +		g_message ("delete window:\t\twindow: %ld",
 +			   xevent->xclient.window));
 +
 +      event->any.type = GDK_DELETE;
 +
 +      gdk_x11_window_set_user_time (win, xevent->xclient.data.l[1]);
 +
 +      return GDK_FILTER_TRANSLATE;
 +    }
 +  else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS"))
 +    {
 +      GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
 +      GdkWindowObject *private = (GdkWindowObject *)win;
 +
 +      /* There is no way of knowing reliably whether we are viewable;
 +       * _gdk_x11_set_input_focus_safe() traps errors asynchronously.
 +       */
 +      if (toplevel && private->accept_focus)
 +	_gdk_x11_set_input_focus_safe (display, toplevel->focus_window,
 +				       RevertToParent,
 +				       xevent->xclient.data.l[1]);
 +
 +      return GDK_FILTER_REMOVE;
 +    }
 +  else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PING") &&
 +	   !_gdk_x11_display_is_root_window (display,
 +					     xevent->xclient.window))
 +    {
 +      XClientMessageEvent xclient = xevent->xclient;
 +
 +      xclient.window = GDK_WINDOW_XROOTWIN (win);
 +      XSendEvent (GDK_WINDOW_XDISPLAY (win),
 +		  xclient.window,
 +		  False,
 +		  SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient);
 +
 +      return GDK_FILTER_REMOVE;
 +    }
 +  else if (atom == gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_SYNC_REQUEST") &&
 +	   GDK_DISPLAY_X11 (display)->use_sync)
 +    {
 +      GdkToplevelX11 *toplevel = _gdk_x11_window_get_toplevel (event->any.window);
 +      if (toplevel)
 +	{
 +#ifdef HAVE_XSYNC
 +	  XSyncIntsToValue (&toplevel->pending_counter_value,
 +			    xevent->xclient.data.l[2],
 +			    xevent->xclient.data.l[3]);
 +#endif
 +	}
 +      return GDK_FILTER_REMOVE;
 +    }
 +
 +  return GDK_FILTER_CONTINUE;
 +}
 +
 +static void
 +_gdk_event_init (GdkDisplay *display)
 +{
 +  GdkDisplayX11 *display_x11;
 +  GdkDeviceManager *device_manager;
 +
 +  display_x11 = GDK_DISPLAY_X11 (display);
 +  display_x11->event_source = gdk_event_source_new (display);
 +
 +  gdk_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
 +                                   GDK_EVENT_TRANSLATOR (display));
 +
 +  device_manager = gdk_device_manager_get_for_display (display);
 +  gdk_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
 +                                   GDK_EVENT_TRANSLATOR (device_manager));
 +
 +  gdk_display_add_client_message_filter (display,
 +					 gdk_atom_intern_static_string ("WM_PROTOCOLS"),
 +					 gdk_wm_protocols_filter,
 +					 NULL);
 +}
 +
 +static void
 +_gdk_input_init (GdkDisplay *display)
 +{
 +  GdkDisplayX11 *display_x11;
 +  GdkDeviceManager *device_manager;
 +  GList *list;
 +
 +  display_x11 = GDK_DISPLAY_X11 (display);
 +  device_manager = gdk_device_manager_get_for_display (display);
 +
 +  /* Add all devices */
 +  display_x11->input_devices = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_MASTER);
 +
 +  list = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_SLAVE);
 +  display_x11->input_devices = g_list_concat (display_x11->input_devices, list);
 +
 +  list = gdk_device_manager_get_devices (device_manager, GDK_DEVICE_TYPE_FLOATING);
 +  display_x11->input_devices = g_list_concat (display_x11->input_devices, list);
 +
 +  /* Now set "core" pointer to the first master device that is a pointer */
 +  list = display_x11->input_devices;
 +
 +  while (list)
 +    {
 +      GdkDevice *device = list->data;
 +      list = list->next;
 +
 +      if (device->source != GDK_SOURCE_MOUSE)
 +        continue;
 +
 +      display->core_pointer = device;
 +      break;
 +    }
 +}
 +
  /**
   * gdk_display_open:
   * @display_name: the name of the display to open



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]