gdkevents-fb.c 4.46 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4
/* 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
5
 * modify it under the terms of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
6 7 8 9 10 11
 * 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
12
 * Lesser General Public License for more details.
Elliot Lee's avatar
Elliot Lee committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
15 16 17 18 19 20
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/*
21
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
Elliot Lee's avatar
Elliot Lee committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35
 * 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 *
 *********************************************/

36 37 38 39 40 41 42 43 44 45 46 47 48
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
};
49

50 51 52 53 54 55 56 57 58
guint32
gdk_fb_get_time(void)
{
  GTimeVal tv;

  g_get_current_time (&tv);
  return (guint32) tv.tv_sec * 1000 + tv.tv_usec / 1000;
}

Elliot Lee's avatar
Elliot Lee committed
59 60 61
void 
gdk_events_init (void)
{
62 63 64 65 66 67 68
  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);
Elliot Lee's avatar
Elliot Lee committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
}

/*
 *--------------------------------------------------------------
 * 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)
{
90
  return gdk_event_queue_find_first () ? TRUE : FALSE;
Elliot Lee's avatar
Elliot Lee committed
91 92 93 94 95
}

GdkEvent*
gdk_event_get_graphics_expose (GdkWindow *window)
{
Elliot Lee's avatar
Elliot Lee committed
96
  GList *ltmp;
Elliot Lee's avatar
Elliot Lee committed
97 98
  g_return_val_if_fail (window != NULL, NULL);
  
99
  for (ltmp = gdk_queued_events; ltmp; ltmp = ltmp->next)
Elliot Lee's avatar
Elliot Lee committed
100 101
    {
      GdkEvent *event = ltmp->data;
102 103
      if (event->type == GDK_EXPOSE &&
	  event->expose.window == window)
Elliot Lee's avatar
Elliot Lee committed
104 105 106
	break;
    }

107
  if (ltmp)
Elliot Lee's avatar
Elliot Lee committed
108 109 110
    {
      GdkEvent *retval = ltmp->data;

111 112
      gdk_event_queue_remove_link (ltmp);
      g_list_free_1 (ltmp);
Elliot Lee's avatar
Elliot Lee committed
113 114 115 116 117

      return retval;
    }

  return NULL;
Elliot Lee's avatar
Elliot Lee committed
118 119 120 121
}

void
gdk_events_queue (void)
Elliot Lee's avatar
Elliot Lee committed
122 123 124 125
{  
}

static gboolean
126 127
fb_events_prepare (GSource    *source,
		   gint       *timeout)
Elliot Lee's avatar
Elliot Lee committed
128
{
Elliot Lee's avatar
Elliot Lee committed
129 130
  *timeout = -1;

131
  return fb_events_check (source);
Elliot Lee's avatar
Elliot Lee committed
132 133
}

Elliot Lee's avatar
Elliot Lee committed
134
static gboolean
135
fb_events_check (GSource    *source)
Elliot Lee's avatar
Elliot Lee committed
136 137 138
{
  gboolean retval;

139
  GDK_THREADS_ENTER ();
Elliot Lee's avatar
Elliot Lee committed
140 141 142

  retval = (gdk_event_queue_find_first () != NULL);

143
  GDK_THREADS_LEAVE ();
Elliot Lee's avatar
Elliot Lee committed
144 145 146

  return retval;
}
Elliot Lee's avatar
Elliot Lee committed
147 148

static gboolean
149 150 151
fb_events_dispatch (GSource  *source,
		    GSourceFunc callback,
		    gpointer  user_data)
Elliot Lee's avatar
Elliot Lee committed
152 153 154
{
  GdkEvent *event;

155
  GDK_THREADS_ENTER ();
Elliot Lee's avatar
Elliot Lee committed
156

157
  while ((event = gdk_event_unqueue ()))
Elliot Lee's avatar
Elliot Lee committed
158
    {
159 160 161 162 163 164 165 166 167 168 169 170
      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);
Elliot Lee's avatar
Elliot Lee committed
171 172
    }

173
  GDK_THREADS_LEAVE ();
Elliot Lee's avatar
Elliot Lee committed
174

Elliot Lee's avatar
Elliot Lee committed
175
  return TRUE;
Elliot Lee's avatar
Elliot Lee committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
}

/*
 *--------------------------------------------------------------
 * 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;
}

207 208
void
gdk_event_send_clientmessage_toall (GdkEvent *sev)
Elliot Lee's avatar
Elliot Lee committed
209 210
{
}