4 #include <gdk/gdkwindow.h>
10 #include "tomboykeybinder.h"
11 #include "tomboyutil.h"
13 /* Uncomment the next line to print a debug trace. */
19 # define TRACE(x) do {} while (FALSE);
23 tomboy_window_get_workspace (GtkWindow *window)
25 GdkWindow *gdkwin = GTK_WIDGET (window)->window;
26 GdkAtom wm_desktop = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
28 gint out_format, out_length;
32 if (!gdk_property_get (gdkwin,
34 _GDK_MAKE_ATOM (XA_CARDINAL),
40 (guchar **) &out_val))
50 tomboy_window_move_to_current_workspace (GtkWindow *window)
52 GdkWindow *gdkwin = GTK_WIDGET (window)->window;
54 gdk_screen_get_root_window (gdk_drawable_get_screen (gdkwin));
56 GdkAtom current_desktop =
57 gdk_atom_intern ("_NET_CURRENT_DESKTOP", FALSE);
58 GdkAtom wm_desktop = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE);
60 gint out_format, out_length;
65 if (!gdk_property_get (rootwin,
67 _GDK_MAKE_ATOM (XA_CARDINAL),
73 (guchar **) &out_val))
79 TRACE (g_print ("Setting _NET_WM_DESKTOP to: %d\n", workspace));
81 xev.xclient.type = ClientMessage;
82 xev.xclient.serial = 0;
83 xev.xclient.send_event = True;
84 xev.xclient.display = GDK_WINDOW_XDISPLAY (gdkwin);
85 xev.xclient.window = GDK_WINDOW_XWINDOW (gdkwin);
86 xev.xclient.message_type =
87 gdk_x11_atom_to_xatom_for_display(
88 gdk_drawable_get_display (gdkwin),
90 xev.xclient.format = 32;
91 xev.xclient.data.l[0] = workspace;
92 xev.xclient.data.l[1] = 0;
93 xev.xclient.data.l[2] = 0;
95 XSendEvent (GDK_WINDOW_XDISPLAY (rootwin),
96 GDK_WINDOW_XWINDOW (rootwin),
98 SubstructureRedirectMask | SubstructureNotifyMask,
103 tomboy_window_override_user_time (GtkWindow *window)
105 guint32 ev_time = gtk_get_current_event_time();
109 * FIXME: Global keypresses use an event filter on the root
110 * window, which processes events before GDK sees them.
112 ev_time = tomboy_keybinder_get_current_event_time ();
115 gint ev_mask = gtk_widget_get_events (GTK_WIDGET(window));
116 if (!(ev_mask & GDK_PROPERTY_CHANGE_MASK)) {
117 gtk_widget_add_events (GTK_WIDGET (window),
118 GDK_PROPERTY_CHANGE_MASK);
122 * NOTE: Last resort for D-BUS or other non-interactive
123 * openings. Causes roundtrip to server. Lame.
125 ev_time = gdk_x11_get_server_time (GTK_WIDGET(window)->window);
128 TRACE (g_print("Setting _NET_WM_USER_TIME to: %d\n", ev_time));
129 gdk_x11_window_set_user_time (GTK_WIDGET(window)->window, ev_time);
133 tomboy_window_present_hardcore (GtkWindow *window)
135 if (!GTK_WIDGET_REALIZED (window))
136 gtk_widget_realize (GTK_WIDGET (window));
137 else if (GTK_WIDGET_VISIBLE (window))
138 tomboy_window_move_to_current_workspace (window);
140 tomboy_window_override_user_time (window);
142 gtk_window_present (window);