summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorElliot Lee <sopwith@src.gnome.org>1998-03-01 22:37:30 +0000
committerElliot Lee <sopwith@src.gnome.org>1998-03-01 22:37:30 +0000
commit3fb589b2ff76843d840e98ad90de186f43fc2893 (patch)
treeac70f161246782e46784b4bbc9dfdaee2b4f3db9 /gdk
parentb7056ea129d99af0ff4e525b736e2a9e801beb95 (diff)
downloadgtk+-3fb589b2ff76843d840e98ad90de186f43fc2893.tar.gz
Add drag_end_event for future expansion, plus allow passing in NULL to the gdk filter stuff to get events without a window in our app
Diffstat (limited to 'gdk')
-rw-r--r--gdk/gdk.c31
-rw-r--r--gdk/gdkglobals.c4
-rw-r--r--gdk/gdkprivate.h2
-rw-r--r--gdk/gdkwindow.c29
-rw-r--r--gdk/x11/gdkglobals-x11.c4
-rw-r--r--gdk/x11/gdkmain-x11.c31
-rw-r--r--gdk/x11/gdkwindow-x11.c29
7 files changed, 82 insertions, 48 deletions
diff --git a/gdk/gdk.c b/gdk/gdk.c
index ead5c99281..b966b85225 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -1701,24 +1701,27 @@ gdk_event_translate (GdkEvent *event,
window = gdk_window_lookup (xevent->xany.window);
window_private = (GdkWindowPrivate *) window;
- if (window == NULL)
- g_warning ("%#lx -> NULL\n", xevent->xany.window);
- else
+ if (window != NULL)
gdk_window_ref (window);
-
+ else if(gdk_null_window_warnings) /* Special purpose programs that
+ get events for other windows may
+ want to disable this */
+ g_warning ("%#lx -> NULL\n", xevent->xany.window);
/* Check for filters for this window */
- if (window_private)
- {
- GdkFilterReturn result;
- result = gdk_event_apply_filters (xevent, event, window_private->filters);
-
- if (result != GDK_FILTER_CONTINUE)
- {
- return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
- }
- }
+ {
+ GdkFilterReturn result;
+ result = gdk_event_apply_filters (xevent, event,
+ window_private
+ ?window_private->filters
+ :default_filters);
+
+ if (result != GDK_FILTER_CONTINUE)
+ {
+ return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
+ }
+ }
/* We do a "manual" conversion of the XEvent to a
* GdkEvent. The structures are mostly the same so
diff --git a/gdk/gdkglobals.c b/gdk/gdkglobals.c
index 4060b567df..d3c967860b 100644
--- a/gdk/gdkglobals.c
+++ b/gdk/gdkglobals.c
@@ -47,4 +47,6 @@ GdkDndGlobals gdk_dnd = {None,None,None,
gchar *gdk_progname = NULL;
gchar *gdk_progclass = NULL;
gint gdk_error_code;
-gint gdk_error_warnings = TRUE;
+gboolean gdk_error_warnings = TRUE;
+gboolean gdk_null_window_warnings = TRUE;
+GList *default_filters = NULL;
diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h
index e205241aeb..9201b9d1c6 100644
--- a/gdk/gdkprivate.h
+++ b/gdk/gdkprivate.h
@@ -250,6 +250,8 @@ extern gchar *gdk_progname;
extern gchar *gdk_progclass;
extern gint gdk_error_code;
extern gint gdk_error_warnings;
+extern gboolean gdk_null_window_warnings;
+extern GList *default_filters;
/* Debugging support */
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 61d02b1f05..1e644fc68b 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -1475,13 +1475,15 @@ gdk_window_add_filter (GdkWindow *window,
GList *tmp_list;
GdkEventFilter *filter;
- g_return_if_fail (window != NULL);
-
private = (GdkWindowPrivate*) window;
- if (private->destroyed)
+ if (private && private->destroyed)
return;
- tmp_list = private->filters;
+ if(private)
+ tmp_list = private->filters;
+ else
+ tmp_list = default_filters;
+
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
@@ -1493,8 +1495,11 @@ gdk_window_add_filter (GdkWindow *window,
filter = g_new (GdkEventFilter, 1);
filter->function = function;
filter->data = data;
-
- private->filters = g_list_append (private->filters, filter);
+
+ if(private)
+ private->filters = g_list_append (private->filters, filter);
+ else
+ default_filters = g_list_append (default_filters, filter);
}
void
@@ -1506,10 +1511,13 @@ gdk_window_remove_filter (GdkWindow *window,
GList *tmp_list;
GdkEventFilter *filter;
- g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
- tmp_list = private->filters;
+ if(private)
+ tmp_list = private->filters;
+ else
+ tmp_list = default_filters;
+
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
@@ -1517,7 +1525,10 @@ gdk_window_remove_filter (GdkWindow *window,
if ((filter->function == function) && (filter->data == data))
{
- private->filters = g_list_remove_link (private->filters, tmp_list);
+ if(private)
+ private->filters = g_list_remove_link (private->filters, tmp_list);
+ else
+ default_filters = g_list_remove_link (default_filters, tmp_list);
g_list_free_1 (tmp_list);
g_free (filter);
diff --git a/gdk/x11/gdkglobals-x11.c b/gdk/x11/gdkglobals-x11.c
index 4060b567df..d3c967860b 100644
--- a/gdk/x11/gdkglobals-x11.c
+++ b/gdk/x11/gdkglobals-x11.c
@@ -47,4 +47,6 @@ GdkDndGlobals gdk_dnd = {None,None,None,
gchar *gdk_progname = NULL;
gchar *gdk_progclass = NULL;
gint gdk_error_code;
-gint gdk_error_warnings = TRUE;
+gboolean gdk_error_warnings = TRUE;
+gboolean gdk_null_window_warnings = TRUE;
+GList *default_filters = NULL;
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index ead5c99281..b966b85225 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -1701,24 +1701,27 @@ gdk_event_translate (GdkEvent *event,
window = gdk_window_lookup (xevent->xany.window);
window_private = (GdkWindowPrivate *) window;
- if (window == NULL)
- g_warning ("%#lx -> NULL\n", xevent->xany.window);
- else
+ if (window != NULL)
gdk_window_ref (window);
-
+ else if(gdk_null_window_warnings) /* Special purpose programs that
+ get events for other windows may
+ want to disable this */
+ g_warning ("%#lx -> NULL\n", xevent->xany.window);
/* Check for filters for this window */
- if (window_private)
- {
- GdkFilterReturn result;
- result = gdk_event_apply_filters (xevent, event, window_private->filters);
-
- if (result != GDK_FILTER_CONTINUE)
- {
- return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
- }
- }
+ {
+ GdkFilterReturn result;
+ result = gdk_event_apply_filters (xevent, event,
+ window_private
+ ?window_private->filters
+ :default_filters);
+
+ if (result != GDK_FILTER_CONTINUE)
+ {
+ return (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
+ }
+ }
/* We do a "manual" conversion of the XEvent to a
* GdkEvent. The structures are mostly the same so
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 61d02b1f05..1e644fc68b 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -1475,13 +1475,15 @@ gdk_window_add_filter (GdkWindow *window,
GList *tmp_list;
GdkEventFilter *filter;
- g_return_if_fail (window != NULL);
-
private = (GdkWindowPrivate*) window;
- if (private->destroyed)
+ if (private && private->destroyed)
return;
- tmp_list = private->filters;
+ if(private)
+ tmp_list = private->filters;
+ else
+ tmp_list = default_filters;
+
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
@@ -1493,8 +1495,11 @@ gdk_window_add_filter (GdkWindow *window,
filter = g_new (GdkEventFilter, 1);
filter->function = function;
filter->data = data;
-
- private->filters = g_list_append (private->filters, filter);
+
+ if(private)
+ private->filters = g_list_append (private->filters, filter);
+ else
+ default_filters = g_list_append (default_filters, filter);
}
void
@@ -1506,10 +1511,13 @@ gdk_window_remove_filter (GdkWindow *window,
GList *tmp_list;
GdkEventFilter *filter;
- g_return_if_fail (window != NULL);
private = (GdkWindowPrivate*) window;
- tmp_list = private->filters;
+ if(private)
+ tmp_list = private->filters;
+ else
+ tmp_list = default_filters;
+
while (tmp_list)
{
filter = (GdkEventFilter *)tmp_list->data;
@@ -1517,7 +1525,10 @@ gdk_window_remove_filter (GdkWindow *window,
if ((filter->function == function) && (filter->data == data))
{
- private->filters = g_list_remove_link (private->filters, tmp_list);
+ if(private)
+ private->filters = g_list_remove_link (private->filters, tmp_list);
+ else
+ default_filters = g_list_remove_link (default_filters, tmp_list);
g_list_free_1 (tmp_list);
g_free (filter);