gdkevents-fb.c 5.48 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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
 * 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"

#include "gdkkeysyms.h"

#if HAVE_CONFIG_H
#  include <config.h>
#  if STDC_HEADERS
#    include <string.h>
#  endif
#endif

typedef struct _GdkIOClosure GdkIOClosure;
typedef struct _GdkEventPrivate GdkEventPrivate;

#define DOUBLE_CLICK_TIME      250
#define TRIPLE_CLICK_TIME      500
#define DOUBLE_CLICK_DIST      5
#define TRIPLE_CLICK_DIST      5

typedef enum
{
  /* Following flag is set for events on the event queue during
   * translation and cleared afterwards.
   */
  GDK_EVENT_PENDING = 1 << 0
} GdkEventFlags;

struct _GdkIOClosure
{
  GdkInputFunction function;
  GdkInputCondition condition;
  GdkDestroyNotify notify;
  gpointer data;
};

struct _GdkEventPrivate
{
  GdkEvent event;
  guint    flags;
};

/* 
 * Private function declarations
 */

/* Private variable declarations
 */

#if 0
static GList *client_filters;	            /* Filters for client messages */

static GSourceFuncs event_funcs = {
  gdk_event_prepare,
  gdk_event_check,
  gdk_event_dispatch,
  (GDestroyNotify)g_free
};
#endif

/*********************************************
 * Functions for maintaining the event queue *
 *********************************************/

93 94 95 96 97 98 99 100 101 102 103
static gboolean fb_events_prepare  (gpointer  source_data,
				    GTimeVal *current_time,
				    gint     *timeout,
				    gpointer  user_data);
static gboolean fb_events_check    (gpointer  source_data,
				    GTimeVal *current_time,
				    gpointer  user_data);
static gboolean fb_events_dispatch (gpointer  source_data,
				    GTimeVal *dispatch_time,
				    gpointer  user_data);

Elliot Lee's avatar
Elliot Lee committed
104 105 106
void 
gdk_events_init (void)
{
Elliot Lee's avatar
Elliot Lee committed
107 108 109 110 111 112 113
  static GSourceFuncs fb_events_funcs = {
    fb_events_prepare,
    fb_events_check,
    fb_events_dispatch,
    NULL
  };

114
  g_source_add (GDK_PRIORITY_EVENTS, TRUE, &fb_events_funcs, NULL, NULL, NULL);
Elliot Lee's avatar
Elliot Lee committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
}

/*
 *--------------------------------------------------------------
 * 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)
{
136
  return gdk_event_queue_find_first () ? TRUE : FALSE;
Elliot Lee's avatar
Elliot Lee committed
137 138 139 140 141
}

GdkEvent*
gdk_event_get_graphics_expose (GdkWindow *window)
{
Elliot Lee's avatar
Elliot Lee committed
142
  GList *ltmp;
Elliot Lee's avatar
Elliot Lee committed
143 144
  g_return_val_if_fail (window != NULL, NULL);
  
145
  for (ltmp = gdk_queued_events; ltmp; ltmp = ltmp->next)
Elliot Lee's avatar
Elliot Lee committed
146 147
    {
      GdkEvent *event = ltmp->data;
148 149
      if (event->type == GDK_EXPOSE &&
	  event->expose.window == window)
Elliot Lee's avatar
Elliot Lee committed
150 151 152
	break;
    }

153
  if (ltmp)
Elliot Lee's avatar
Elliot Lee committed
154 155 156
    {
      GdkEvent *retval = ltmp->data;

157 158
      gdk_event_queue_remove_link (ltmp);
      g_list_free_1 (ltmp);
Elliot Lee's avatar
Elliot Lee committed
159 160 161 162 163

      return retval;
    }

  return NULL;
Elliot Lee's avatar
Elliot Lee committed
164 165 166 167
}

void
gdk_events_queue (void)
Elliot Lee's avatar
Elliot Lee committed
168 169 170 171
{  
}

static gboolean
172 173 174 175
fb_events_prepare (gpointer  source_data, 
		   GTimeVal *current_time,
		   gint     *timeout,
		   gpointer  user_data)
Elliot Lee's avatar
Elliot Lee committed
176
{
Elliot Lee's avatar
Elliot Lee committed
177 178
  *timeout = -1;

179
  return fb_events_check (source_data, current_time, user_data);
Elliot Lee's avatar
Elliot Lee committed
180 181
}

Elliot Lee's avatar
Elliot Lee committed
182
static gboolean
183 184 185
fb_events_check (gpointer  source_data,
		 GTimeVal *current_time,
		 gpointer  user_data)
Elliot Lee's avatar
Elliot Lee committed
186 187 188
{
  gboolean retval;

189
  GDK_THREADS_ENTER ();
Elliot Lee's avatar
Elliot Lee committed
190 191 192

  retval = (gdk_event_queue_find_first () != NULL);

193
  GDK_THREADS_LEAVE ();
Elliot Lee's avatar
Elliot Lee committed
194 195 196

  return retval;
}
Elliot Lee's avatar
Elliot Lee committed
197 198

static gboolean
199 200 201
fb_events_dispatch (gpointer source_data,
		    GTimeVal *dispatch_time,
		    gpointer user_data)
Elliot Lee's avatar
Elliot Lee committed
202 203 204
{
  GdkEvent *event;

205
  GDK_THREADS_ENTER ();
Elliot Lee's avatar
Elliot Lee committed
206

207
  while ((event = gdk_event_unqueue ()))
Elliot Lee's avatar
Elliot Lee committed
208
    {
209 210 211 212 213 214 215 216 217 218 219 220
      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
221 222
    }

223
  GDK_THREADS_LEAVE ();
Elliot Lee's avatar
Elliot Lee committed
224

Elliot Lee's avatar
Elliot Lee committed
225
  return TRUE;
Elliot Lee's avatar
Elliot Lee committed
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
}

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

257 258
void
gdk_event_send_clientmessage_toall (GdkEvent *sev)
Elliot Lee's avatar
Elliot Lee committed
259 260
{
}