gtk2/gdk/linux-fb/gdkevents-fb.c

211 lines
4.5 KiB
C
Raw Normal View History

2000-05-31 21:50:38 +00:00
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
2000-05-31 21:50:38 +00:00
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
2000-05-31 21:50:38 +00:00
*
* You should have received a copy of the GNU Lesser General Public
2000-05-31 21:50:38 +00:00
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
2000-05-31 21:50:38 +00:00
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "gdk.h"
#include "gdkprivate-fb.h"
#include "gdkinternals.h"
#include "gdkfb.h"
/*********************************************
* Functions for maintaining the event queue *
*********************************************/
static gboolean fb_events_prepare (GSource *source,
gint *timeout);
static gboolean fb_events_check (GSource *source);
static gboolean fb_events_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data);
static GSourceFuncs fb_events_funcs = {
fb_events_prepare,
fb_events_check,
fb_events_dispatch,
NULL
};
i2000-11-22 Alexander Larsson <alexl@redhat.com> * gdk/gdktypes.h: Add new type GdkSpan * docs/reference/gdk/gdk-sections.txt, docs/reference/gdk/tmpl/regions.sgml, gdk/gdkregion-generic.c, gdk/gdkregion.h: Implement and document gdk_region_spans_intersect_foreach. * gdk/linux-fb/Makefile.am, gdk/linux-fb/gdkrender-fb.c: Add new file gdkrender-fb.c which contains all core rendering code. Add gdk_fb_fill_rectangle_generic (old rectangle code) and gdk_fb_fill_rectangle_simple_16, gdk_fb_fill_rectangle_simple_32 (optimized rectangle fillers). * gdk/linux-fb/gdkdrawable-fb2.c: Move all rendering code to gdkrender-fb.c. Change from using GdkRectangles and GdkSegments for spans to GdkSpan. Use the new span intersection functions in gdk_fb_fill_spans. gdk_fb_draw_rectangle() clips filled rectangles and calls gc->fill_rectangle with the result. gdk_fb_fill_spans() gets extra argument "sorted". * gdk/linux-fb/gdkevents-fb.c: Remove unused includes and defines. New function gdk_fb_get_time() to get correct time for events. * gdk/linux-fb/gdkinput-ps2.c: Use gdk method of generating multiple-clicks (gdk_event_button_generate) Make sure to set the time of all events. * gdk/linux-fb/gdkmain-fb.c: Use gdk_fb_get_time (). * gdk/linux-fb/gdkprivate-fb.h: New virtual GC calls: fill_span & fill_rectangle. Export gdk_fb_get_time(). gdk_fb_fill_spans() gets extra argument "sorted". * gdk/linux-fb/mi*.c: Use GdkSpan instead of GdkRectangle. Pass correct sorted to gdk_fb_fill_spans. (sorted value taken from XFree 4 source)
2000-11-22 10:07:34 +00:00
guint32
gdk_fb_get_time(void)
{
GTimeVal tv;
g_get_current_time (&tv);
return (guint32) tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
2000-05-31 21:50:38 +00:00
void
gdk_events_init (void)
{
GSource *source;
source = g_source_new (&fb_events_funcs, sizeof (GSource));
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
g_source_set_can_recurse (source, TRUE);
g_source_attach (source, NULL);
2000-05-31 21:50:38 +00:00
}
/*
*--------------------------------------------------------------
* gdk_events_pending
*
* Returns if events are pending on the queue.
*
* Arguments:
*
* Results:
* Returns TRUE if events are pending
*
* Side effects:
*
*--------------------------------------------------------------
*/
gboolean
gdk_events_pending (void)
{
return gdk_event_queue_find_first () ? TRUE : FALSE;
2000-05-31 21:50:38 +00:00
}
GdkEvent*
gdk_event_get_graphics_expose (GdkWindow *window)
{
2000-06-20 20:20:38 +00:00
GList *ltmp;
2000-05-31 21:50:38 +00:00
g_return_val_if_fail (window != NULL, NULL);
for (ltmp = gdk_queued_events; ltmp; ltmp = ltmp->next)
2000-06-20 20:20:38 +00:00
{
GdkEvent *event = ltmp->data;
if (event->type == GDK_EXPOSE &&
event->expose.window == window)
2000-06-20 20:20:38 +00:00
break;
}
if (ltmp)
2000-06-20 20:20:38 +00:00
{
GdkEvent *retval = ltmp->data;
gdk_event_queue_remove_link (ltmp);
g_list_free_1 (ltmp);
2000-06-20 20:20:38 +00:00
return retval;
}
return NULL;
2000-05-31 21:50:38 +00:00
}
void
gdk_events_queue (void)
2000-06-20 20:20:38 +00:00
{
}
static gboolean
fb_events_prepare (GSource *source,
gint *timeout)
2000-05-31 21:50:38 +00:00
{
2000-06-20 20:20:38 +00:00
*timeout = -1;
return fb_events_check (source);
2000-05-31 21:50:38 +00:00
}
2000-06-20 20:20:38 +00:00
static gboolean
fb_events_check (GSource *source)
2000-06-20 20:20:38 +00:00
{
gboolean retval;
GDK_THREADS_ENTER ();
2000-06-20 20:20:38 +00:00
retval = (gdk_event_queue_find_first () != NULL);
GDK_THREADS_LEAVE ();
2000-06-20 20:20:38 +00:00
return retval;
}
2000-05-31 21:50:38 +00:00
static gboolean
fb_events_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
2000-05-31 21:50:38 +00:00
{
GdkEvent *event;
GDK_THREADS_ENTER ();
2000-05-31 21:50:38 +00:00
while ((event = gdk_event_unqueue ()))
2000-05-31 21:50:38 +00:00
{
if (event->type == GDK_EXPOSE &&
event->expose.window == gdk_parent_root)
gdk_window_clear_area (event->expose.window,
event->expose.area.x,
event->expose.area.y,
event->expose.area.width,
event->expose.area.height);
else if (gdk_event_func)
(*gdk_event_func) (event, gdk_event_data);
gdk_event_free (event);
2000-05-31 21:50:38 +00:00
}
GDK_THREADS_LEAVE ();
2000-05-31 21:50:38 +00:00
2000-06-20 20:20:38 +00:00
return TRUE;
2000-05-31 21:50:38 +00:00
}
/*
*--------------------------------------------------------------
* gdk_flush
*
* Flushes the Xlib output buffer and then waits
* until all requests have been received and processed
* by the X server. The only real use for this function
* is in dealing with XShm.
*
* Arguments:
*
* Results:
*
* Side effects:
*
*--------------------------------------------------------------
*/
void
gdk_flush (void)
{
}
gboolean
gdk_event_send_client_message (GdkEvent *event, guint32 xid)
{
return FALSE;
}
void
gdk_event_send_clientmessage_toall (GdkEvent *sev)
2000-05-31 21:50:38 +00:00
{
}