diff options
author | Ray Strode <rstrode@redhat.com> | 2007-05-06 00:24:06 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2007-05-06 00:24:06 -0400 |
commit | e3aa16afa3e6a6809ab70a95b841ecb36b42e0dd (patch) | |
tree | 451cb0a1647ed974468e9d88ca048a9f420ceaa0 /src/pop-demo.c | |
parent | d69c13a8fe92356a516704853b6b5d2faa3e1fb6 (diff) |
Fix up formatting
Run source code through "uncrustify"
Diffstat (limited to 'src/pop-demo.c')
-rw-r--r-- | src/pop-demo.c | 223 |
1 files changed, 142 insertions, 81 deletions
diff --git a/src/pop-demo.c b/src/pop-demo.c index ecb6ffb..75f7825 100644 --- a/src/pop-demo.c +++ b/src/pop-demo.c @@ -38,16 +38,20 @@ composite_is_available (void) event_base = 0; error_base = 0; if (XCompositeQueryExtension (GDK_DISPLAY (), &event_base, &error_base)) - return TRUE; + { + return TRUE; + } return FALSE; } static gboolean initialize_damage_extension (void) { - if (XDamageQueryExtension (GDK_DISPLAY (), &damage_extension_event_base, + if (XDamageQueryExtension (GDK_DISPLAY (), &damage_extension_event_base, &damage_extension_error_base)) + { return TRUE; + } return FALSE; } @@ -57,24 +61,27 @@ initialize_shape_extension (void) { if (XShapeQueryExtension (GDK_DISPLAY (), &shape_extension_event_base, &shape_extension_error_base)) + { return TRUE; + } return FALSE; } gint -window_compare (PopWindowView *view, - Window *x_window_id) +window_compare (PopWindowView *view, + Window *x_window_id) { - GdkWindow *window; - if (!POP_IS_WINDOW_VIEW (view)) - { - g_warning ("passed invalid data to compare func: %p\n", view); - return -1; - } - - window = pop_window_view_get_window (view); - return ((gulong) GDK_WINDOW_XWINDOW (window)) - *x_window_id; + GdkWindow *window; + + if (!POP_IS_WINDOW_VIEW (view)) + { + g_warning ("passed invalid data to compare func: %p\n", view); + return -1; + } + + window = pop_window_view_get_window (view); + return ((gulong) GDK_WINDOW_XWINDOW (window)) - *x_window_id; } static void @@ -83,9 +90,11 @@ remove_window_from_list (GdkWindow *window) PopWindowView *view; view = g_object_get_data (G_OBJECT (window), "pop-window-view"); - + if (view == NULL) - return; + { + return; + } g_assert (POP_IS_WINDOW_VIEW (view)); @@ -119,7 +128,9 @@ add_window_to_list (GdkWindow *window) PopWindowView *view; if (window == GTK_WIDGET (overlay_window)->window) - return; + { + return; + } { Window parent, root, *children; guint number_of_children, i; @@ -128,18 +139,25 @@ add_window_to_list (GdkWindow *window) if (!XQueryTree (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (window), &root, &parent, &children, &number_of_children)) - return; + { + return; + } if (gdk_error_trap_pop ()) - return; + { + return; + } for (i = 0; i < number_of_children; i++) - { - if (children[i] == GDK_WINDOW_XWINDOW (GTK_WIDGET (overlay_window)->window)) + if (children[i] == + GDK_WINDOW_XWINDOW (GTK_WIDGET (overlay_window)->window)) + { break; - } + } XFree (children); if (i != number_of_children) - return; + { + return; + } } view = pop_window_view_new (); @@ -149,7 +167,7 @@ add_window_to_list (GdkWindow *window) GDK_WINDOW_XWINDOW (window)); return; } - + g_object_ref (G_OBJECT (window)); g_object_set_data (G_OBJECT (window), "pop-window-view", g_object_ref (view)); } @@ -171,7 +189,9 @@ view_subtract_overlapping_region (PopWindowStack *stack, above_view = g_object_get_data (G_OBJECT (above_window), "pop-window-view"); if (!POP_IS_WINDOW_VIEW (above_view)) - return; + { + return; + } view = g_object_get_data (G_OBJECT (window), "pop-window-view"); g_assert (POP_IS_WINDOW_VIEW (view)); @@ -181,13 +201,14 @@ view_subtract_overlapping_region (PopWindowStack *stack, g_assert (difference != NULL); if (*visible_region == NULL) - *visible_region = difference; - else + { + *visible_region = difference; + } + else { gdk_region_intersect (*visible_region, difference); gdk_region_destroy (difference); } - } static GdkRegion * @@ -209,7 +230,9 @@ get_view_visible_region (PopWindowStack *stack, view_subtract_overlapping_region, &visible_region); if (visible_region == NULL) - visible_region = gdk_region_new (); + { + visible_region = gdk_region_new (); + } return visible_region; } @@ -225,8 +248,10 @@ draw_window_from_stack (PopWindowStack *stack, view = g_object_get_data (G_OBJECT (window), "pop-window-view"); if (view == NULL) - return; - + { + return; + } + g_assert (POP_IS_WINDOW_VIEW (view)); #if 0 @@ -235,13 +260,13 @@ draw_window_from_stack (PopWindowStack *stack, if (!gdk_region_empty (visible_region)) { #endif - cairo_save (cairo_context); - pop_window_view_render_to_context (view, cairo_context); - cairo_restore (cairo_context); + cairo_save (cairo_context); + pop_window_view_render_to_context (view, cairo_context); + cairo_restore (cairo_context); #if 0 - } +} - gdk_region_destroy (visible_region); +gdk_region_destroy (visible_region); #endif } @@ -249,10 +274,12 @@ static void draw_windows (cairo_t *cairo_context) { if (!pop_window_stack_is_ready (stack)) - return; + { + return; + } - pop_window_stack_foreach (stack, - (PopWindowStackForeachFunc) + pop_window_stack_foreach (stack, + (PopWindowStackForeachFunc) draw_window_from_stack, cairo_context); } @@ -274,18 +301,21 @@ on_expose_event (GtkWidget *widget, screen = gtk_widget_get_screen (widget); gdk_screen_get_monitor_geometry (screen, - gdk_screen_get_monitor_at_window (screen, widget->window), &monitor_area); + gdk_screen_get_monitor_at_window (screen, + widget-> + window), + &monitor_area); x_scale_factor = widget->allocation.width / ((double) monitor_area.width); y_scale_factor = widget->allocation.height / ((double) monitor_area.height); cairo_context = gdk_cairo_create (widget->window); - //cairo_scale (cairo_context, x_scale_factor, y_scale_factor); - //cairo_set_source_rgb (cairo_context, 0.5, 0.5, 0.6); - //cairo_paint (cairo_context); + /* cairo_scale (cairo_context, x_scale_factor, y_scale_factor); */ + /* cairo_set_source_rgb (cairo_context, 0.5, 0.5, 0.6); */ + /* cairo_paint (cairo_context); */ draw_windows (cairo_context); cairo_destroy (cairo_context); - + return FALSE; } @@ -293,9 +323,11 @@ static void add_windows_from_stack_to_list (PopWindowStack *stack) { if (pop_window_stack_is_ready (stack)) - pop_window_stack_foreach (stack, - (PopWindowStackForeachFunc) - add_window_from_stack_to_list, NULL); + { + pop_window_stack_foreach (stack, + (PopWindowStackForeachFunc) + add_window_from_stack_to_list, NULL); + } } static void @@ -304,10 +336,12 @@ on_stack_ready_add_windows (GObject *object, gpointer user_data) { PopWindowStack *stack; + stack = POP_WINDOW_STACK (object); add_windows_from_stack_to_list (stack); - g_signal_handlers_disconnect_by_func (object, on_stack_ready_add_windows, user_data); + g_signal_handlers_disconnect_by_func (object, on_stack_ready_add_windows, + user_data); } static void @@ -316,10 +350,14 @@ on_map (GtkWidget *widget) stack = pop_window_stack_get_for_screen (NULL); if (pop_window_stack_is_ready (stack)) - add_windows_from_stack_to_list (stack); - else - g_signal_connect (G_OBJECT (stack), "notify::is-ready", - on_stack_ready_add_windows, NULL); + { + add_windows_from_stack_to_list (stack); + } + else + { + g_signal_connect (G_OBJECT (stack), "notify::is-ready", + on_stack_ready_add_windows, NULL); + } } static void @@ -332,9 +370,9 @@ remove_window_from_stack_from_list (PopWindowStack *stack, static void remove_windows_from_stack_from_list (PopWindowStack *stack) { - pop_window_stack_foreach (stack, - (PopWindowStackForeachFunc) - remove_window_from_stack_from_list, + pop_window_stack_foreach (stack, + (PopWindowStackForeachFunc) + remove_window_from_stack_from_list, NULL); g_object_unref (stack); stack = NULL; @@ -348,19 +386,25 @@ on_stack_ready_remove_windows (GObject *object, gpointer user_data) { PopWindowStack *stack; + stack = POP_WINDOW_STACK (object); remove_windows_from_stack_from_list (stack); - g_signal_handlers_disconnect_by_func (object, on_stack_ready_remove_windows, user_data); + g_signal_handlers_disconnect_by_func (object, on_stack_ready_remove_windows, + user_data); } static gboolean on_close (GtkWidget *widget) { if (pop_window_stack_is_ready (stack)) - remove_windows_from_stack_from_list (stack); - else - g_signal_connect (G_OBJECT (stack), "notify::is-ready", - on_stack_ready_remove_windows, NULL); + { + remove_windows_from_stack_from_list (stack); + } + else + { + g_signal_connect (G_OBJECT (stack), "notify::is-ready", + on_stack_ready_remove_windows, NULL); + } return FALSE; } @@ -379,15 +423,21 @@ on_create_window_event (XCreateWindowEvent *window_event, GdkWindow *window; if (window_event->parent != GDK_ROOT_WINDOW ()) - return; + { + return; + } window = gdk_window_foreign_new (window_event->window); if (window != NULL) - add_window_to_list (window); + { + add_window_to_list (window); + } else - g_print ("recently created window 0x%lx has already been destroyed\n", - window_event->window); + { + g_print ("recently created window 0x%lx has already been destroyed\n", + window_event->window); + } } static void @@ -398,7 +448,9 @@ on_destroy_window_event (XDestroyWindowEvent *window_event, window = gdk_window_lookup (window_event->window); if (window == NULL) - return; + { + return; + } remove_window_from_list (window); gtk_widget_queue_draw (GTK_WIDGET (overlay_window)); } @@ -426,18 +478,25 @@ on_event (XEvent *x_event, GdkEvent *event, PopOverlayWindow *overlay_window) { - - if (((GdkEventAny *) event)->window == GTK_WIDGET (overlay_window)->window) - return GDK_FILTER_CONTINUE; - if (x_event_is_damage_event (x_event)) - on_damage_event ((XDamageNotifyEvent *) x_event, overlay_window); - else if (x_event_is_create_window_event (x_event)) - on_create_window_event ((XCreateWindowEvent *) x_event, overlay_window); - else if (x_event_is_destroy_window_event (x_event)) - on_destroy_window_event ((XDestroyWindowEvent *) x_event, overlay_window); + if (((GdkEventAny *) event)->window == GTK_WIDGET (overlay_window)->window) + { + return GDK_FILTER_CONTINUE; + } + if (x_event_is_damage_event (x_event)) + { + on_damage_event ((XDamageNotifyEvent *) x_event, overlay_window); + } + else if (x_event_is_create_window_event (x_event)) + { + on_create_window_event ((XCreateWindowEvent *) x_event, overlay_window); + } + else if (x_event_is_destroy_window_event (x_event)) + { + on_destroy_window_event ((XDestroyWindowEvent *) x_event, overlay_window); + } gtk_widget_queue_draw (GTK_WIDGET (overlay_window)); - + return GDK_FILTER_CONTINUE; } @@ -449,15 +508,15 @@ main (int argc, gtk_init (&argc, &argv); - if (!composite_is_available ()) + if (!composite_is_available ()) { - g_printerr ("composite extension not found\n"); + g_printerr ("composite extension not found\n"); return 1; } if (!initialize_damage_extension ()) { - g_printerr ("damage extension not found\n"); + g_printerr ("damage extension not found\n"); return 2; } @@ -471,13 +530,13 @@ main (int argc, gtk_widget_realize (GTK_WIDGET (overlay_window)); #endif - g_signal_connect (G_OBJECT (overlay_window), "expose-event", + g_signal_connect (G_OBJECT (overlay_window), "expose-event", G_CALLBACK (on_expose_event), NULL); g_signal_connect (G_OBJECT (overlay_window), "map", G_CALLBACK (on_map), NULL); g_signal_connect (G_OBJECT (overlay_window), "delete-event", G_CALLBACK (on_close), NULL); - + root_window = gdk_get_default_root_window (); gdk_window_set_events (root_window, GDK_SUBSTRUCTURE_MASK); gdk_window_add_filter (NULL, (GdkFilterFunc) on_event, overlay_window); @@ -486,9 +545,11 @@ main (int argc, gtk_widget_show (overlay_window); - g_print ("overlay window is 0x%lx\n", GDK_WINDOW_XWINDOW (overlay_window->window)); + g_print ("overlay window is 0x%lx\n", + GDK_WINDOW_XWINDOW (overlay_window->window)); - gtk_main(); + gtk_main (); return 0; } + |