}
}
+#define HAS_FOCUS(window_impl) \
+ ((window_impl)->has_focus || (window_impl)->has_pointer_focus)
+
+static void
+generate_focus_event (GdkWindow *window,
+ gboolean in)
+{
+ GdkEvent event;
+
+ event.type = GDK_FOCUS_CHANGE;
+ event.focus_change.window = window;
+ event.focus_change.send_event = FALSE;
+ event.focus_change.in = in;
+
+ gdk_event_put (&event);
+}
+
static gint
gdk_event_translate (GdkEvent *event,
XEvent *xevent,
GdkWindow *window;
GdkWindowObject *window_private;
+ GdkWindowImplX11 *window_impl = NULL;
static XComposeStatus compose;
KeySym keysym;
int charcount;
}
window = gdk_window_lookup (xevent->xany.window);
- /* FIXME: window might be a GdkPixmap!!! */
-
window_private = (GdkWindowObject *) window;
-
- if (window != NULL)
- gdk_window_ref (window);
if (_gdk_moveresize_window &&
(xevent->xany.type == MotionNotify ||
return FALSE;
}
+ /* FIXME: window might be a GdkPixmap!!! */
+ if (window != NULL)
+ {
+ window_impl = GDK_WINDOW_IMPL_X11 (window_private->impl);
+
+ if (xevent->xany.window != GDK_WINDOW_XID (window))
+ {
+ g_assert (xevent->xany.window == window_impl->focus_window);
+
+ switch (xevent->type)
+ {
+ case KeyPress:
+ case KeyRelease:
+ xevent->xany.window = GDK_WINDOW_XID (window);
+ break;
+ default:
+ return False;
+ }
+ }
+
+ gdk_window_ref (window);
+ }
+
event->any.window = window;
event->any.send_event = xevent->xany.send_event ? TRUE : FALSE;
/* If we get a ButtonPress event where the button is 4 or 5,
it's a Scroll event */
- if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5)
- {
+ switch (xevent->xbutton.button)
+ {
+ case 4: /* up */
+ case 5: /* down */
+ case 6: /* left */
+ case 7: /* right */
event->scroll.type = GDK_SCROLL;
- event->scroll.direction = (xevent->xbutton.button == 4) ?
- GDK_SCROLL_UP : GDK_SCROLL_DOWN;
+
+ if (xevent->xbutton.button == 4)
+ event->scroll.direction = GDK_SCROLL_UP;
+ else if (xevent->xbutton.button == 5)
+ event->scroll.direction = GDK_SCROLL_DOWN;
+ else if (xevent->xbutton.button == 6)
+ event->scroll.direction = GDK_SCROLL_LEFT;
+ else
+ event->scroll.direction = GDK_SCROLL_RIGHT;
+
event->scroll.window = window;
event->scroll.time = xevent->xbutton.x;
event->scroll.x = xevent->xbutton.x + xoffset;
event->scroll.y_root = (gfloat)xevent->xbutton.y_root;
event->scroll.state = (GdkModifierType) xevent->xbutton.state;
event->scroll.device = gdk_core_pointer;
- }
- else
- {
+ break;
+
+ default:
event->button.type = GDK_BUTTON_PRESS;
event->button.window = window;
event->button.time = xevent->xbutton.time;
event->button.device = gdk_core_pointer;
gdk_event_button_generate (event);
+ break;
}
break;
}
/* We treat button presses as scroll wheel events, so ignore the release */
- if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5)
+ if (xevent->xbutton.button == 4 || xevent->xbutton.button == 5 ||
+ xevent->xbutton.button == 6 || xevent->xbutton.button ==7)
{
return_val = FALSE;
break;
xevent->xcrossing.window,
xevent->xcrossing.detail,
xevent->xcrossing.subwindow));
-
+
+ /* Handle focusing (in the case where no window manager is running */
+ if (window &&
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
+ xevent->xcrossing.detail != NotifyInferior &&
+ xevent->xcrossing.focus && !window_impl->has_focus)
+ {
+ gboolean had_focus = HAS_FOCUS (window_impl);
+
+ window_impl->has_pointer_focus = TRUE;
+
+ if (HAS_FOCUS (window_impl) != had_focus)
+ generate_focus_event (window, TRUE);
+ }
+
/* Tell XInput stuff about it if appropriate */
if (window_private &&
!GDK_WINDOW_DESTROYED (window) &&
xevent->xcrossing.window,
xevent->xcrossing.detail, xevent->xcrossing.subwindow));
+ /* Handle focusing (in the case where no window manager is running */
+ if (window &&
+ GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
+ xevent->xcrossing.detail != NotifyInferior &&
+ xevent->xcrossing.focus && !window_impl->has_focus)
+ {
+ gboolean had_focus = HAS_FOCUS (window_impl);
+
+ window_impl->has_pointer_focus = FALSE;
+
+ if (HAS_FOCUS (window_impl) != had_focus)
+ generate_focus_event (window, FALSE);
+ }
+
event->crossing.type = GDK_LEAVE_NOTIFY;
event->crossing.window = window;
break;
- case FocusIn:
- case FocusOut:
/* We only care about focus events that indicate that _this_
* window (not a ancestor or child) got or lost the focus
*/
- switch (xevent->xfocus.detail)
+ case FocusIn:
+ GDK_NOTE (EVENTS,
+ g_message ("focus in:\t\twindow: %ld", xevent->xfocus.window));
+
+ if (window && GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
{
- case NotifyAncestor:
- case NotifyInferior:
- case NotifyNonlinear:
- GDK_NOTE (EVENTS,
- g_message ("focus %s:\t\twindow: %ld",
- (xevent->xany.type == FocusIn) ? "in" : "out",
- xevent->xfocus.window));
+ gboolean had_focus = HAS_FOCUS (window_impl);
+ switch (xevent->xfocus.detail)
+ {
+ case NotifyAncestor:
+ case NotifyNonlinear:
+ case NotifyVirtual:
+ case NotifyNonlinearVirtual:
+ window_impl->has_focus = TRUE;
+ break;
+ case NotifyPointer:
+ window_impl->has_pointer_focus = TRUE;
+ break;
+ case NotifyInferior:
+ case NotifyPointerRoot:
+ case NotifyDetailNone:
+ break;
+ }
+
+ if (HAS_FOCUS (window_impl) != had_focus)
+ generate_focus_event (window, TRUE);
+ }
+ break;
+ case FocusOut:
+ GDK_NOTE (EVENTS,
+ g_message ("focus out:\t\twindow: %ld", xevent->xfocus.window));
+
+ if (window && GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
+ {
+ gboolean had_focus = HAS_FOCUS (window_impl);
+
+ switch (xevent->xfocus.detail)
+ {
+ case NotifyAncestor:
+ case NotifyNonlinear:
+ case NotifyVirtual:
+ case NotifyNonlinearVirtual:
+ window_impl->has_focus = FALSE;
+ break;
+ case NotifyPointer:
+ window_impl->has_pointer_focus = FALSE;
+ break;
+ case NotifyInferior:
+ case NotifyPointerRoot:
+ case NotifyDetailNone:
+ break;
+ }
+
+ if (HAS_FOCUS (window_impl) != had_focus)
+ generate_focus_event (window, FALSE);
+ }
+ break;
+
+#if 0
/* gdk_keyboard_grab() causes following events. These events confuse
* the XIM focus, so ignore them.
*/
if (xevent->xfocus.mode == NotifyGrab ||
xevent->xfocus.mode == NotifyUngrab)
break;
-
- event->focus_change.type = GDK_FOCUS_CHANGE;
- event->focus_change.window = window;
- event->focus_change.in = (xevent->xany.type == FocusIn);
+#endif
- break;
- default:
- return_val = FALSE;
- }
- break;
-
case KeymapNotify:
GDK_NOTE (EVENTS,
g_message ("keymap notify"));
* an unmap, it means we hid the window ourselves, so we
* will have already flipped the iconified bit off.
*/
- if (GDK_WINDOW_IS_MAPPED (window))
+ if (window && GDK_WINDOW_IS_MAPPED (window))
gdk_synthesize_window_state (window,
0,
GDK_WINDOW_STATE_ICONIFIED);
event->any.window = window;
/* Unset iconified if it was set */
- if (((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_ICONIFIED)
+ if (window && (((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_ICONIFIED))
gdk_synthesize_window_state (window,
GDK_WINDOW_STATE_ICONIFIED,
0);
}
else if ((Atom) xevent->xclient.data.l[0] == gdk_wm_take_focus)
{
+ GdkWindow *win = event->any.window;
+ Window focus_win = GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->focus_window;
+
+ /* There is no way of knowing reliably whether we are viewable so we need
+ * to trap errors so we don't cause a BadMatch.
+ */
+ gdk_error_trap_push ();
+ XSetInputFocus (GDK_WINDOW_XDISPLAY (win),
+ focus_win,
+ RevertToParent,
+ xevent->xclient.data.l[1]);
+ XSync (GDK_WINDOW_XDISPLAY (win), False);
+ gdk_error_trap_pop ();
}
else if ((Atom) xevent->xclient.data.l[0] == gdk_atom_intern ("_NET_WM_PING", FALSE))
{
const char *xsettings_name;
const char *gdk_name;
} settings_map[] = {
- { "Net/DoubleClickTime", "double-click-timeout" },
- { "Net/DragThreshold", "drag-threshold" }
+ { "Net/DoubleClickTime", "gtk-double-click-timeout" },
+ { "Net/DragThreshold", "gtk-drag-threshold" },
+ { "Gtk/ColorPalette", "gtk-color-palette" },
+ { "Gtk/ToolbarStyle", "gtk-toolbar-style" },
+ { "Gtk/ToolbarIconSize", "gtk-toolbar-icon-size" },
+ { "Net/CursorBlink", "gtk-cursor-blink" },
+ { "Net/CursorBlinkTime", "gtk-cursor-blink-time" }
};
static void
XSettingsSetting *setting;
gboolean success = FALSE;
gint i;
+ GValue tmp_val = { 0, };
for (i = 0; i < G_N_ELEMENTS (settings_map) ; i++)
if (strcmp (settings_map[i].gdk_name, name) == 0)
case XSETTINGS_TYPE_INT:
if (check_transform (xsettings_name, G_TYPE_INT, G_VALUE_TYPE (value)))
{
- g_value_set_int (value, setting->data.v_int);
+ g_value_init (&tmp_val, G_TYPE_INT);
+ g_value_set_int (&tmp_val, setting->data.v_int);
+ g_value_transform (&tmp_val, value);
+
success = TRUE;
}
break;
case XSETTINGS_TYPE_STRING:
if (check_transform (xsettings_name, G_TYPE_STRING, G_VALUE_TYPE (value)))
{
- g_value_set_string (value, setting->data.v_string);
+ g_value_init (&tmp_val, G_TYPE_STRING);
+ g_value_set_string (&tmp_val, setting->data.v_string);
+ g_value_transform (&tmp_val, value);
+
success = TRUE;
}
break;
{
GdkColor color;
+ g_value_init (&tmp_val, GDK_TYPE_COLOR);
+
color.pixel = 0;
color.red = setting->data.v_color.red;
color.green = setting->data.v_color.green;
color.blue = setting->data.v_color.blue;
- g_value_set_boxed (value, &color);
+ g_value_set_boxed (&tmp_val, &color);
+
+ g_value_transform (&tmp_val, value);
success = TRUE;
}
break;
}
+
+ g_value_unset (&tmp_val);
xsettings_setting_free (setting);