Commit ed521b3c authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Add gdk_screen_set_screen()/_get_screen() which (by evil hacks) work for

Wed Oct  2 17:36:42 2002  Owen Taylor  <otaylor@redhat.com>

        * gdk/gdkevents.[ch] gdk/x11/gdkevents-x11.[ch]: Add
        gdk_screen_set_screen()/_get_screen() which (by evil
        hacks) work for for heap allocated events and
        fall back gracefully for stack allocated events.
parent acbe4f18
Wed Oct 2 17:36:42 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.[ch] gdk/x11/gdkevents-x11.c: Add
gdk_screen_set_screen()/_get_screen() which (by evil
hacks) work for for heap allocated events and
fall back gracefully for stack allocated events.
Wed Oct 2 08:47:31 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtksettings.[ch]: Privately export:
......
Wed Oct 2 17:36:42 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.[ch] gdk/x11/gdkevents-x11.c: Add
gdk_screen_set_screen()/_get_screen() which (by evil
hacks) work for for heap allocated events and
fall back gracefully for stack allocated events.
Wed Oct 2 08:47:31 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtksettings.[ch]: Privately export:
......
Wed Oct 2 17:36:42 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.[ch] gdk/x11/gdkevents-x11.c: Add
gdk_screen_set_screen()/_get_screen() which (by evil
hacks) work for for heap allocated events and
fall back gracefully for stack allocated events.
Wed Oct 2 08:47:31 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtksettings.[ch]: Privately export:
......
Wed Oct 2 17:36:42 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.[ch] gdk/x11/gdkevents-x11.c: Add
gdk_screen_set_screen()/_get_screen() which (by evil
hacks) work for for heap allocated events and
fall back gracefully for stack allocated events.
Wed Oct 2 08:47:31 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtksettings.[ch]: Privately export:
......
Wed Oct 2 17:36:42 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.[ch] gdk/x11/gdkevents-x11.c: Add
gdk_screen_set_screen()/_get_screen() which (by evil
hacks) work for for heap allocated events and
fall back gracefully for stack allocated events.
Wed Oct 2 08:47:31 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtksettings.[ch]: Privately export:
......
Wed Oct 2 17:36:42 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkevents.[ch] gdk/x11/gdkevents-x11.c: Add
gdk_screen_set_screen()/_get_screen() which (by evil
hacks) work for for heap allocated events and
fall back gracefully for stack allocated events.
Wed Oct 2 08:47:31 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtksettings.[ch]: Privately export:
......
......@@ -256,6 +256,7 @@ gdk_event_put (GdkEvent *event)
}
static GMemChunk *event_chunk = NULL;
static GHashTable *event_hash = NULL;
GdkEvent*
_gdk_event_new (void)
......@@ -263,17 +264,30 @@ _gdk_event_new (void)
GdkEventPrivate *new_event;
if (event_chunk == NULL)
event_chunk = g_mem_chunk_new ("events",
sizeof (GdkEventPrivate),
4096,
G_ALLOC_AND_FREE);
{
event_chunk = g_mem_chunk_new ("events",
sizeof (GdkEventPrivate),
4096,
G_ALLOC_AND_FREE);
event_hash = g_hash_table_new (g_direct_hash, NULL);
}
new_event = g_chunk_new (GdkEventPrivate, event_chunk);
new_event->flags = 0;
new_event->screen = NULL;
g_hash_table_insert (event_hash, new_event, GUINT_TO_POINTER (1));
return (GdkEvent*) new_event;
}
static gboolean
gdk_event_is_allocated (GdkEvent *event)
{
if (event_hash)
return g_hash_table_lookup (event_hash, event) != NULL;
}
/**
* gdk_event_copy:
* @event: a #GdkEvent
......@@ -399,7 +413,8 @@ gdk_event_free (GdkEvent *event)
default:
break;
}
g_hash_table_remove (event_chunk, event);
g_mem_chunk_free (event_chunk, event);
}
......@@ -738,6 +753,59 @@ gdk_event_get_axis (GdkEvent *event,
return gdk_device_get_axis (device, axes, axis_use, value);
}
/**
* gdk_event_set_screen:
* @event: a #GdkEvent
* @screen: a #GdkScreen
*
* Sets the screen for @event to @screen. The event must
* have been allocated by GTK+, for instance, by
* gdk_event_copy().
**/
void
gdk_event_set_screen (GdkEvent *event,
GdkScreen *screen)
{
GdkEventPrivate *private;
g_return_if_fail (gdk_event_is_allocated (event));
private = (GdkEventPrivate *)event;
private->screen = screen;
}
/**
* gdk_event_get_screen:
* @event: a #GdkEvent
*
* Returns the screen for the event. The screen is
* typically the screen for event->any.window, but
* for events such as mouse events, it is the screen
* where the the pointer was when the event occurs -
* that is, the screen which has the root window
* to which event->motion.x_root and
* event->motion.y_root are relative.
*
* Return value: the screen for the event
**/
GdkScreen *
gdk_event_get_screen (GdkEvent *event)
{
if (gdk_event_is_allocated (event))
{
GdkEventPrivate *private = (GdkEventPrivate *)event;
if (private->screen)
return private->screen;
}
if (event->any.window)
return gdk_drawable_get_screen (event->any.window);
return NULL;
}
/**
* gdk_set_show_events:
* @show_events: %TRUE to output event debugging information.
......
......@@ -470,6 +470,10 @@ void gdk_event_handler_set (GdkEventFunc func,
gpointer data,
GDestroyNotify notify);
void gdk_event_set_screen (GdkEvent *event,
GdkScreen *screen);
GdkScreen *gdk_event_get_screen (GdkEvent *event);
void gdk_set_show_events (gboolean show_events);
gboolean gdk_get_show_events (void);
......
......@@ -499,6 +499,19 @@ generate_focus_event (GdkWindow *window,
gdk_event_put (&event);
}
static void
set_screen_from_root (GdkDisplay *display,
GdkEvent *event,
Window xrootwin)
{
GdkScreen *screen;
screen = _gdk_x11_display_screen_for_xrootwin (display, xrootwin);
g_assert (screen);
gdk_event_set_screen (event, screen);
}
static gboolean
gdk_event_translate (GdkDisplay *display,
GdkEvent *event,
......@@ -817,6 +830,9 @@ gdk_event_translate (GdkDisplay *display,
event->scroll.y_root = (gfloat)xevent->xbutton.y_root;
event->scroll.state = (GdkModifierType) xevent->xbutton.state;
event->scroll.device = display->core_pointer;
set_screen_from_root (display, event, xevent->xbutton.root);
break;
default:
......@@ -832,6 +848,8 @@ gdk_event_translate (GdkDisplay *display,
event->button.button = xevent->xbutton.button;
event->button.device = display->core_pointer;
set_screen_from_root (display, event, xevent->xbutton.root);
_gdk_event_button_generate (display, event);
break;
}
......@@ -872,6 +890,8 @@ gdk_event_translate (GdkDisplay *display,
event->button.state = (GdkModifierType) xevent->xbutton.state;
event->button.button = xevent->xbutton.button;
event->button.device = display->core_pointer;
set_screen_from_root (display, event, xevent->xbutton.root);
break;
......@@ -902,6 +922,8 @@ gdk_event_translate (GdkDisplay *display,
event->motion.is_hint = xevent->xmotion.is_hint;
event->motion.device = display->core_pointer;
set_screen_from_root (display, event, xevent->xmotion.root);
break;
case EnterNotify:
......@@ -954,6 +976,8 @@ gdk_event_translate (GdkDisplay *display,
event->crossing.x_root = xevent->xcrossing.x_root;
event->crossing.y_root = xevent->xcrossing.y_root;
set_screen_from_root (display, event, xevent->xcrossing.root);
/* Translate the crossing mode into Gdk terms.
*/
switch (xevent->xcrossing.mode)
......@@ -1041,6 +1065,8 @@ gdk_event_translate (GdkDisplay *display,
event->crossing.x_root = xevent->xcrossing.x_root;
event->crossing.y_root = xevent->xcrossing.y_root;
set_screen_from_root (display, event, xevent->xcrossing.root);
/* Translate the crossing mode into Gdk terms.
*/
switch (xevent->xcrossing.mode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment