summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2007-05-06 00:24:06 -0400
committerRay Strode <rstrode@redhat.com>2007-05-06 00:24:06 -0400
commite3aa16afa3e6a6809ab70a95b841ecb36b42e0dd (patch)
tree451cb0a1647ed974468e9d88ca048a9f420ceaa0
parentd69c13a8fe92356a516704853b6b5d2faa3e1fb6 (diff)
Fix up formatting
Run source code through "uncrustify"
-rw-r--r--src/pop-demo.c223
-rw-r--r--src/pop-event-listener.c354
-rw-r--r--src/pop-overlay-window.c97
-rw-r--r--src/pop-transaction.c452
-rw-r--r--src/pop-window-stack.c204
-rw-r--r--src/pop-window-view.c327
-rw-r--r--src/pop-x-reply-watch.c85
7 files changed, 1021 insertions, 721 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;
}
+
diff --git a/src/pop-event-listener.c b/src/pop-event-listener.c
index 9667b98..a0012ff 100644
--- a/src/pop-event-listener.c
+++ b/src/pop-event-listener.c
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * 02111-1307, USA.
*/
#include "config.h"
#include "pop-event-listener.h"
@@ -66,7 +66,6 @@ static void pop_event_listener_circulate_handler (PopEventListener *listener,
static void pop_event_listener_stop (PopEventListener *listener);
-
static int pop_event_listener_damage_notify_event_type,
pop_event_listener_shape_notify_event_type;
@@ -75,7 +74,6 @@ struct _PopEventListenerPrivate
GHashTable *event_handlers;
};
-
/* XXX: This is a bit of a hack. gdk doesn't have
* events for some of X extensions we need, so we
* are rolling our own using an event filter.
@@ -137,9 +135,9 @@ struct _PopEventCirculate
PopEventCirculatePlacement placement;
};
-typedef void (* PopEventListenerEventHandler) (PopEventListener *listener,
- GdkEvent *event,
- GdkWindow *window);
+typedef void (*PopEventListenerEventHandler) (PopEventListener *listener,
+ GdkEvent *event,
+ GdkWindow *window);
static void
pop_event_listener_class_install_signals (PopEventListenerClass *listener_class);
@@ -147,16 +145,16 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
#if 0
static void
pop_event_listener_class_install_properties
-(PopEventListenerClass * listener_class);
+(PopEventListenerClass *listener_class);
-static void pop_event_listener_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void pop_event_listener_get_property (GObject * object,
- guint prop_id,
- GValue * value,
- GParamSpec * pspec);
+static void pop_event_listener_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void pop_event_listener_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
enum
{
@@ -237,7 +235,7 @@ resized (PopEventListener *listener,
static void
redrawn (PopEventListener *listener,
- GdkWindow *window,
+ GdkWindow *window,
GdkRectangle *area)
{
#if 0
@@ -278,7 +276,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-created", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_created),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_created = created;
@@ -286,7 +284,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-destroyed", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_destroyed),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_destroyed = destroyed;
@@ -294,7 +292,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-shown", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_shown),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_shown = shown;
@@ -302,7 +300,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-hidden", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_hidden),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_hidden = hidden;
@@ -310,7 +308,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-moved", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_moved),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_moved = moved;
@@ -318,7 +316,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-resized", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_resized),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_resized = resized;
@@ -326,7 +324,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-reshaped", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_reshaped),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_reshaped = NULL;
@@ -334,7 +332,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-reparented", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_reparented),
- NULL, NULL, pop_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2,
+ NULL, NULL, pop_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2,
G_TYPE_OBJECT, G_TYPE_OBJECT);
listener_class->window_reparented = reparented;
@@ -342,7 +340,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-redrawn", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_redrawn),
- NULL, NULL, pop_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
+ NULL, NULL, pop_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
G_TYPE_OBJECT, G_TYPE_POINTER);
listener_class->window_redrawn = redrawn;
@@ -350,7 +348,7 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-layered-under", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_layered_under),
- NULL, NULL, pop_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2,
+ NULL, NULL, pop_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2,
G_TYPE_OBJECT, G_TYPE_OBJECT);
listener_class->window_layered_under = NULL;
@@ -358,22 +356,24 @@ pop_event_listener_class_install_signals (PopEventListenerClass *listener_class)
g_signal_new ("window-layered-on-top", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
G_STRUCT_OFFSET (PopEventListenerClass, window_layered_on_top),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_layered_on_top = NULL;
pop_event_listener_signals[WINDOW_LAYERED_ON_BOTTOM] =
g_signal_new ("window-layered-on-bottom", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- G_STRUCT_OFFSET (PopEventListenerClass, window_layered_on_bottom),
- NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
+ G_STRUCT_OFFSET (PopEventListenerClass,
+ window_layered_on_bottom),
+ NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
G_TYPE_OBJECT);
listener_class->window_layered_on_bottom = NULL;
}
#if 0
static void
-pop_event_listener_class_install_properties (PopEventListenerClass *listener_class)
+pop_event_listener_class_install_properties (
+ PopEventListenerClass *listener_class)
{
GObjectClass *object_class;
GParamSpec *bar_spec;
@@ -382,19 +382,21 @@ pop_event_listener_class_install_properties (PopEventListenerClass *listener_cla
object_class->set_property = pop_event_listener_set_property;
object_class->get_property = pop_event_listener_get_property;
- bar_spec = g_param_spec_int ("bar", _("Bar"),
- _("The amount of bar"),
+ bar_spec = g_param_spec_int ("bar", _ ("Bar"),
+ _ ("The amount of bar"),
0, G_MAXINT,
POP_EVENT_LISTENER_DEFAULT_BAR,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property (object_class, PROP_BAR, bar_spec);
}
+
#endif
static void
pop_event_listener_initialize_damage_extension (PopEventListener *listener)
{
int event_base, error_base;
+
XDamageQueryExtension (GDK_DISPLAY (), &event_base, &error_base);
pop_event_listener_damage_notify_event_type = event_base + XDamageNotify;
@@ -404,6 +406,7 @@ static void
pop_event_listener_initialize_shape_extension (PopEventListener *listener)
{
int event_base, error_base;
+
XShapeQueryExtension (GDK_DISPLAY (), &event_base, &error_base);
pop_event_listener_shape_notify_event_type = event_base + ShapeNotify;
@@ -414,19 +417,19 @@ pop_event_listener_register_event_handlers (PopEventListener *listener)
{
listener->priv->event_handlers = g_hash_table_new (NULL, NULL);
- g_hash_table_insert (listener->priv->event_handlers,
+ g_hash_table_insert (listener->priv->event_handlers,
GINT_TO_POINTER (GDK_DESTROY),
pop_event_listener_destroy_handler);
- g_hash_table_insert (listener->priv->event_handlers,
+ g_hash_table_insert (listener->priv->event_handlers,
GINT_TO_POINTER (GDK_CONFIGURE),
pop_event_listener_configure_handler);
- g_hash_table_insert (listener->priv->event_handlers,
+ g_hash_table_insert (listener->priv->event_handlers,
GINT_TO_POINTER (GDK_MAP),
pop_event_listener_map_handler);
- g_hash_table_insert (listener->priv->event_handlers,
+ g_hash_table_insert (listener->priv->event_handlers,
GINT_TO_POINTER (GDK_UNMAP),
pop_event_listener_unmap_handler);
@@ -445,7 +448,6 @@ pop_event_listener_register_event_handlers (PopEventListener *listener)
g_hash_table_insert (listener->priv->event_handlers,
GINT_TO_POINTER (POP_CIRCULATE),
pop_event_listener_circulate_handler);
-
}
static void
@@ -474,46 +476,50 @@ pop_event_listener_do_finalize (GObject *object)
pop_event_listener_stop (listener);
if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ {
+ parent_class->finalize (object);
+ }
}
#if 0
static void
-pop_event_listener_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec)
+pop_event_listener_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
PopEventListener *listener = POP_EVENT_LISTENER (object);
switch (prop_id)
{
- case PROP_BAR:
- pop_event_listener_set_bar (listener, g_value_get_int (value));
- break;
+ case PROP_BAR:
+ pop_event_listener_set_bar (listener, g_value_get_int (value));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
-pop_event_listener_get_property (GObject * object,
- guint prop_id,
- GValue * value, GParamSpec * pspec)
+pop_event_listener_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
PopEventListener *listener = POP_EVENT_LISTENER (object);
switch (prop_id)
{
- case PROP_BAR:
- g_value_set_int (value, pop_event_listener_get_bar (listener));
- break;
+ case PROP_BAR:
+ g_value_set_int (value, pop_event_listener_get_bar (listener));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
+
#endif
GQuark
@@ -522,7 +528,9 @@ pop_event_listener_error_quark (void)
static GQuark error_quark = 0;
if (error_quark == 0)
- error_quark = g_quark_from_static_string ("pop-event-listener");
+ {
+ error_quark = g_quark_from_static_string ("pop-event-listener");
+ }
return error_quark;
}
@@ -539,7 +547,8 @@ pop_event_listener_new (GdkDisplay *display)
#if 0
void
-pop_event_listener_set_bar (PopEventListener * listener, int bar)
+pop_event_listener_set_bar (PopEventListener *listener,
+ int bar)
{
if (listener->priv->bar != bar)
{
@@ -549,18 +558,20 @@ pop_event_listener_set_bar (PopEventListener * listener, int bar)
}
int
-pop_event_listener_get_bar (PopEventListener * listener)
+pop_event_listener_get_bar (PopEventListener *listener)
{
return listener->priv->bar;
}
+
#endif
static GQuark
pop_event_listener_get_signal_detail_for_window (PopEventListener *listener,
- GdkWindow *window)
+ GdkWindow *window)
{
gchar window_id[sizeof ("ffffffff")];
- g_snprintf (window_id, sizeof (window_id),
+
+ g_snprintf (window_id, sizeof (window_id),
"%lx", GDK_WINDOW_XWINDOW (window));
return g_quark_from_string (window_id);
@@ -573,13 +584,13 @@ pop_event_listener_destroy_handler (PopEventListener *listener,
{
g_signal_emit (G_OBJECT (listener),
pop_event_listener_signals[WINDOW_CREATED],
- pop_event_listener_get_signal_detail_for_window (listener,
- window),
+ pop_event_listener_get_signal_detail_for_window (listener,
+ window),
window);
}
static gboolean
-pop_event_listener_get_cached_window_geometry (PopEventListener *listener,
+pop_event_listener_get_cached_window_geometry (PopEventListener *listener,
GdkWindow *window,
int *x,
int *y,
@@ -594,52 +605,62 @@ pop_event_listener_get_cached_window_geometry (PopEventListener *listener,
"window-geometry"));
if (!has_cached_geometry)
- return FALSE;
+ {
+ return FALSE;
+ }
if (x)
- *x = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
- "pop-event-listener-cached-window-x"));
+ {
+ *x = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
+ "pop-event-listener-cached-window-x"));
+ }
if (y)
- *y = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
- "pop-event-listener-cached-window-y"));
+ {
+ *y = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
+ "pop-event-listener-cached-window-y"));
+ }
if (width)
- *width = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
- "pop-event-listener-cached-window-width"));
+ {
+ *width = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
+ "pop-event-listener-cached-window-width"));
+ }
if (height)
- *height = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
- "pop-event-listener-cached-window-height"));
+ {
+ *height = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (window),
+ "pop-event-listener-cached-window-height"));
+ }
return TRUE;
}
static void
-pop_event_listener_cache_window_geometry (PopEventListener *listener,
+pop_event_listener_cache_window_geometry (PopEventListener *listener,
GdkWindow *window,
int x,
int y,
int width,
int height)
{
- g_object_set_data (G_OBJECT (window),
+ g_object_set_data (G_OBJECT (window),
"pop-event-listener-cached-window-x",
GINT_TO_POINTER (x));
- g_object_set_data (G_OBJECT (window),
+ g_object_set_data (G_OBJECT (window),
"pop-event-listener-cached-window-y",
- GINT_TO_POINTER (y));
+ GINT_TO_POINTER (y));
- g_object_set_data (G_OBJECT (window),
+ g_object_set_data (G_OBJECT (window),
"pop-event-listener-cached-window-width",
GINT_TO_POINTER (width));
- g_object_set_data (G_OBJECT (window),
+ g_object_set_data (G_OBJECT (window),
"pop-event-listener-cached-window-height",
GINT_TO_POINTER (height));
- g_object_set_data (G_OBJECT (window),
+ g_object_set_data (G_OBJECT (window),
"pop-event-listener-has-cached-window-geometry",
GINT_TO_POINTER (TRUE));
}
@@ -658,7 +679,9 @@ pop_event_listener_get_cached_window_layer (PopEventListener *listener,
"window-layer"));
if (!has_cached_layer)
- return FALSE;
+ {
+ return FALSE;
+ }
cached_window_above = g_object_get_data (G_OBJECT (window),
"pop-event-listener-cached-window-"
@@ -677,9 +700,9 @@ pop_event_listener_get_cached_window_layer (PopEventListener *listener,
g_object_set_data (G_OBJECT (window),
"pop-event-listener-cached-window-"
"layer-window-above", NULL);
- g_object_set_data (G_OBJECT (window),
+ g_object_set_data (G_OBJECT (window),
"pop-event-listener-has-cached-window-layer",
- GINT_TO_POINTER (FALSE));
+ GINT_TO_POINTER (FALSE));
g_object_unref (cached_window_above);
return FALSE;
}
@@ -689,7 +712,7 @@ pop_event_listener_get_cached_window_layer (PopEventListener *listener,
}
static void
-pop_event_listener_cache_window_layer (PopEventListener *listener,
+pop_event_listener_cache_window_layer (PopEventListener *listener,
GdkWindow *window,
GdkWindow *window_above)
{
@@ -698,7 +721,9 @@ pop_event_listener_cache_window_layer (PopEventListener *listener,
old_window_above = g_object_get_data (G_OBJECT (window),
"pop-event-listener-cached-window-layer-window-above");
if (old_window_above != NULL)
- g_object_unref (old_window_above);
+ {
+ g_object_unref (old_window_above);
+ }
g_object_set_data (G_OBJECT (window),
"pop-event-listener-cached-window-layer-window-above",
@@ -711,8 +736,8 @@ pop_event_listener_cache_window_layer (PopEventListener *listener,
"pop-event-listener-cached-window-layer-window-below",
g_object_ref (window));
}
-
- g_object_set_data (G_OBJECT (window),
+
+ g_object_set_data (G_OBJECT (window),
"pop-event-listener-has-cached-window-layer",
GINT_TO_POINTER (TRUE));
}
@@ -740,8 +765,8 @@ pop_event_listener_configure_handler (PopEventListener *listener,
&x, &y, &width, &height))
{
changed_position = (x != configure_event->x) || (y != configure_event->y);
- changed_size = (width != configure_event->width)
- || (height != configure_event->height);
+ changed_size = (width != configure_event->width)
+ || (height != configure_event->height);
}
else
{
@@ -749,10 +774,15 @@ pop_event_listener_configure_handler (PopEventListener *listener,
changed_size = TRUE;
}
- if (pop_event_listener_get_cached_window_layer (listener, window, &window_above))
- changed_layer = window_above != new_window_above;
+ if (pop_event_listener_get_cached_window_layer (listener, window,
+ &window_above))
+ {
+ changed_layer = window_above != new_window_above;
+ }
else
- changed_layer = TRUE;
+ {
+ changed_layer = TRUE;
+ }
PopWindowView *view;
view = g_object_get_data (G_OBJECT (window), "pop-window-view");
@@ -778,27 +808,35 @@ pop_event_listener_configure_handler (PopEventListener *listener,
{
g_print ("window 0x%lx changed layers\n", GDK_WINDOW_XWINDOW (window));
if (new_window_above != NULL)
- g_signal_emit (G_OBJECT (listener),
- pop_event_listener_signals[WINDOW_LAYERED_UNDER],
- pop_event_listener_get_signal_detail_for_window (listener,
- window),
- window,
- new_window_above);
+ {
+ g_signal_emit (G_OBJECT (listener),
+ pop_event_listener_signals[WINDOW_LAYERED_UNDER],
+ pop_event_listener_get_signal_detail_for_window (
+ listener,
+ window),
+ window,
+ new_window_above);
+ }
else
- g_signal_emit (G_OBJECT (listener),
- pop_event_listener_signals[WINDOW_LAYERED_ON_BOTTOM],
- pop_event_listener_get_signal_detail_for_window (listener,
- window),
- window);
+ {
+ g_signal_emit (G_OBJECT (listener),
+ pop_event_listener_signals[WINDOW_LAYERED_ON_BOTTOM],
+ pop_event_listener_get_signal_detail_for_window (
+ listener,
+ window),
+ window);
+ }
pop_event_listener_cache_window_layer (listener, window, new_window_above);
}
if (new_window_above != NULL)
- g_object_unref (new_window_above);
-
- pop_event_listener_cache_window_geometry (listener, window,
- configure_event->x,
- configure_event->y,
+ {
+ g_object_unref (new_window_above);
+ }
+
+ pop_event_listener_cache_window_geometry (listener, window,
+ configure_event->x,
+ configure_event->y,
configure_event->width,
configure_event->height);
}
@@ -820,7 +858,6 @@ pop_event_listener_unmap_handler (PopEventListener *listener,
GdkEvent *event,
GdkWindow *window)
{
-
g_signal_emit (G_OBJECT (listener),
pop_event_listener_signals[WINDOW_HIDDEN],
pop_event_listener_get_signal_detail_for_window (listener,
@@ -828,7 +865,7 @@ pop_event_listener_unmap_handler (PopEventListener *listener,
window);
}
-static void
+static void
pop_event_listener_damage_handler (PopEventListener *listener,
GdkEvent *event,
GdkWindow *window)
@@ -847,7 +884,7 @@ pop_event_listener_damage_handler (PopEventListener *listener,
window, &damage_event->area);
}
-static void
+static void
pop_event_listener_shape_handler (PopEventListener *listener,
GdkEvent *event,
GdkWindow *window)
@@ -865,7 +902,7 @@ pop_event_listener_shape_handler (PopEventListener *listener,
window);
}
-static void
+static void
pop_event_listener_reparent_handler (PopEventListener *listener,
GdkEvent *event,
GdkWindow *window)
@@ -884,7 +921,7 @@ pop_event_listener_reparent_handler (PopEventListener *listener,
window, reparent_event->parent);
}
-static void
+static void
pop_event_listener_circulate_handler (PopEventListener *listener,
GdkEvent *event,
GdkWindow *window)
@@ -898,7 +935,8 @@ pop_event_listener_circulate_handler (PopEventListener *listener,
if (circulate_event->placement == POP_EVENT_CIRCULATE_PLACEMENT_TOP)
{
- g_print ("window 0x%lx moved to top of stack\n", GDK_WINDOW_XWINDOW (window));
+ g_print ("window 0x%lx moved to top of stack\n",
+ GDK_WINDOW_XWINDOW (window));
g_signal_emit (G_OBJECT (listener),
pop_event_listener_signals[WINDOW_LAYERED_ON_TOP],
pop_event_listener_get_signal_detail_for_window (listener,
@@ -907,7 +945,8 @@ pop_event_listener_circulate_handler (PopEventListener *listener,
}
else if (circulate_event->placement == POP_EVENT_CIRCULATE_PLACEMENT_BOTTOM)
{
- g_print ("window 0x%lx moved to bottom of stack\n", GDK_WINDOW_XWINDOW (window));
+ g_print ("window 0x%lx moved to bottom of stack\n",
+ GDK_WINDOW_XWINDOW (window));
g_signal_emit (G_OBJECT (listener),
pop_event_listener_signals[WINDOW_LAYERED_ON_BOTTOM],
pop_event_listener_get_signal_detail_for_window (listener,
@@ -923,12 +962,14 @@ pop_event_listener_process_event_for_window (PopEventListener *listener,
{
PopEventListenerEventHandler event_handler;
- event_handler = (PopEventListenerEventHandler)
- g_hash_table_lookup (listener->priv->event_handlers,
- GINT_TO_POINTER (event->type));
+ event_handler = (PopEventListenerEventHandler)
+ g_hash_table_lookup (listener->priv->event_handlers,
+ GINT_TO_POINTER (event->type));
if (event_handler == NULL)
- return;
+ {
+ return;
+ }
event_handler (listener, event, window);
}
@@ -938,21 +979,25 @@ pop_event_listener_event_handler (GdkEvent *event,
gpointer data)
{
PopEventListener *listener;
-
+
g_assert (event != NULL);
g_assert (POP_IS_EVENT_LISTENER (data));
listener = POP_EVENT_LISTENER (data);
if (event->any.window != NULL)
- pop_event_listener_process_event_for_window (listener, event,
- event->any.window);
+ {
+ pop_event_listener_process_event_for_window (listener, event,
+ event->any.window);
+ }
/* chain up to the default handler if it's not one of our custom
* events
*/
if (event->type >= GDK_NOTHING)
- gtk_main_do_event (event);
+ {
+ gtk_main_do_event (event);
+ }
}
GdkFilterReturn
@@ -997,7 +1042,9 @@ pop_event_listener_filter_reparent_event (XReparentEvent *x_reparent_event,
parent = gdk_window_lookup (x_reparent_event->parent);
if (parent == NULL)
- parent = gdk_window_foreign_new (x_reparent_event->parent);
+ {
+ parent = gdk_window_foreign_new (x_reparent_event->parent);
+ }
reparent_event->parent = parent;
@@ -1013,13 +1060,17 @@ pop_event_listener_filter_circulate_event (XCirculateEvent *x_circulate_event,
circulate_event->type = POP_CIRCULATE;
circulate_event->send_event = FALSE;
- g_assert ((x_circulate_event->place == PlaceOnTop) ||
- (x_circulate_event->place == PlaceOnBottom));
+ g_assert ((x_circulate_event->place == PlaceOnTop)
+ || (x_circulate_event->place == PlaceOnBottom));
if (x_circulate_event->place == PlaceOnTop)
- circulate_event->placement = POP_EVENT_CIRCULATE_PLACEMENT_TOP;
+ {
+ circulate_event->placement = POP_EVENT_CIRCULATE_PLACEMENT_TOP;
+ }
else if (x_circulate_event->place == PlaceOnBottom)
- circulate_event->placement = POP_EVENT_CIRCULATE_PLACEMENT_BOTTOM;
+ {
+ circulate_event->placement = POP_EVENT_CIRCULATE_PLACEMENT_BOTTOM;
+ }
return GDK_FILTER_TRANSLATE;
}
@@ -1036,15 +1087,21 @@ pop_event_listener_filter_configure_event (XConfigureEvent *x_configure_event,
*/
if (x_configure_event->above == None)
- window_above = NULL;
+ {
+ window_above = NULL;
+ }
else
- window_above = gdk_window_foreign_new (x_configure_event->above);
+ {
+ window_above = gdk_window_foreign_new (x_configure_event->above);
+ }
- g_object_set_data (G_OBJECT (window), "pop-event-listener-window-above",
+ g_object_set_data (G_OBJECT (window), "pop-event-listener-window-above",
window_above);
if (window_above != NULL)
- g_object_ref (window_above);
+ {
+ g_object_ref (window_above);
+ }
return GDK_FILTER_CONTINUE;
}
@@ -1059,12 +1116,15 @@ pop_event_listener_filter (XEvent *x_event,
window = gdk_window_lookup (x_event->xany.window);
if (window == NULL)
- return GDK_FILTER_CONTINUE;
+ {
+ return GDK_FILTER_CONTINUE;
+ }
if (x_event->type == pop_event_listener_damage_notify_event_type)
{
g_assert (sizeof (PopEventDamage) <= sizeof (*event));
- return pop_event_listener_filter_damage_event ((XDamageNotifyEvent *) x_event,
+ return pop_event_listener_filter_damage_event ((XDamageNotifyEvent *)
+ x_event,
(PopEventDamage *) event,
window);
}
@@ -1078,21 +1138,27 @@ pop_event_listener_filter (XEvent *x_event,
else if (x_event->type == ReparentNotify)
{
g_assert (sizeof (PopEventReparent) <= sizeof (*event));
- return pop_event_listener_filter_reparent_event ((XReparentEvent *) x_event,
- (PopEventReparent *) event,
+ return pop_event_listener_filter_reparent_event ((XReparentEvent *)
+ x_event,
+ (PopEventReparent *)
+ event,
window);
}
else if (x_event->type == CirculateNotify)
{
g_assert (sizeof (PopEventCirculate) <= sizeof (*event));
- return pop_event_listener_filter_circulate_event ((XCirculateEvent *) x_event,
- (PopEventCirculate *) event,
+ return pop_event_listener_filter_circulate_event ((XCirculateEvent *)
+ x_event,
+ (PopEventCirculate *)
+ event,
window);
}
else if (x_event->type == ConfigureNotify)
{
- return pop_event_listener_filter_configure_event ((XConfigureEvent *) x_event,
- (GdkEventConfigure *) event,
+ return pop_event_listener_filter_configure_event ((XConfigureEvent *)
+ x_event,
+ (GdkEventConfigure *)
+ event,
window);
}
@@ -1104,12 +1170,12 @@ pop_event_listener_start (PopEventListener *listener)
{
/* used for questionable hack to get damage and shape events reported
*/
- gdk_window_add_filter (NULL, (GdkFilterFunc) pop_event_listener_filter,
+ gdk_window_add_filter (NULL, (GdkFilterFunc) pop_event_listener_filter,
listener);
/* translates gdk events to signals on the listener object
*/
- gdk_event_handler_set (pop_event_listener_event_handler,
+ gdk_event_handler_set (pop_event_listener_event_handler,
listener, NULL);
}
@@ -1139,7 +1205,8 @@ pop_event_listener_get_default (void)
#include <glib.h>
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
PopEventListener *listener;
int exit_code;
@@ -1154,7 +1221,7 @@ main (int argc, char **argv)
g_message ("'event listener' object created successfully");
g_message
- ("destroying previously created 'event listener' object...");
+ ("destroying previously created 'event listener' object...");
g_object_unref (listener);
g_message ("'event listener' object destroyed successfully");
@@ -1162,4 +1229,5 @@ main (int argc, char **argv)
return exit_code;
}
+
#endif /* POP_EVENT_LISTENER_ENABLE_TEST */
diff --git a/src/pop-overlay-window.c b/src/pop-overlay-window.c
index 955eccb..ab8cc99 100644
--- a/src/pop-overlay-window.c
+++ b/src/pop-overlay-window.c
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General
* Public License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Boston, MA 02111-1307, USA.
*
* Originally written by: Ray Strode <rstrode@redhat.com>
*/
@@ -40,11 +40,10 @@ static void pop_overlay_window_do_realize (GtkWidget *widget);
static void pop_overlay_window_do_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-
-struct _PopOverlayWindowPrivate
+struct _PopOverlayWindowPrivate
{
GdkWindow *parent_window;
-};
+};
G_DEFINE_TYPE (PopOverlayWindow, pop_overlay_window, GTK_TYPE_WINDOW);
@@ -83,7 +82,9 @@ pop_overlay_window_do_finalize (GObject *object)
parent_class = G_OBJECT_CLASS (pop_overlay_window_parent_class);
if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ {
+ parent_class->finalize (object);
+ }
}
static void
@@ -117,14 +118,17 @@ pop_overlay_window_setup_parent_window (PopOverlayWindow *overlay_window)
}
static void
-pop_overlay_window_get_initial_display_window_attributes (PopOverlayWindow *overlay_window,
- GdkWindowAttr *attributes,
- gint *attributes_mask)
+pop_overlay_window_get_initial_display_window_attributes (
+ PopOverlayWindow *overlay_window,
+
+ GdkWindowAttr*attributes,
+
+ gint *attributes_mask)
{
GtkWidget *widget;
- static gint new_attributes_mask = GDK_WA_COLORMAP
- | GDK_WA_VISUAL
- | GDK_WA_X
+ static gint new_attributes_mask = GDK_WA_COLORMAP
+ | GDK_WA_VISUAL
+ | GDK_WA_X
| GDK_WA_Y;
static GdkEventMask new_event_mask = GDK_EXPOSURE_MASK
| GDK_KEY_PRESS_MASK
@@ -146,7 +150,7 @@ pop_overlay_window_get_initial_display_window_attributes (PopOverlayWindow *over
widget = GTK_WIDGET (overlay_window);
- gdk_window_get_geometry (overlay_window->priv->parent_window,
+ gdk_window_get_geometry (overlay_window->priv->parent_window,
&x, &y, &width, &height, NULL);
new_attributes.window_type = GDK_WINDOW_TOPLEVEL;
new_attributes.wclass = GDK_INPUT_OUTPUT;
@@ -177,14 +181,15 @@ pop_overlay_window_setup_display_window (PopOverlayWindow *overlay_window)
widget = GTK_WIDGET (overlay_window);
screen = gtk_widget_get_screen (widget);
- pop_overlay_window_get_initial_display_window_attributes (POP_OVERLAY_WINDOW (widget),
- &attributes,
+ pop_overlay_window_get_initial_display_window_attributes (POP_OVERLAY_WINDOW (
+ widget),
+ &attributes,
&attributes_mask);
- widget->window = gdk_window_new (overlay_window->priv->parent_window,
+ widget->window = gdk_window_new (overlay_window->priv->parent_window,
&attributes, attributes_mask);
gdk_window_set_user_data (widget->window, widget);
- gdk_window_set_decorations (widget->window, (GdkWMDecoration) 0);
+ gdk_window_set_decorations (widget->window, (GdkWMDecoration) 0);
}
static void
@@ -211,7 +216,7 @@ pop_overlay_window_setup_initial_geometry (PopOverlayWindow *overlay_window)
gtk_window_resize (GTK_WINDOW (widget), width, height);
}
-static void
+static void
pop_overlay_window_do_realize (GtkWidget *widget)
{
PopOverlayWindow *overlay_window;
@@ -219,7 +224,7 @@ pop_overlay_window_do_realize (GtkWidget *widget)
overlay_window = POP_OVERLAY_WINDOW (widget);
/* we make the widget's display window a child of X's
- * composite overlay window instead of using the composite
+ * composite overlay window instead of using the composite
* overlay window directly, so that we have some flexibility
* over what visual to use.
*/
@@ -256,19 +261,25 @@ pop_overlay_window_compute_child_allocation (PopOverlayWindow *overlay_window,
child_allocation->height = widget->allocation.height - 2 * border_width;
if (child_allocation->width < 1)
- child_allocation->width = 1;
+ {
+ child_allocation->width = 1;
+ }
if (child_allocation->height < 1)
- child_allocation->height = 1;
+ {
+ child_allocation->height = 1;
+ }
}
static GdkRegion *
-pop_overlay_window_create_region_from_allocation (PopOverlayWindow *overlay_window,
- GtkAllocation *allocation)
+pop_overlay_window_create_region_from_allocation (
+ PopOverlayWindow *overlay_window,
+
+ GtkAllocation*allocation)
{
GdkRectangle rectangle;
GdkRegion *region;
-
+
g_assert (POP_IS_OVERLAY_WINDOW (overlay_window));
g_assert (allocation != NULL);
@@ -285,41 +296,46 @@ pop_overlay_window_create_region_from_allocation (PopOverlayWindow *overlay_wind
}
static void
-pop_overlay_window_set_input_region_from_allocation (PopOverlayWindow *overlay_window,
- GtkAllocation *allocation)
-{
+pop_overlay_window_set_input_region_from_allocation (
+ PopOverlayWindow *overlay_window,
+
+ GtkAllocation*allocation)
+{
GtkWidget *widget;
GdkRegion *input_region;
g_assert (POP_IS_OVERLAY_WINDOW (overlay_window));
g_assert (allocation != NULL);
- g_assert (gdk_display_supports_input_shapes (gtk_widget_get_display (GTK_WIDGET (overlay_window))));
+ g_assert (gdk_display_supports_input_shapes (gtk_widget_get_display (
+ GTK_WIDGET (overlay_window))));
/* either the child allocation is empty or present, it shouldn't
* ever be negative or only filled on one dimension
*/
g_assert (((allocation->width > 0) && (allocation->height > 0))
- || ((allocation->width == 0) && (allocation->height == 0)));
+ || ((allocation->width == 0) && (allocation->height == 0)));
widget = GTK_WIDGET (overlay_window);
- input_region =
- pop_overlay_window_create_region_from_allocation (overlay_window,
- allocation);
+ input_region =
+ pop_overlay_window_create_region_from_allocation (overlay_window,
+ allocation);
- g_assert (input_region != NULL);
+ g_assert (input_region != NULL);
gdk_window_input_shape_combine_region (overlay_window->priv->parent_window,
input_region, 0, 0);
gdk_region_destroy (input_region);
}
-static void
+static void
pop_overlay_window_do_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
PopOverlayWindow *overlay_window;
GtkWidget *child_widget;
- GtkAllocation child_allocation = { 0 };
+ GtkAllocation child_allocation = {
+ 0
+ };
g_assert (POP_IS_OVERLAY_WINDOW (widget));
g_assert (allocation != NULL);
@@ -330,7 +346,7 @@ pop_overlay_window_do_size_allocate (GtkWidget *widget,
child_widget = gtk_bin_get_child (GTK_BIN (widget));
- if ((child_widget != NULL) && GTK_WIDGET_VISIBLE (child_widget))
+ if ((child_widget != NULL) && GTK_WIDGET_VISIBLE (child_widget))
{
/* first figure out how much the space our children should get.
* Normally the answer is "all of it", but I guess to be a good
@@ -347,12 +363,14 @@ pop_overlay_window_do_size_allocate (GtkWidget *widget,
}
/* we want our children to be able to receive input events, but all space
- * not allocated to a child should just pass through to windows under the
+ * not allocated to a child should just pass through to windows under the
* overlay, so we set the input region to the area occupied by our children
*/
if (GTK_WIDGET_REALIZED (overlay_window))
- pop_overlay_window_set_input_region_from_allocation (overlay_window,
- &child_allocation);
+ {
+ pop_overlay_window_set_input_region_from_allocation (overlay_window,
+ &child_allocation);
+ }
}
GtkWidget *
@@ -360,10 +378,11 @@ pop_overlay_window_new (void)
{
PopOverlayWindow *overlay_window;
- overlay_window = g_object_new (POP_TYPE_OVERLAY_WINDOW,
+ overlay_window = g_object_new (POP_TYPE_OVERLAY_WINDOW,
"type", GTK_WINDOW_TOPLEVEL,
"app-paintable", TRUE,
NULL);
return GTK_WIDGET (overlay_window);
}
+
diff --git a/src/pop-transaction.c b/src/pop-transaction.c
index f787ae6..2e33e55 100644
--- a/src/pop-transaction.c
+++ b/src/pop-transaction.c
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * 02111-1307, USA.
*/
#include "config.h"
#include "pop-transaction.h"
@@ -27,7 +27,7 @@
#include <glib-object.h>
#include <glib/gi18n.h>
-typedef enum
+typedef enum
{
POP_TRANSACTION_STATE_UNCOMMITED = 0,
POP_TRANSACTION_STATE_COMMITED,
@@ -66,25 +66,26 @@ typedef struct
{
PopActionProcessFunc process_func;
PopActionRollbackFunc rollback_func;
- gpointer user_data;
- GDestroyNotify free_func;
+ gpointer user_data;
+ GDestroyNotify free_func;
} PopAction;
-typedef gboolean (* PopTransactionIdleFunc) (PopTransaction *transaction);
+typedef gboolean (*PopTransactionIdleFunc) (PopTransaction *transaction);
-static void pop_transaction_finalize (GObject * object);
+static void pop_transaction_finalize (GObject *object);
static void pop_transaction_class_install_signals (PopTransactionClass *
- transaction_class);
+ transaction_class);
static void pop_transaction_class_install_properties (PopTransactionClass *
- transaction_class);
-
-static void pop_transaction_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void pop_transaction_get_property (GObject * object,
- guint prop_id,
- GValue * value, GParamSpec * pspec);
+ transaction_class);
+
+static void pop_transaction_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void pop_transaction_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
static void pop_transaction_fail (PopTransaction *transaction);
static void pop_transaction_process_on_idle (PopTransaction *transaction);
static void pop_transaction_rollback_on_idle (PopTransaction *transaction);
@@ -116,7 +117,7 @@ static guint pop_transaction_signals[NUMBER_OF_SIGNALS];
G_DEFINE_TYPE (PopTransaction, pop_transaction, G_TYPE_OBJECT);
static void
-pop_transaction_class_init (PopTransactionClass * transaction_class)
+pop_transaction_class_init (PopTransactionClass *transaction_class)
{
GObjectClass *object_class;
@@ -128,12 +129,12 @@ pop_transaction_class_init (PopTransactionClass * transaction_class)
pop_transaction_class_install_signals (transaction_class);
g_type_class_add_private (transaction_class,
- sizeof (PopTransactionPrivate));
+ sizeof (PopTransactionPrivate));
}
static void
pop_transaction_class_install_signals (PopTransactionClass *
- transaction_class)
+ transaction_class)
{
GObjectClass *object_class;
@@ -141,49 +142,51 @@ pop_transaction_class_install_signals (PopTransactionClass *
pop_transaction_signals[PROCESS] =
g_signal_new ("process", G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PopTransactionClass, process),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PopTransactionClass, process),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
transaction_class->process = NULL;
pop_transaction_signals[WAIT] =
g_signal_new ("wait", G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PopTransactionClass, wait),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PopTransactionClass, wait),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
transaction_class->wait = NULL;
pop_transaction_signals[RESUME] =
g_signal_new ("resume", G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PopTransactionClass, resume),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PopTransactionClass, resume),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
transaction_class->resume = NULL;
pop_transaction_signals[CANCEL] =
g_signal_new ("cancel", G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PopTransactionClass, cancel),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PopTransactionClass, cancel),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
transaction_class->cancel = NULL;
pop_transaction_signals[FINISH] =
g_signal_new ("finish", G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PopTransactionClass, finish),
- NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PopTransactionClass, finish),
+ NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1,
+ G_TYPE_INT);
transaction_class->finish = NULL;
pop_transaction_signals[ROLLBACK] =
g_signal_new ("rollback", G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PopTransactionClass, rollback),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PopTransactionClass, rollback),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
transaction_class->rollback = NULL;
}
static void
-pop_transaction_class_install_properties (PopTransactionClass *transaction_class)
+pop_transaction_class_install_properties (
+ PopTransactionClass *transaction_class)
{
GObjectClass *object_class;
GParamSpec *param_spec;
@@ -194,21 +197,21 @@ pop_transaction_class_install_properties (PopTransactionClass *transaction_class
/* FIXME: do the whole enum gtype song and dance
*/
- param_spec = g_param_spec_int ("status", _("Status"),
- _("Current status of the transaction"),
- POP_TRANSACTION_STATUS_NOT_FINISHED,
+ param_spec = g_param_spec_int ("status", _ ("Status"),
+ _ ("Current status of the transaction"),
+ POP_TRANSACTION_STATUS_NOT_FINISHED,
POP_TRANSACTION_STATUS_SUCCEEDED,
POP_TRANSACTION_STATUS_NOT_FINISHED,
G_PARAM_READABLE);
g_object_class_install_property (object_class, PROP_STATUS, param_spec);
- param_spec = g_param_spec_pointer ("result", _("Result"),
- _("Output of transaction"),
+ param_spec = g_param_spec_pointer ("result", _ ("Result"),
+ _ ("Output of transaction"),
G_PARAM_READABLE);
g_object_class_install_property (object_class, PROP_RESULT, param_spec);
- param_spec = g_param_spec_pointer ("error", _("Error"),
- _("Reason for transaction error"),
+ param_spec = g_param_spec_pointer ("error", _ ("Error"),
+ _ ("Reason for transaction error"),
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_ERROR, param_spec);
}
@@ -219,8 +222,8 @@ pop_transaction_init (PopTransaction *transaction)
g_assert (POP_IS_TRANSACTION (transaction));
transaction->priv = G_TYPE_INSTANCE_GET_PRIVATE (transaction,
- POP_TYPE_TRANSACTION,
- PopTransactionPrivate);
+ POP_TYPE_TRANSACTION,
+ PopTransactionPrivate);
transaction->priv->actions = g_queue_new ();
transaction->priv->status = POP_TRANSACTION_STATUS_NOT_FINISHED;
@@ -243,13 +246,15 @@ pop_transaction_finalize (GObject *object)
pop_transaction_set_result (transaction, NULL, NULL);
if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ {
+ parent_class->finalize (object);
+ }
}
static void
pop_transaction_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
+ guint prop_id,
+ const GValue *value,
GParamSpec *pspec)
{
PopTransaction *transaction;
@@ -260,20 +265,20 @@ pop_transaction_set_property (GObject *object,
switch (prop_id)
{
- case PROP_ERROR:
- pop_transaction_set_error (transaction,
- (GError *) g_value_get_pointer (value));
- break;
+ case PROP_ERROR:
+ pop_transaction_set_error (transaction,
+ (GError *) g_value_get_pointer (value));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
pop_transaction_get_property (GObject *object,
- guint prop_id,
- GValue *value,
+ guint prop_id,
+ GValue *value,
GParamSpec *pspec)
{
PopTransaction *transaction;
@@ -284,18 +289,20 @@ pop_transaction_get_property (GObject *object,
switch (prop_id)
{
- case PROP_STATUS:
- g_value_set_int (value, pop_transaction_get_status (transaction));
- break;
- case PROP_ERROR:
- g_value_set_pointer (value, pop_transaction_get_error (transaction));
- break;
- case PROP_RESULT:
- g_value_set_pointer (value, pop_transaction_get_result (transaction));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_STATUS:
+ g_value_set_int (value, pop_transaction_get_status (transaction));
+ break;
+
+ case PROP_ERROR:
+ g_value_set_pointer (value, pop_transaction_get_error (transaction));
+ break;
+
+ case PROP_RESULT:
+ g_value_set_pointer (value, pop_transaction_get_result (transaction));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -345,7 +352,7 @@ pop_action_new (PopActionProcessFunc action_process_func,
action->rollback_func = action_rollback_func;
action->user_data = user_data;
action->free_func = free_func;
-
+
return action;
}
@@ -355,14 +362,16 @@ pop_action_free (PopAction *action)
g_assert (action != NULL);
if (action->free_func != NULL)
- action->free_func (action->user_data);
+ {
+ action->free_func (action->user_data);
+ }
- g_slice_free (PopAction, action);
+ g_slice_free (PopAction, action);
}
-void
-pop_transaction_add_action_full (PopTransaction *transaction,
- PopActionProcessFunc action_process_func,
+void
+pop_transaction_add_action_full (PopTransaction *transaction,
+ PopActionProcessFunc action_process_func,
PopActionRollbackFunc action_rollback_func,
gpointer user_data,
GDestroyNotify free_func)
@@ -371,15 +380,18 @@ pop_transaction_add_action_full (PopTransaction *transaction,
g_return_if_fail (POP_IS_TRANSACTION (transaction));
- action = pop_action_new (action_process_func, action_rollback_func, user_data, free_func);
+ action = pop_action_new (action_process_func, action_rollback_func, user_data,
+ free_func);
if (transaction->priv->current_action_node == NULL)
- g_queue_push_tail (transaction->priv->actions, action);
+ {
+ g_queue_push_tail (transaction->priv->actions, action);
+ }
else
{
gboolean can_rewind;
- g_queue_insert_before (transaction->priv->actions,
+ g_queue_insert_before (transaction->priv->actions,
transaction->priv->current_action_node,
action);
can_rewind = pop_transaction_rewind (transaction);
@@ -388,18 +400,18 @@ pop_transaction_add_action_full (PopTransaction *transaction,
}
}
-void
+void
pop_transaction_add_action (PopTransaction *transaction,
PopActionProcessFunc action_process_func,
PopActionRollbackFunc action_rollback_func,
gpointer user_data)
{
- pop_transaction_add_action_full (transaction, action_process_func,
+ pop_transaction_add_action_full (transaction, action_process_func,
action_rollback_func,
user_data, NULL);
}
-static PopActionProcessStatus
+static PopActionProcessStatus
pop_transaction_process_subtransaction (PopTransaction *transaction,
PopTransaction *subtransaction)
{
@@ -411,8 +423,8 @@ pop_transaction_process_subtransaction (PopTransaction *transaction,
if (!pop_transaction_is_committed (transaction))
{
pop_transaction_wait (transaction);
- g_signal_connect_swapped (G_OBJECT (subtransaction),
- "finish", G_CALLBACK (pop_transaction_resume),
+ g_signal_connect_swapped (G_OBJECT (subtransaction),
+ "finish", G_CALLBACK (pop_transaction_resume),
transaction);
pop_transaction_commit (transaction);
@@ -423,26 +435,28 @@ pop_transaction_process_subtransaction (PopTransaction *transaction,
status = pop_transaction_get_status (subtransaction);
g_assert (status != POP_TRANSACTION_STATUS_NOT_FINISHED);
- g_assert (status == POP_TRANSACTION_STATUS_CANCELED ||
- status == POP_TRANSACTION_STATUS_FAILED ||
- status == POP_TRANSACTION_STATUS_SUCCEEDED);
+ g_assert (status == POP_TRANSACTION_STATUS_CANCELED
+ || status == POP_TRANSACTION_STATUS_FAILED
+ || status == POP_TRANSACTION_STATUS_SUCCEEDED);
- if ((status == POP_TRANSACTION_STATUS_CANCELED) ||
- (status == POP_TRANSACTION_STATUS_FAILED))
- return POP_ACTION_PROCESS_STATUS_FAILED;
+ if ((status == POP_TRANSACTION_STATUS_CANCELED)
+ || (status == POP_TRANSACTION_STATUS_FAILED))
+ {
+ return POP_ACTION_PROCESS_STATUS_FAILED;
+ }
return POP_ACTION_PROCESS_STATUS_SUCCEEDED;
}
-static PopActionRollbackStatus
+static PopActionRollbackStatus
pop_transaction_rollback_subtransaction (PopTransaction *transaction,
PopTransaction *subtransaction)
{
PopTransactionStatus status;
-
+
status = pop_transaction_get_status (subtransaction);
- /* FIXME: things are a little confusing here. when you
+ /* FIXME: things are a little confusing here. when you
* rollback a transaction it puts the status in NOT_FINISHED
* and emits a "finish" signal. That's pretty counter-intuitive.
*
@@ -450,8 +464,8 @@ pop_transaction_rollback_subtransaction (PopTransaction *transaction,
* for when the rollback completes
*/
- g_assert ((status == POP_TRANSACTION_STATUS_SUCCEEDED) ||
- (status == POP_TRANSACTION_STATUS_NOT_FINISHED));
+ g_assert ((status == POP_TRANSACTION_STATUS_SUCCEEDED)
+ || (status == POP_TRANSACTION_STATUS_NOT_FINISHED));
/* not rolled back yet
*/
@@ -459,19 +473,19 @@ pop_transaction_rollback_subtransaction (PopTransaction *transaction,
{
pop_transaction_wait (transaction);
pop_transaction_rollback (subtransaction);
- g_signal_connect_swapped (G_OBJECT (subtransaction),
- "finish", G_CALLBACK (pop_transaction_resume),
+ g_signal_connect_swapped (G_OBJECT (subtransaction),
+ "finish", G_CALLBACK (pop_transaction_resume),
transaction);
return POP_ACTION_ROLLBACK_STATUS_NOT_FINISHED;
}
- /* the second time we've been called. After the pop_transaction_resume()
+ /* the second time we've been called. After the pop_transaction_resume()
*/
return POP_ACTION_ROLLBACK_STATUS_FINISHED;
}
-void
+void
pop_transaction_add_subtransaction (PopTransaction *transaction,
PopTransaction *subtransaction)
{
@@ -479,13 +493,13 @@ pop_transaction_add_subtransaction (PopTransaction *transaction,
g_return_if_fail (POP_IS_TRANSACTION (subtransaction));
g_return_if_fail (!pop_transaction_is_committed (subtransaction));
- pop_transaction_add_action_full (transaction,
- (PopActionProcessFunc)
+ pop_transaction_add_action_full (transaction,
+ (PopActionProcessFunc)
pop_transaction_process_subtransaction,
- (PopActionRollbackFunc)
+ (PopActionRollbackFunc)
pop_transaction_rollback_subtransaction,
g_object_ref (subtransaction),
- (GDestroyNotify) g_object_unref);
+ (GDestroyNotify) g_object_unref);
}
void
@@ -498,14 +512,14 @@ pop_transaction_resume (PopTransaction *transaction)
{
case POP_TRANSACTION_STATE_PROCESSING:
pop_transaction_process_on_idle (transaction);
- break;
+ break;
case POP_TRANSACTION_STATE_ROLLING_BACK:
pop_transaction_rollback_on_idle (transaction);
- break;
-
+ break;
+
default:
- break;
+ break;
}
g_source_remove (transaction->priv->wait_id);
@@ -528,7 +542,7 @@ pop_transaction_is_in_action (PopTransaction *transaction)
return FALSE;
}
-void
+void
pop_transaction_wait (PopTransaction *transaction)
{
g_return_if_fail (POP_IS_TRANSACTION (transaction));
@@ -541,17 +555,17 @@ pop_transaction_wait (PopTransaction *transaction)
g_assert (transaction->priv->rollback_idle_id == 0);
g_source_remove (transaction->priv->process_idle_id);
transaction->priv->process_idle_id = 0;
- break;
+ break;
case POP_TRANSACTION_STATE_ROLLING_BACK:
g_assert (transaction->priv->rollback_idle_id != 0);
g_assert (transaction->priv->process_idle_id == 0);
g_source_remove (transaction->priv->rollback_idle_id);
transaction->priv->rollback_idle_id = 0;
- break;
-
+ break;
+
default:
- break;
+ break;
}
g_signal_emit (transaction, pop_transaction_signals[WAIT], 0);
@@ -564,7 +578,7 @@ pop_transaction_on_fd_ready_resume (GIOChannel *channel,
{
PopTransaction *transaction;
- g_assert (POP_IS_TRANSACTION (data));
+ g_assert (POP_IS_TRANSACTION (data));
transaction = POP_TRANSACTION (data);
@@ -589,7 +603,8 @@ pop_transaction_wait_for_fd (PopTransaction *transaction,
channel = g_io_channel_unix_new (fd);
g_io_channel_set_buffered (channel, FALSE);
source = g_io_create_watch (channel, condition);
- g_source_set_callback (source, (GSourceFunc) pop_transaction_on_fd_ready_resume,
+ g_source_set_callback (source,
+ (GSourceFunc) pop_transaction_on_fd_ready_resume,
transaction, NULL);
transaction->priv->wait_id = g_source_attach (source,
transaction->priv->context);
@@ -602,7 +617,7 @@ pop_transaction_on_timeout_resume (gpointer data)
{
PopTransaction *transaction;
- g_assert (POP_IS_TRANSACTION (data));
+ g_assert (POP_IS_TRANSACTION (data));
transaction = POP_TRANSACTION (data);
@@ -623,7 +638,8 @@ pop_transaction_wait_a_while (PopTransaction *transaction,
pop_transaction_wait (transaction);
source = g_timeout_source_new (milliseconds);
- g_source_set_callback (source, (GSourceFunc) pop_transaction_on_timeout_resume,
+ g_source_set_callback (source,
+ (GSourceFunc) pop_transaction_on_timeout_resume,
transaction, NULL);
transaction->priv->wait_id = g_source_attach (source,
transaction->priv->context);
@@ -641,10 +657,10 @@ pop_transaction_call_on_idle (PopTransaction *transaction,
source = g_idle_source_new ();
g_object_ref (transaction);
- g_source_set_callback (source, (GSourceFunc) callback, transaction,
+ g_source_set_callback (source, (GSourceFunc) callback, transaction,
(GDestroyNotify) g_object_unref);
- idle_id = g_source_attach (source, transaction->priv->context);
+ idle_id = g_source_attach (source, transaction->priv->context);
g_source_unref (source);
return idle_id;
@@ -669,10 +685,12 @@ pop_transaction_rewind (PopTransaction *transaction)
g_assert (POP_IS_TRANSACTION (transaction));
if (pop_transaction_is_at_first_action (transaction))
- return FALSE;
+ {
+ return FALSE;
+ }
transaction->priv->current_action_node =
- transaction->priv->current_action_node->prev;
+ transaction->priv->current_action_node->prev;
return TRUE;
}
@@ -684,7 +702,7 @@ pop_transaction_seek_forward (PopTransaction *transaction)
g_assert (transaction->priv->current_action_node != NULL);
transaction->priv->current_action_node =
- transaction->priv->current_action_node->next;
+ transaction->priv->current_action_node->next;
return transaction->priv->current_action_node != NULL;
}
@@ -696,12 +714,12 @@ pop_transaction_finish (PopTransaction *transaction)
transaction->priv->state = POP_TRANSACTION_STATE_FINISHED;
- g_signal_emit (transaction, pop_transaction_signals[FINISH], 0,
+ g_signal_emit (transaction, pop_transaction_signals[FINISH], 0,
transaction->priv->status);
}
static gboolean
-pop_transaction_process_current_action_and_seek_forward (PopTransaction *transaction)
+pop_transaction_run_action_and_seek_forward (PopTransaction *transaction)
{
PopAction *action;
PopActionProcessStatus status;
@@ -722,16 +740,20 @@ pop_transaction_process_current_action_and_seek_forward (PopTransaction *transac
transaction->priv->is_in_action = TRUE;
if (action->process_func != NULL)
- status = action->process_func (transaction, action->user_data);
+ {
+ status = action->process_func (transaction, action->user_data);
+ }
else
- status = POP_ACTION_PROCESS_STATUS_SUCCEEDED;
+ {
+ status = POP_ACTION_PROCESS_STATUS_SUCCEEDED;
+ }
transaction->priv->is_in_action = FALSE;
switch (status)
{
case POP_ACTION_PROCESS_STATUS_NOT_FINISHED:
- should_continue = TRUE;
- break;
+ should_continue = TRUE;
+ break;
case POP_ACTION_PROCESS_STATUS_SUCCEEDED:
if (!pop_transaction_seek_forward (transaction))
@@ -739,11 +761,13 @@ pop_transaction_process_current_action_and_seek_forward (PopTransaction *transac
pop_transaction_set_status (transaction,
POP_TRANSACTION_STATUS_SUCCEEDED);
pop_transaction_finish (transaction);
- should_continue = FALSE;
+ should_continue = FALSE;
}
else
- should_continue = TRUE;
- break;
+ {
+ should_continue = TRUE;
+ }
+ break;
default:
g_warning ("status %d is not valid processing status\n", (int) status);
@@ -752,9 +776,9 @@ pop_transaction_process_current_action_and_seek_forward (PopTransaction *transac
*/
case POP_ACTION_PROCESS_STATUS_FAILED:
- should_continue = FALSE;
+ should_continue = FALSE;
pop_transaction_fail (transaction);
- break;
+ break;
}
if (!should_continue)
@@ -771,16 +795,16 @@ pop_transaction_process_on_idle (PopTransaction *transaction)
{
g_assert (POP_IS_TRANSACTION (transaction));
- transaction->priv->current_action_node =
- g_queue_peek_head_link (transaction->priv->actions);
+ transaction->priv->current_action_node =
+ g_queue_peek_head_link (transaction->priv->actions);
transaction->priv->process_idle_id =
pop_transaction_call_on_idle (transaction,
- pop_transaction_process_current_action_and_seek_forward);
+ pop_transaction_run_action_and_seek_forward);
}
static gboolean
-pop_transaction_rollback_current_action_and_rewind (PopTransaction *transaction)
+pop_transaction_rollback_action_and_rewind (PopTransaction *transaction)
{
PopAction *action;
PopActionRollbackStatus status;
@@ -790,7 +814,9 @@ pop_transaction_rollback_current_action_and_rewind (PopTransaction *transaction)
g_assert (transaction->priv->current_action_node != NULL);
if (transaction->priv->state == POP_TRANSACTION_STATE_PROCESSING)
- transaction->priv->state = POP_TRANSACTION_STATE_ROLLING_BACK;
+ {
+ transaction->priv->state = POP_TRANSACTION_STATE_ROLLING_BACK;
+ }
g_assert (transaction->priv->state == POP_TRANSACTION_STATE_ROLLING_BACK);
@@ -798,16 +824,20 @@ pop_transaction_rollback_current_action_and_rewind (PopTransaction *transaction)
transaction->priv->is_in_action = TRUE;
if (action->rollback_func != NULL)
- status = action->rollback_func (transaction, action->user_data);
+ {
+ status = action->rollback_func (transaction, action->user_data);
+ }
else
- status = POP_ACTION_ROLLBACK_STATUS_FINISHED;
+ {
+ status = POP_ACTION_ROLLBACK_STATUS_FINISHED;
+ }
transaction->priv->is_in_action = FALSE;
switch (status)
{
case POP_ACTION_ROLLBACK_STATUS_NOT_FINISHED:
should_continue = TRUE;
- break;
+ break;
default:
g_warning ("status %d is not valid rollback status\n", (int) status);
@@ -817,10 +847,10 @@ pop_transaction_rollback_current_action_and_rewind (PopTransaction *transaction)
case POP_ACTION_ROLLBACK_STATUS_FINISHED:
should_continue = pop_transaction_rewind (transaction);
- break;
+ break;
- should_continue = FALSE;
- break;
+ should_continue = FALSE;
+ break;
}
if (!should_continue)
@@ -839,11 +869,12 @@ pop_transaction_rollback_on_idle (PopTransaction *transaction)
{
g_assert (POP_IS_TRANSACTION (transaction));
- transaction->priv->current_action_node = transaction->priv->current_action_node->prev;
+ transaction->priv->current_action_node = transaction->priv->
+ current_action_node->prev;
transaction->priv->rollback_idle_id =
pop_transaction_call_on_idle (transaction,
- pop_transaction_rollback_current_action_and_rewind);
+ pop_transaction_rollback_action_and_rewind);
}
static void
@@ -878,7 +909,7 @@ pop_transaction_is_attached (PopTransaction *transaction)
return transaction->priv->context != NULL;
}
-void
+void
pop_transaction_attach (PopTransaction *transaction,
GMainContext *context)
{
@@ -922,7 +953,7 @@ pop_transaction_is_finished (PopTransaction *transaction)
return transaction->priv->state == POP_TRANSACTION_STATE_FINISHED;
}
-void
+void
pop_transaction_cancel (PopTransaction *transaction)
{
g_return_if_fail (POP_IS_TRANSACTION (transaction));
@@ -941,7 +972,7 @@ pop_transaction_rollback (PopTransaction *transaction)
{
g_return_if_fail (POP_IS_TRANSACTION (transaction));
g_return_if_fail (pop_transaction_is_finished (transaction));
- g_return_if_fail (pop_transaction_get_status (transaction) ==
+ g_return_if_fail (pop_transaction_get_status (transaction) ==
POP_TRANSACTION_STATUS_SUCCEEDED);
pop_transaction_set_status (transaction,
@@ -959,15 +990,16 @@ pop_transaction_set_result (PopTransaction *transaction,
{
g_return_if_fail (POP_IS_TRANSACTION (transaction));
-
- if (transaction->priv->free_result_func != NULL)
- transaction->priv->free_result_func (transaction->priv->result);
+ if (transaction->priv->free_result_func != NULL)
+ {
+ transaction->priv->free_result_func (transaction->priv->result);
+ }
transaction->priv->result = result;
transaction->priv->free_result_func = free_func;
}
-gpointer
+gpointer
pop_transaction_get_result (PopTransaction *transaction)
{
g_return_val_if_fail (POP_IS_TRANSACTION (transaction), NULL);
@@ -975,7 +1007,7 @@ pop_transaction_get_result (PopTransaction *transaction)
return transaction->priv->result;
}
-void
+void
pop_transaction_set_error (PopTransaction *transaction,
const GError *error)
{
@@ -984,7 +1016,9 @@ pop_transaction_set_error (PopTransaction *transaction,
if (transaction->priv->error != error)
{
if (transaction->priv->error != NULL)
- g_error_free (transaction->priv->error);
+ {
+ g_error_free (transaction->priv->error);
+ }
transaction->priv->error = g_error_copy (error);
g_object_notify (G_OBJECT (transaction), "error");
@@ -1006,14 +1040,14 @@ pop_transaction_get_error (PopTransaction *transaction)
#include <glib.h>
-typedef struct
+typedef struct
{
int fd;
guint8 *buffer;
gssize number_of_bytes_to_process;
} InputOutputArguments;
-typedef ssize_t (* InputOutputFunc) (int fd, void *buf, size_t count);
+typedef ssize_t (*InputOutputFunc) (int fd, void *buf, size_t count);
static PopActionProcessStatus
proces_io_action (PopTransaction *transaction,
@@ -1031,18 +1065,18 @@ proces_io_action (PopTransaction *transaction,
g_return_val_if_fail (arguments->buffer != NULL,
POP_ACTION_PROCESS_STATUS_FAILED);
- is_ready = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (transaction),
- "is-ready"));
+ is_ready = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (transaction),
+ "is-ready"));
if (is_ready)
{
- /* pause transaction until fd is ready for reading (or writing
+ /* pause transaction until fd is ready for reading (or writing
* depending on the io_func)
*/
pop_transaction_wait_for_fd (transaction, arguments->fd, condition,
- NULL);
- g_object_set_data (G_OBJECT (transaction), "bytes-left-to-process",
- GINT_TO_POINTER (arguments->number_of_bytes_to_process));
-
+ NULL);
+ g_object_set_data (G_OBJECT (transaction), "bytes-left-to-process",
+ GINT_TO_POINTER (arguments->number_of_bytes_to_process));
+
/* when the transaction gets unpaused we want to continue on
*/
g_object_set_data (G_OBJECT (transaction), "is-ready",
@@ -1050,24 +1084,26 @@ proces_io_action (PopTransaction *transaction,
return POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
}
- bytes_done = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (transaction),
- "bytes-already-processed"));
- bytes_left = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (transaction),
- "bytes-left-to-process"));
+ bytes_done = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (transaction),
+ "bytes-already-processed"));
+ bytes_left = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (transaction),
+ "bytes-left-to-process"));
- bytes_done_this_time = io_func (arguments->fd,
+ bytes_done_this_time = io_func (arguments->fd,
arguments->buffer + bytes_done,
bytes_left);
if (bytes_done_this_time < 0)
{
- GError *error;
+ GError *error;
if ((errno == EINTR) || (errno == EAGAIN))
- return POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
+ {
+ return POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
+ }
error = g_error_new_literal (G_FILE_ERROR,
g_file_error_from_errno (errno),
- g_strerror (errno));
+ g_strerror (errno));
pop_transaction_set_error (transaction, error);
g_error_free (error);
@@ -1078,10 +1114,10 @@ proces_io_action (PopTransaction *transaction,
bytes_done += bytes_done_this_time;
bytes_left -= bytes_done_this_time;
-
- g_object_set_data (G_OBJECT (transaction), "bytes-already-processed",
+
+ g_object_set_data (G_OBJECT (transaction), "bytes-already-processed",
GINT_TO_POINTER (bytes_done));
- g_object_set_data (G_OBJECT (transaction), "bytes-left-to-process",
+ g_object_set_data (G_OBJECT (transaction), "bytes-left-to-process",
GINT_TO_POINTER (bytes_left));
if (bytes_left == 0)
@@ -1091,9 +1127,9 @@ proces_io_action (PopTransaction *transaction,
}
return POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
-}
+}
-static PopActionProcessStatus
+static PopActionProcessStatus
process_read_action (PopTransaction *transaction,
InputOutputArguments *arguments)
{
@@ -1101,7 +1137,7 @@ process_read_action (PopTransaction *transaction,
arguments, G_IO_IN);
}
-static PopActionProcessStatus
+static PopActionProcessStatus
process_write_action (PopTransaction *transaction,
InputOutputArguments *arguments)
{
@@ -1122,7 +1158,7 @@ on_transaction_finish (PopTransaction *transaction,
g_main_loop_quit (loop);
}
-static PopActionProcessStatus
+static PopActionProcessStatus
preemptive_action (PopTransaction *transaction,
gpointer user_data)
{
@@ -1131,49 +1167,50 @@ preemptive_action (PopTransaction *transaction,
return POP_ACTION_PROCESS_STATUS_SUCCEEDED;
}
-static PopActionProcessStatus
+static PopActionProcessStatus
test_action (PopTransaction *transaction,
gpointer user_data)
{
PopActionProcessStatus status;
int generation;
+
generation = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (transaction),
"generation"));
g_print ("Generation %d\n", generation);
switch (generation)
{
case 0:
- g_print ("First instance of test action\n");
- g_print ("Press enter to continue\n");
- pop_transaction_wait_for_fd (transaction, fileno (stdin), G_IO_IN, NULL);
- status = POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
- break;
+ g_print ("First instance of test action\n");
+ g_print ("Press enter to continue\n");
+ pop_transaction_wait_for_fd (transaction, fileno (stdin), G_IO_IN, NULL);
+ status = POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
+ break;
case 1:
- getc (stdin);
- g_print ("enter detected, will continue in 5 seconds...\n");
- pop_transaction_wait_a_while (transaction, 5 * 1000);
- status = POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
- break;
+ getc (stdin);
+ g_print ("enter detected, will continue in 5 seconds...\n");
+ pop_transaction_wait_a_while (transaction, 5 * 1000);
+ status = POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
+ break;
case 2:
- g_print ("5 seconds elapsed, finishing first action...\n");
- status = POP_ACTION_PROCESS_STATUS_SUCCEEDED;
- break;
+ g_print ("5 seconds elapsed, finishing first action...\n");
+ status = POP_ACTION_PROCESS_STATUS_SUCCEEDED;
+ break;
case 3:
- g_print ("Second instance of test action\n");
- g_print ("waiting on blocking action before continuing.\n");
- pop_transaction_add_action (transaction, preemptive_action, NULL, NULL);
- status = POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
- break;
+ g_print ("Second instance of test action\n");
+ g_print ("waiting on blocking action before continuing.\n");
+ pop_transaction_add_action (transaction, preemptive_action, NULL, NULL);
+ status = POP_ACTION_PROCESS_STATUS_NOT_FINISHED;
+ break;
case 4:
- g_print ("blocking action complete.\n");
- g_print ("failing anyway because I'm a failure.\n");
- status = POP_ACTION_PROCESS_STATUS_FAILED;
- break;
+ g_print ("blocking action complete.\n");
+ g_print ("failing anyway because I'm a failure.\n");
+ status = POP_ACTION_PROCESS_STATUS_FAILED;
+ break;
}
generation++;
@@ -1182,7 +1219,7 @@ test_action (PopTransaction *transaction,
return status;
}
-static PopActionRollbackStatus
+static PopActionRollbackStatus
test_action_cleanup (PopTransaction *transaction,
gpointer user_data)
{
@@ -1191,14 +1228,15 @@ test_action_cleanup (PopTransaction *transaction,
}
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
GMainLoop *loop;
PopTransaction *transaction;
int exit_code;
g_log_set_always_fatal (G_LOG_LEVEL_ERROR
- | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+ | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
g_type_init ();
@@ -1208,12 +1246,13 @@ main (int argc, char **argv)
transaction = pop_transaction_new ();
g_message ("'transaction' object created successfully");
- g_signal_connect (G_OBJECT (transaction), "finish",
+ g_signal_connect (G_OBJECT (transaction), "finish",
G_CALLBACK (on_transaction_finish),
loop);
g_message ("adding simple test action...");
- pop_transaction_add_action (transaction, test_action, test_action_cleanup, NULL);
+ pop_transaction_add_action (transaction, test_action, test_action_cleanup,
+ NULL);
g_message ("done adding simple test action...");
g_message ("adding duplicate test action...");
@@ -1240,4 +1279,5 @@ main (int argc, char **argv)
return exit_code;
}
+
#endif /* POP_TRANSACTION_ENABLE_TEST */
diff --git a/src/pop-window-stack.c b/src/pop-window-stack.c
index 65d85bd..258c496 100644
--- a/src/pop-window-stack.c
+++ b/src/pop-window-stack.c
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * 02111-1307, USA.
*/
#include "config.h"
#include "pop-window-stack.h"
@@ -45,24 +45,27 @@ struct _PopWindowStackPrivate
typedef struct
{
PopWindowStack *stack;
- PopWindowStackForeachFunc func;
- gpointer data;
+ PopWindowStackForeachFunc func;
+ gpointer data;
} PopWindowStackForeachClosure;
typedef struct
{
PopWindowStack *stack;
GdkWindow *window;
- PopWindowStackAboveWindowForeachFunc func;
- gpointer data;
+ PopWindowStackAboveWindowForeachFunc func;
+ gpointer data;
} PopWindowStackAboveWindowForeachClosure;
-static void pop_window_stack_finalize (GObject * object);
+static void pop_window_stack_finalize (GObject *object);
+
#if 0
static void pop_window_stack_class_install_signals (PopWindowStackClass *
- stack_class);
+ stack_class);
+
#endif
-static void pop_window_stack_class_install_properties (PopWindowStackClass *stack_class);
+static void pop_window_stack_class_install_properties (
+ PopWindowStackClass *stack_class);
static void pop_window_stack_set_property (GObject *object,
guint prop_id,
@@ -76,7 +79,7 @@ static void pop_window_stack_get_property (GObject *object,
static void pop_window_stack_set_screen (PopWindowStack *stack,
GdkScreen *screen);
static void pop_window_stack_set_ready (PopWindowStack *stack,
- gboolean is_ready);
+ gboolean is_ready);
static void pop_window_stack_clear_window_list (PopWindowStack *stack);
static void pop_window_stack_ask_for_window_list (PopWindowStack *stack);
@@ -101,7 +104,7 @@ static guint pop_window_stack_signals[NUMBER_OF_SIGNALS];
G_DEFINE_TYPE (PopWindowStack, pop_window_stack, G_TYPE_OBJECT);
static void
-pop_window_stack_class_init (PopWindowStackClass * stack_class)
+pop_window_stack_class_init (PopWindowStackClass *stack_class)
{
GObjectClass *object_class;
@@ -119,7 +122,7 @@ pop_window_stack_class_init (PopWindowStackClass * stack_class)
#if 0
static void
-pop_window_stack_class_install_signals (PopWindowStackClass * stack_class)
+pop_window_stack_class_install_signals (PopWindowStackClass *stack_class)
{
GObjectClass *object_class;
@@ -127,15 +130,17 @@ pop_window_stack_class_install_signals (PopWindowStackClass * stack_class)
pop_window_stack_signals[FOO] =
g_signal_new ("foo", G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PopWindowStackClass, foo),
- NULL, NULL, g_cclosure_marshal_VOID__NONE; G_TYPE_NONE, 0);
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PopWindowStackClass, foo),
+ NULL, NULL, g_cclosure_marshal_VOID__NONE;
+ G_TYPE_NONE, 0);
stack_class->foo = NULL;
}
+
#endif
static void
-pop_window_stack_class_install_properties (PopWindowStackClass * stack_class)
+pop_window_stack_class_install_properties (PopWindowStackClass *stack_class)
{
GObjectClass *object_class;
GParamSpec *param_spec;
@@ -144,38 +149,39 @@ pop_window_stack_class_install_properties (PopWindowStackClass * stack_class)
object_class->set_property = pop_window_stack_set_property;
object_class->get_property = pop_window_stack_get_property;
- param_spec = g_param_spec_pointer ("screen", _("Screen"),
- _("Which screen to user for tracking window stack"),
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ param_spec = g_param_spec_pointer ("screen", _ ("Screen"),
+ _ (
+ "Which screen to user for tracking window stack"),
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_SCREEN, param_spec);
- param_spec = g_param_spec_boolean ("is-ready", _("Is it ready?"),
- _("whether or not the window stack is fully "
- "initialized and can be used"), FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ param_spec = g_param_spec_boolean ("is-ready", _ ("Is it ready?"),
+ _ (
+ "whether or not the window stack is fully "
+ "initialized and can be used"), FALSE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_IS_READY, param_spec);
-
}
static void
pop_window_stack_init (PopWindowStack *stack)
{
stack->priv = G_TYPE_INSTANCE_GET_PRIVATE (stack,
- POP_TYPE_WINDOW_STACK,
- PopWindowStackPrivate);
+ POP_TYPE_WINDOW_STACK,
+ PopWindowStackPrivate);
stack->priv->event_listener = pop_event_listener_get_default ();
g_signal_connect_swapped (G_OBJECT (stack->priv->event_listener),
"window-layered-under",
- G_CALLBACK (pop_window_stack_ask_for_window_list),
+ G_CALLBACK (pop_window_stack_ask_for_window_list),
stack);
g_signal_connect_swapped (G_OBJECT (stack->priv->event_listener),
"window-layered-on-top",
- G_CALLBACK (pop_window_stack_ask_for_window_list),
+ G_CALLBACK (pop_window_stack_ask_for_window_list),
stack);
g_signal_connect_swapped (G_OBJECT (stack->priv->event_listener),
"window-layered-on-bottom",
- G_CALLBACK (pop_window_stack_ask_for_window_list),
+ G_CALLBACK (pop_window_stack_ask_for_window_list),
stack);
stack->priv->windows = g_queue_new ();
@@ -184,7 +190,7 @@ pop_window_stack_init (PopWindowStack *stack)
}
static void
-pop_window_stack_finalize (GObject * object)
+pop_window_stack_finalize (GObject *object)
{
PopWindowStack *stack;
GObjectClass *parent_class;
@@ -199,50 +205,54 @@ pop_window_stack_finalize (GObject * object)
g_queue_free (stack->priv->windows);
if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ {
+ parent_class->finalize (object);
+ }
}
static void
pop_window_stack_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
+ guint prop_id,
+ const GValue *value,
GParamSpec *pspec)
{
PopWindowStack *stack = POP_WINDOW_STACK (object);
switch (prop_id)
{
- case PROP_SCREEN:
- pop_window_stack_set_screen (stack, g_value_get_pointer (value));
- break;
- case PROP_IS_READY:
- pop_window_stack_set_ready (stack, g_value_get_boolean (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ case PROP_SCREEN:
+ pop_window_stack_set_screen (stack, g_value_get_pointer (value));
+ break;
+
+ case PROP_IS_READY:
+ pop_window_stack_set_ready (stack, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
-pop_window_stack_get_property (GObject * object,
- guint prop_id,
- GValue * value, GParamSpec * pspec)
+pop_window_stack_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
PopWindowStack *stack = POP_WINDOW_STACK (object);
switch (prop_id)
{
- case PROP_SCREEN:
- g_value_set_pointer (value, stack->priv->screen);
- break;
+ case PROP_SCREEN:
+ g_value_set_pointer (value, stack->priv->screen);
+ break;
- case PROP_IS_READY:
- g_value_set_boolean (value, stack->priv->is_ready);
- break;
+ case PROP_IS_READY:
+ g_value_set_boolean (value, stack->priv->is_ready);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -252,7 +262,9 @@ pop_window_stack_error_quark (void)
static GQuark error_quark = 0;
if (error_quark == 0)
- error_quark = g_quark_from_static_string ("pop-window-stack");
+ {
+ error_quark = g_quark_from_static_string ("pop-window-stack");
+ }
return error_quark;
}
@@ -263,9 +275,11 @@ pop_window_stack_new (GdkScreen *screen)
PopWindowStack *stack;
if (screen == NULL)
- screen = gdk_screen_get_default ();
+ {
+ screen = gdk_screen_get_default ();
+ }
- stack = g_object_new (POP_TYPE_WINDOW_STACK,
+ stack = g_object_new (POP_TYPE_WINDOW_STACK,
"screen", screen, NULL);
return stack;
@@ -278,7 +292,9 @@ pop_window_stack_get_for_screen (GdkScreen *screen)
PopWindowStack *stack;
if (screen == NULL)
- screen = gdk_screen_get_default ();
+ {
+ screen = gdk_screen_get_default ();
+ }
for (tmp = stack_list; tmp != NULL; tmp = tmp->next)
{
@@ -288,7 +304,9 @@ pop_window_stack_get_for_screen (GdkScreen *screen)
if (gdk_screen_get_number (stack->priv->screen) ==
gdk_screen_get_number (screen))
- return g_object_ref (screen);
+ {
+ return g_object_ref (screen);
+ }
}
stack = pop_window_stack_new (screen);
@@ -305,7 +323,7 @@ pop_window_stack_is_ready (PopWindowStack *stack)
return stack->priv->is_ready;
}
-guint
+guint
pop_window_stack_get_length (PopWindowStack *stack)
{
g_return_val_if_fail (POP_IS_WINDOW_STACK (stack), 0);
@@ -314,7 +332,7 @@ pop_window_stack_get_length (PopWindowStack *stack)
}
static void
-pop_window_stack_foreach_func (gpointer data,
+pop_window_stack_foreach_func (gpointer data,
gpointer user_data)
{
GdkWindow *window;
@@ -327,25 +345,26 @@ pop_window_stack_foreach_func (gpointer data,
}
void
-pop_window_stack_foreach (PopWindowStack *stack,
+pop_window_stack_foreach (PopWindowStack *stack,
PopWindowStackForeachFunc func,
gpointer data)
-{
+{
PopWindowStackForeachClosure closure;
g_return_if_fail (POP_IS_WINDOW_STACK (stack));
g_return_if_fail (func != NULL);
g_return_if_fail (pop_window_stack_is_ready (stack));
-
+
closure.stack = stack;
closure.func = func;
closure.data = data;
- g_queue_foreach (stack->priv->windows, pop_window_stack_foreach_func, &closure);
+ g_queue_foreach (stack->priv->windows, pop_window_stack_foreach_func,
+ &closure);
}
static void
-pop_window_stack_above_window_foreach_func (gpointer data,
+pop_window_stack_above_window_foreach_func (gpointer data,
gpointer user_data)
{
GdkWindow *above_window;
@@ -357,11 +376,15 @@ pop_window_stack_above_window_foreach_func (gpointer data,
closure->func (closure->stack, closure->window, above_window, closure->data);
}
-void
-pop_window_stack_above_window_foreach (PopWindowStack *stack,
- GdkWindow *window,
- PopWindowStackAboveWindowForeachFunc func,
- gpointer data)
+void
+pop_window_stack_above_window_foreach (
+ PopWindowStack *stack,
+
+ GdkWindow*window,
+
+ PopWindowStackAboveWindowForeachFunc func,
+
+ gpointer data)
{
PopWindowStackAboveWindowForeachClosure closure;
GList *window_link;
@@ -375,16 +398,18 @@ pop_window_stack_above_window_foreach (PopWindowStack *sta
if (window_link == NULL)
{
- g_warning ("window with id 0x%lx is not in window stack\n",
+ g_warning ("window with id 0x%lx is not in window stack\n",
GDK_WINDOW_XWINDOW (window));
return;
}
closure.stack = stack;
- closure.window = g_object_ref (window); closure.func = func;
+ closure.window = g_object_ref (window);
+ closure.func = func;
closure.data = data;
- g_list_foreach (window_link->next, pop_window_stack_above_window_foreach_func, &closure);
+ g_list_foreach (window_link->next, pop_window_stack_above_window_foreach_func,
+ &closure);
g_object_unref (window);
}
@@ -392,11 +417,12 @@ pop_window_stack_above_window_foreach (PopWindowStack *sta
static void
pop_window_stack_clear_window_list (PopWindowStack *stack)
{
-
pop_window_stack_set_ready (stack, FALSE);
if (g_queue_is_empty (stack->priv->windows))
- return;
+ {
+ return;
+ }
g_queue_foreach (stack->priv->windows, (GFunc) g_object_unref, NULL);
@@ -411,15 +437,17 @@ window_can_output (GdkWindow *window)
gboolean received_attrs;
/* FIXME: this sucks because it requires a server round trip.
- */
+ */
gdk_error_trap_push ();
received_attrs = XGetWindowAttributes (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XWINDOW (window),
&attrs);
- if (gdk_error_trap_pop () || !received_attrs)
- return FALSE;
+ if ((gdk_error_trap_pop ()) || (!received_attrs))
+ {
+ return FALSE;
+ }
return attrs.class == InputOutput;
}
@@ -457,7 +485,7 @@ queried_window_foreach_func (Window x_window_id,
PopWindowStack *stack;
GdkDisplay *display;
GdkWindow *window;
-
+
g_assert (POP_IS_WINDOW_STACK (data));
stack = POP_WINDOW_STACK (data);
@@ -465,7 +493,9 @@ queried_window_foreach_func (Window x_window_id,
window = gdk_window_foreign_new_for_display (display, x_window_id);
if (window == NULL)
- return;
+ {
+ return;
+ }
if (!window_can_output (window))
{
@@ -498,6 +528,7 @@ on_query_tree_reply (GdkDisplay *display,
for (i = 0; i < state->number_of_children; i++)
queried_window_foreach_func (state->children[i], state->data);
+
XFree (state->children);
state->children = NULL;
state->number_of_children = 0;
@@ -523,17 +554,19 @@ pop_window_stack_ask_for_window_list (PopWindowStack *stack)
screen = stack->priv->screen;
if (screen == NULL)
- screen = gdk_screen_get_default ();
+ {
+ screen = gdk_screen_get_default ();
+ }
display = gdk_screen_get_display (screen);
state = g_slice_new0 (PopQueryTreeState);
- state->window = g_object_ref (gdk_screen_get_root_window (screen));
+ state->window = g_object_ref (gdk_screen_get_root_window (screen));
state->data = stack;
- pop_x_reply_watch_add (display,
+ pop_x_reply_watch_add (display,
query_tree_request, state,
- on_query_tree_reply, state);
+ on_query_tree_reply, state);
}
static void
@@ -575,13 +608,14 @@ print_toplevel (PopWindowStack *stack,
}
int
-main (int argc, char **argv)
+main (int argc,
+ char **argv)
{
PopWindowStack *stack;
int exit_code;
g_log_set_always_fatal (G_LOG_LEVEL_ERROR
- | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+ | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
g_type_init ();
gtk_init (&argc, &argv);
diff --git a/src/pop-window-view.c b/src/pop-window-view.c
index 9e7f3dd..dd36d91 100644
--- a/src/pop-window-view.c
+++ b/src/pop-window-view.c
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * 02111-1307, USA.
*/
#include "config.h"
#include "pop-window-view.h"
@@ -58,16 +58,19 @@ struct _PopWindowViewPrivate
gint width, height;
};
-static void pop_window_view_class_install_signals (PopWindowViewClass *view_class);
-static void pop_window_view_class_install_properties (PopWindowViewClass *view_class);
+static void pop_window_view_class_install_signals (
+ PopWindowViewClass *view_class);
+static void pop_window_view_class_install_properties (
+ PopWindowViewClass *view_class);
-static void pop_window_view_set_property (GObject * object,
- guint prop_id,
- const GValue * value,
- GParamSpec * pspec);
-static void pop_window_view_get_property (GObject * object,
- guint prop_id,
- GValue * value, GParamSpec * pspec);
+static void pop_window_view_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void pop_window_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
static void pop_window_view_do_finalize (GObject *object);
@@ -112,7 +115,7 @@ pop_window_view_class_init (PopWindowViewClass *view_class)
#if 0
static void
-pop_window_view_class_install_signals (PopWindowViewClass * view_class)
+pop_window_view_class_install_signals (PopWindowViewClass *view_class)
{
GObjectClass *object_class;
@@ -122,9 +125,11 @@ pop_window_view_class_install_signals (PopWindowViewClass * view_class)
g_signal_new ("foo", G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (PopWindowViewClass, foo),
- NULL, NULL, g_cclosure_marshal_VOID__NONE; G_TYPE_NONE, 0);
+ NULL, NULL, g_cclosure_marshal_VOID__NONE;
+ G_TYPE_NONE, 0);
view_class->foo = NULL;
}
+
#endif
static void
@@ -139,9 +144,10 @@ pop_window_view_class_install_properties (PopWindowViewClass *view_class)
param_spec = NULL;
#if 0
- param_spec = g_param_spec_ulong ("x-window-id", _("X Window ID"),
- _("A client-side identifier representing a "
- "server-side window"), 0, G_MAXULONG,
+ param_spec = g_param_spec_ulong ("x-window-id", _ ("X Window ID"),
+ _ (
+ "A client-side identifier representing a "
+ "server-side window"), 0, G_MAXULONG,
(gulong) POP_WINDOW_VIEW_INVALID_WINDOW,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_WINDOW, param_spec);
@@ -154,7 +160,7 @@ pop_window_view_init (PopWindowView *view)
g_assert (POP_IS_WINDOW_VIEW (view));
view->priv = G_TYPE_INSTANCE_GET_PRIVATE (view,
- POP_TYPE_WINDOW_VIEW,
+ POP_TYPE_WINDOW_VIEW,
PopWindowViewPrivate);
view->priv->event_listener = pop_event_listener_get_default ();
@@ -170,18 +176,18 @@ pop_window_view_set_property (GObject *object,
switch (prop_id)
{
- case PROP_WINDOW:
+ case PROP_WINDOW:
view = NULL;
- break;
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
pop_window_view_get_property (GObject *object,
- guint prop_id,
+ guint prop_id,
GValue *value,
GParamSpec *pspec)
{
@@ -189,12 +195,12 @@ pop_window_view_get_property (GObject *object,
switch (prop_id)
{
- case PROP_WINDOW:
+ case PROP_WINDOW:
view = NULL;
- break;
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -207,12 +213,16 @@ pop_window_view_do_finalize (GObject *object)
view = POP_WINDOW_VIEW (object);
if (view->priv->window != NULL)
- pop_window_view_unset_window (view);
+ {
+ pop_window_view_unset_window (view);
+ }
parent_class = G_OBJECT_CLASS (pop_window_view_parent_class);
if (parent_class->finalize != NULL)
- parent_class->finalize (object);
+ {
+ parent_class->finalize (object);
+ }
}
static gboolean
@@ -233,7 +243,7 @@ pop_window_get_initial_geometry (PopWindowView *view)
static cairo_surface_t *
pop_window_view_get_surface (PopWindowView *view)
{
- cairo_surface_t *surface;
+ cairo_surface_t *surface;
cairo_status_t status;
g_assert (POP_IS_WINDOW_VIEW (view));
@@ -253,11 +263,11 @@ pop_window_view_free_x_pixmap (PopWindowView *view)
Pixmap pixmap;
g_assert (POP_IS_WINDOW_VIEW (view));
-
+
surface = pop_window_view_get_surface (view);
g_assert (surface != NULL);
- pixmap = (Pixmap) cairo_xlib_surface_get_drawable (surface);
+ pixmap = (Pixmap) cairo_xlib_surface_get_drawable (surface);
XFreePixmap (GDK_WINDOW_XDISPLAY (view->priv->window), pixmap);
}
@@ -267,7 +277,9 @@ pop_window_view_destroy_pattern (PopWindowView *view)
g_assert (POP_IS_WINDOW_VIEW (view));
if (view->priv->pattern == NULL)
- return;
+ {
+ return;
+ }
pop_window_view_free_x_pixmap (view);
cairo_pattern_destroy (view->priv->pattern);
@@ -280,7 +292,9 @@ pop_window_view_destroy_clip_path (PopWindowView *view)
g_assert (POP_IS_WINDOW_VIEW (view));
if (view->priv->clip_path == NULL)
- return;
+ {
+ return;
+ }
cairo_path_destroy (view->priv->clip_path);
view->priv->clip_path = NULL;
@@ -292,7 +306,9 @@ pop_window_view_error_quark (void)
static GQuark error_quark = 0;
if (error_quark == 0)
- error_quark = g_quark_from_static_string ("pop-window");
+ {
+ error_quark = g_quark_from_static_string ("pop-window");
+ }
return error_quark;
}
@@ -302,7 +318,7 @@ pop_window_view_new (void)
{
PopWindowView *view;
- view = g_object_new (POP_TYPE_WINDOW_VIEW, NULL);
+ view = g_object_new (POP_TYPE_WINDOW_VIEW, NULL);
return view;
}
@@ -318,7 +334,9 @@ pop_window_view_redirect_window_off_screen (PopWindowView *view)
CompositeRedirectAutomatic);
gdk_flush ();
if (gdk_error_trap_pop ())
- return FALSE;
+ {
+ return FALSE;
+ }
return TRUE;
}
@@ -332,9 +350,9 @@ pop_window_view_fetch_window_pixmap (PopWindowView *view)
g_assert (POP_IS_WINDOW_VIEW (view));
gdk_error_trap_push ();
- pixmap =
- XCompositeNameWindowPixmap (GDK_WINDOW_XDISPLAY (view->priv->window),
- GDK_WINDOW_XWINDOW (view->priv->window));
+ pixmap =
+ XCompositeNameWindowPixmap (GDK_WINDOW_XDISPLAY (view->priv->window),
+ GDK_WINDOW_XWINDOW (view->priv->window));
gdk_flush ();
status = gdk_error_trap_pop ();
@@ -342,9 +360,9 @@ pop_window_view_fetch_window_pixmap (PopWindowView *view)
{
char error_message[64];
- XGetErrorText (GDK_WINDOW_XDISPLAY (view->priv->window),
+ XGetErrorText (GDK_WINDOW_XDISPLAY (view->priv->window),
status, error_message, sizeof (error_message) - 1);
- g_print ("could not name pixmap for window 0x%lx: %s\n",
+ g_print ("could not name pixmap for window 0x%lx: %s\n",
GDK_WINDOW_XWINDOW (view->priv->window),
error_message);
@@ -359,7 +377,7 @@ pop_window_view_create_pattern_from_window (PopWindowView *view)
{
GdkVisual *visual;
Pixmap pixmap;
- cairo_surface_t *surface;
+ cairo_surface_t *surface;
cairo_status_t status;
int width, height;
@@ -367,7 +385,7 @@ pop_window_view_create_pattern_from_window (PopWindowView *view)
g_assert (view->priv->window != NULL);
g_assert (view->priv->pattern == NULL);
- pixmap = pop_window_view_fetch_window_pixmap (view);
+ pixmap = pop_window_view_fetch_window_pixmap (view);
if (pixmap == POP_WINDOW_VIEW_INVALID_PIXMAP)
{
@@ -375,18 +393,19 @@ pop_window_view_create_pattern_from_window (PopWindowView *view)
return FALSE;
}
- gdk_drawable_get_size (GDK_DRAWABLE (view->priv->window),
+ gdk_drawable_get_size (GDK_DRAWABLE (view->priv->window),
&width, &height);
- visual = gdk_drawable_get_visual (GDK_DRAWABLE (view->priv->window));
+ visual = gdk_drawable_get_visual (GDK_DRAWABLE (view->priv->window));
surface = cairo_xlib_surface_create (GDK_WINDOW_XDISPLAY (view->priv->window),
- (Drawable) pixmap,
- GDK_VISUAL_XVISUAL (visual),
+ (Drawable) pixmap,
+ GDK_VISUAL_XVISUAL (visual),
width, height);
status = cairo_surface_status (surface);
if (status != CAIRO_STATUS_SUCCESS)
{
- g_print ("could create xlib surface for window: %s\n", cairo_status_to_string (status));
+ g_print ("could create xlib surface for window: %s\n",
+ cairo_status_to_string (status));
goto failed;
}
@@ -396,7 +415,8 @@ pop_window_view_create_pattern_from_window (PopWindowView *view)
status = cairo_pattern_status (view->priv->pattern);
if (status != CAIRO_STATUS_SUCCESS)
{
- g_print ("couldn't create cairo pattern: %s\n", cairo_status_to_string (status));
+ g_print ("couldn't create cairo pattern: %s\n",
+ cairo_status_to_string (status));
goto failed;
}
@@ -409,7 +429,7 @@ failed:
view->priv->pattern = NULL;
}
- XFreePixmap (GDK_WINDOW_XDISPLAY (view->priv->window),
+ XFreePixmap (GDK_WINDOW_XDISPLAY (view->priv->window),
pixmap);
return FALSE;
@@ -417,7 +437,8 @@ failed:
static XRectangle *
pop_window_view_get_tesselated_window_shape (PopWindowView *view,
- gint *number_of_rectangles)
+
+ gint*number_of_rectangles)
{
XRectangle *rectangles;
gint ordering;
@@ -431,18 +452,19 @@ pop_window_view_get_tesselated_window_shape (PopWindowView *view,
gdk_error_trap_push ();
rectangles = XShapeGetRectangles (GDK_WINDOW_XDISPLAY (view->priv->window),
GDK_WINDOW_XWINDOW (view->priv->window),
- ShapeBounding, number_of_rectangles,
+ ShapeBounding, number_of_rectangles,
&ordering);
gdk_flush ();
status = gdk_error_trap_pop ();
if (status != Success)
- return NULL;
+ {
+ return NULL;
+ }
return rectangles;
}
-
static gboolean
pop_window_view_set_clip_path_from_window (PopWindowView *view)
{
@@ -456,11 +478,14 @@ pop_window_view_set_clip_path_from_window (PopWindowView *view)
g_assert (POP_IS_WINDOW_VIEW (view));
g_assert (view->priv->clip_path == NULL);
- rectangles = pop_window_view_get_tesselated_window_shape (view,
- &number_of_rectangles);
+ rectangles = pop_window_view_get_tesselated_window_shape (view,
+ &
+ number_of_rectangles);
if (rectangles == NULL)
- return FALSE;
+ {
+ return FALSE;
+ }
surface = cairo_image_surface_create (CAIRO_FORMAT_A1,
view->priv->width, view->priv->height);
@@ -477,13 +502,11 @@ pop_window_view_set_clip_path_from_window (PopWindowView *view)
cairo_context = cairo_create (surface);
for (i = 0; i < number_of_rectangles; i++)
- {
- cairo_rectangle (cairo_context,
- rectangles[i].x,
- rectangles[i].y,
- rectangles[i].width,
- rectangles[i].height);
- }
+ cairo_rectangle (cairo_context,
+ rectangles[i].x,
+ rectangles[i].y,
+ rectangles[i].width,
+ rectangles[i].height);
XFree (rectangles);
view->priv->clip_path = cairo_copy_path_flat (cairo_context);
@@ -516,8 +539,8 @@ pop_window_view_set_clip_path_for_placeholder (PopWindowView *view)
cairo_context = cairo_create (surface);
- cairo_rectangle (cairo_context,
- view->priv->x, view->priv->y,
+ cairo_rectangle (cairo_context,
+ view->priv->x, view->priv->y,
view->priv->width, view->priv->height);
view->priv->clip_path = cairo_copy_path_flat (cairo_context);
@@ -536,7 +559,8 @@ pop_window_view_enable_window_geometry_reporting (PopWindowView *view)
event_mask = gdk_window_get_events (view->priv->window);
- gdk_window_set_events (view->priv->window, event_mask | GDK_STRUCTURE_MASK | GDK_EXPOSURE_MASK);
+ gdk_window_set_events (view->priv->window, event_mask | GDK_STRUCTURE_MASK |
+ GDK_EXPOSURE_MASK);
}
static void
@@ -576,10 +600,10 @@ pop_window_view_enable_window_damage_reporting (PopWindowView *view)
{
g_assert (POP_IS_WINDOW_VIEW (view));
- view->priv->damage =
- XDamageCreate (GDK_WINDOW_XDISPLAY (view->priv->window),
- GDK_WINDOW_XWINDOW (view->priv->window),
- XDamageReportBoundingBox);
+ view->priv->damage =
+ XDamageCreate (GDK_WINDOW_XDISPLAY (view->priv->window),
+ GDK_WINDOW_XWINDOW (view->priv->window),
+ XDamageReportBoundingBox);
}
static void
@@ -600,21 +624,27 @@ pop_window_view_window_redrawn (PopWindowView *view,
GdkWindow *window,
GdkRectangle *rectangle)
{
- g_print ("window 0x%lx redrawn (area: %dx%d+%d+%d)\n", GDK_WINDOW_XWINDOW (view->priv->window), rectangle->x, rectangle->y, rectangle->width, rectangle->height);
+ g_print ("window 0x%lx redrawn (area: %dx%d+%d+%d)\n",
+ GDK_WINDOW_XWINDOW (view->priv->window), rectangle->x, rectangle->y,
+ rectangle->width, rectangle->height);
if (view->priv->pattern == NULL)
- pop_window_view_create_pattern_from_window (view);
+ {
+ pop_window_view_create_pattern_from_window (view);
+ }
if (view->priv->clip_path == NULL)
- pop_window_view_set_clip_path_from_window (view);
+ {
+ pop_window_view_set_clip_path_from_window (view);
+ }
gdk_rectangle_union (&view->priv->damaged_area,
- rectangle,
+ rectangle,
&view->priv->damaged_area);
view->priv->is_damaged = TRUE;
}
-void
+void
pop_window_view_window_resized (PopWindowView *view)
{
gint old_width, old_height;
@@ -639,9 +669,9 @@ pop_window_view_window_resized (PopWindowView *view)
pop_window_view_set_clip_path_from_window (view);
}
- g_print ("window 0x%lx resized from (%dx%d) to (%dx%d)\n",
+ g_print ("window 0x%lx resized from (%dx%d) to (%dx%d)\n",
GDK_WINDOW_XWINDOW (view->priv->window),
- old_width, old_height,
+ old_width, old_height,
view->priv->width, view->priv->height);
}
@@ -654,35 +684,38 @@ pop_window_view_window_moved (PopWindowView *view)
old_y = view->priv->y;
gdk_window_get_position (GDK_DRAWABLE (view->priv->window),
- &view->priv->x,
- &view->priv->y);
+ &view->priv->x,
+ &view->priv->y);
- g_print ("window 0x%lx moved from (%d, %d) to (%d, %d)\n",
+ g_print ("window 0x%lx moved from (%d, %d) to (%d, %d)\n",
GDK_WINDOW_XWINDOW (view->priv->window),
old_x, old_y, view->priv->x, view->priv->y);
}
-static void
+static void
pop_window_view_window_shown (PopWindowView *view)
{
- g_print ("window 0x%lx is now visible\n",
+ g_print ("window 0x%lx is now visible\n",
GDK_WINDOW_XWINDOW (view->priv->window));
- view->priv->is_mapped = TRUE;
+ view->priv->is_mapped = TRUE;
#if 0
if (view->priv->pattern == NULL)
- pop_window_view_create_pattern_from_window (view);
+ {
+ pop_window_view_create_pattern_from_window (view);
+ }
if (view->priv->clip_path == NULL)
- pop_window_view_set_clip_path_from_window (view);
+ {
+ pop_window_view_set_clip_path_from_window (view);
+ }
#endif
}
static void
pop_window_view_window_hidden (PopWindowView *view)
{
-
view->priv->is_mapped = FALSE;
g_print ("window 0x%lx hidden\n", GDK_WINDOW_XWINDOW (view->priv->window));
pop_window_view_destroy_pattern (view);
@@ -714,10 +747,10 @@ pop_window_view_window_reshaped (PopWindowView *view)
}
if (view->priv->clip_path != NULL)
- {
- pop_window_view_destroy_clip_path (view);
- pop_window_view_set_clip_path_from_window (view);
- }
+ {
+ pop_window_view_destroy_clip_path (view);
+ pop_window_view_set_clip_path_from_window (view);
+ }
}
static void
@@ -732,55 +765,56 @@ pop_window_view_listen_to_window (PopWindowView *view)
{
gchar detailed_signal[sizeof ("window-XXXXXXXXXX::ffffffff")];
- g_print ("listening to window 0x%lx\n", GDK_WINDOW_XWINDOW (view->priv->window));
+ g_print ("listening to window 0x%lx\n",
+ GDK_WINDOW_XWINDOW (view->priv->window));
snprintf (detailed_signal, sizeof (detailed_signal),
"window-destroyed::%lx", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_connect_swapped (G_OBJECT (view->priv->event_listener),
detailed_signal,
- G_CALLBACK (pop_window_view_window_destroyed),
+ G_CALLBACK (pop_window_view_window_destroyed),
view);
snprintf (detailed_signal, sizeof (detailed_signal),
"window-shown::%lx", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_connect_swapped (G_OBJECT (view->priv->event_listener),
detailed_signal,
- G_CALLBACK (pop_window_view_window_shown),
+ G_CALLBACK (pop_window_view_window_shown),
view);
snprintf (detailed_signal, sizeof (detailed_signal),
"window-hidden::%lx", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_connect_swapped (G_OBJECT (view->priv->event_listener),
detailed_signal,
- G_CALLBACK (pop_window_view_window_hidden),
+ G_CALLBACK (pop_window_view_window_hidden),
view);
snprintf (detailed_signal, sizeof (detailed_signal),
"window-resized::%lx", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_connect_swapped (G_OBJECT (view->priv->event_listener),
detailed_signal,
- G_CALLBACK (pop_window_view_window_resized),
+ G_CALLBACK (pop_window_view_window_resized),
view);
snprintf (detailed_signal, sizeof (detailed_signal),
"window-reshaped::%lx", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_connect_swapped (G_OBJECT (view->priv->event_listener),
detailed_signal,
- G_CALLBACK (pop_window_view_window_reshaped),
+ G_CALLBACK (pop_window_view_window_reshaped),
view);
snprintf (detailed_signal, sizeof (detailed_signal),
"window-reparented::%lx", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_connect_swapped (G_OBJECT (view->priv->event_listener),
detailed_signal,
- G_CALLBACK (pop_window_view_window_reparented),
+ G_CALLBACK (pop_window_view_window_reparented),
view);
snprintf (detailed_signal, sizeof (detailed_signal),
"window-moved::%lx", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_connect_swapped (G_OBJECT (view->priv->event_listener),
detailed_signal,
- G_CALLBACK (pop_window_view_window_moved),
+ G_CALLBACK (pop_window_view_window_moved),
view);
snprintf (detailed_signal, sizeof (detailed_signal),
"window-redrawn::%lx", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_connect_swapped (G_OBJECT (view->priv->event_listener),
detailed_signal,
- G_CALLBACK (pop_window_view_window_redrawn),
+ G_CALLBACK (pop_window_view_window_redrawn),
view);
}
@@ -790,28 +824,36 @@ pop_window_view_ignore_window (PopWindowView *view)
g_print ("ignoring window 0x%lx\n", GDK_WINDOW_XWINDOW (view->priv->window));
g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->event_listener),
- G_CALLBACK (pop_window_view_window_destroyed),
+ G_CALLBACK (
+ pop_window_view_window_destroyed),
view);
g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->event_listener),
- G_CALLBACK (pop_window_view_window_shown),
+ G_CALLBACK (
+ pop_window_view_window_shown),
view);
g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->event_listener),
- G_CALLBACK (pop_window_view_window_hidden),
+ G_CALLBACK (
+ pop_window_view_window_hidden),
view);
g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->event_listener),
- G_CALLBACK (pop_window_view_window_resized),
+ G_CALLBACK (
+ pop_window_view_window_resized),
view);
g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->event_listener),
- G_CALLBACK (pop_window_view_window_reshaped),
+ G_CALLBACK (
+ pop_window_view_window_reshaped),
view);
g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->event_listener),
- G_CALLBACK (pop_window_view_window_reparented),
+ G_CALLBACK (
+ pop_window_view_window_reparented),
view);
g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->event_listener),
- G_CALLBACK (pop_window_view_window_moved),
+ G_CALLBACK (
+ pop_window_view_window_moved),
view);
g_signal_handlers_disconnect_by_func (G_OBJECT (view->priv->event_listener),
- G_CALLBACK (pop_window_view_window_redrawn),
+ G_CALLBACK (
+ pop_window_view_window_redrawn),
view);
}
@@ -839,7 +881,9 @@ pop_window_view_disable_window_status_reporting (PopWindowView *view)
g_assert (POP_IS_WINDOW_VIEW (view));
if ((view->priv->window == NULL) || GDK_WINDOW_DESTROYED (view->priv->window))
- return;
+ {
+ return;
+ }
pop_window_view_disable_window_damage_reporting (view);
@@ -851,8 +895,8 @@ pop_window_view_disable_window_status_reporting (PopWindowView *view)
gdk_error_trap_pop ();
}
-gboolean
-pop_window_view_set_window (PopWindowView *view,
+gboolean
+pop_window_view_set_window (PopWindowView *view,
GdkWindow *window)
{
g_return_val_if_fail (POP_IS_WINDOW_VIEW (view), FALSE);
@@ -874,7 +918,7 @@ pop_window_view_set_window (PopWindowView *view,
pop_window_view_disable_window_status_reporting (view);
view->priv->window = NULL;
return FALSE;
- }
+ }
if (!pop_window_view_redirect_window_off_screen (view))
{
@@ -884,10 +928,12 @@ pop_window_view_set_window (PopWindowView *view,
}
if (gdk_window_is_visible (view->priv->window))
- view->priv->is_mapped = TRUE;
+ {
+ view->priv->is_mapped = TRUE;
+ }
g_object_ref (window);
-
+
return TRUE;
}
@@ -957,15 +1003,19 @@ pop_window_view_get_difference (PopWindowView *view,
g_return_val_if_fail (POP_IS_WINDOW_VIEW (other_view), NULL);
if (!gdk_window_is_visible (view->priv->window))
- return gdk_region_new ();
+ {
+ return gdk_region_new ();
+ }
view_bounding_region = pop_window_view_get_bounding_region (view);
if (!gdk_window_is_visible (other_view->priv->window))
- return view_bounding_region;
+ {
+ return view_bounding_region;
+ }
other_view_bounding_region = pop_window_view_get_bounding_region (other_view);
- /* This is the part of the view that isn't overlapped by the
+ /* This is the part of the view that isn't overlapped by the
* other view
*/
gdk_region_subtract (view_bounding_region, other_view_bounding_region);
@@ -982,23 +1032,22 @@ static void
pop_window_view_render_placeholder_to_context (PopWindowView *view,
cairo_t *cairo_context)
{
-
cairo_translate (cairo_context, view->priv->x, view->priv->y);
cairo_set_source_rgba (cairo_context, 1.0, 1.0, 1.0, .75);
- cairo_rectangle (cairo_context, 0.0, 0.0,
+ cairo_rectangle (cairo_context, 0.0, 0.0,
view->priv->width, view->priv->height);
cairo_clip (cairo_context);
cairo_paint (cairo_context);
cairo_set_source_rgb (cairo_context, 0.0, 0.0, 0.0);
- cairo_rectangle (cairo_context, 0.0, 0.0,
+ cairo_rectangle (cairo_context, 0.0, 0.0,
view->priv->width, view->priv->height);
cairo_stroke (cairo_context);
}
-void
-pop_window_view_render_to_context (PopWindowView *view,
+void
+pop_window_view_render_to_context (PopWindowView *view,
cairo_t *cairo_context)
{
g_return_if_fail (POP_IS_WINDOW_VIEW (view));
@@ -1007,12 +1056,16 @@ pop_window_view_render_to_context (PopWindowView *view,
if (view->priv->pattern == NULL)
{
if (gdk_window_is_visible (view->priv->window))
- pop_window_view_render_placeholder_to_context (view, cairo_context);
+ {
+ pop_window_view_render_placeholder_to_context (view, cairo_context);
+ }
return;
}
- if (!view->priv->is_damaged && FALSE)
- return;
+ if ((!view->priv->is_damaged) && (FALSE))
+ {
+ return;
+ }
g_assert (view->priv->clip_path != NULL);
@@ -1036,26 +1089,34 @@ pop_window_view_render_to_context (PopWindowView *view,
}
void
-pop_window_view_get_size (PopWindowView *view,
- int *width,
+pop_window_view_get_size (PopWindowView *view,
+ int *width,
int *height)
{
-
if (width)
- *width = view->priv->width;
+ {
+ *width = view->priv->width;
+ }
if (height)
- *height = view->priv->height;
+ {
+ *height = view->priv->height;
+ }
}
void
-pop_window_view_get_position (PopWindowView *view,
- int *x,
+pop_window_view_get_position (PopWindowView *view,
+ int *x,
int *y)
{
if (x)
- *x = view->priv->x;
+ {
+ *x = view->priv->x;
+ }
if (y)
- *y = view->priv->y;
+ {
+ *y = view->priv->y;
+ }
}
+
diff --git a/src/pop-x-reply-watch.c b/src/pop-x-reply-watch.c
index 63a7087..634a793 100644
--- a/src/pop-x-reply-watch.c
+++ b/src/pop-x-reply-watch.c
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * 02111-1307, USA.
*/
#include "config.h"
@@ -64,7 +64,9 @@ pop_x_reply_watch_check (GSource *source)
x_reply_watch_source = (PopXReplyWatchSource *) source;
- last_processed_request_id = LastKnownRequestProcessed (GDK_DISPLAY_XDISPLAY (x_reply_watch_source->display));
+ last_processed_request_id = LastKnownRequestProcessed (GDK_DISPLAY_XDISPLAY (
+ x_reply_watch_source
+ ->display));
return last_processed_request_id >= x_reply_watch_source->request_id;
}
@@ -76,18 +78,20 @@ pop_x_reply_watch_dispatch (GSource *source,
{
PopXReplyWatchSource *x_reply_watch_source;
PopXReplyWatchFunc x_reply_watch_func;
-
+
if (callback == NULL)
- return FALSE;
-
+ {
+ return FALSE;
+ }
+
x_reply_watch_source = (PopXReplyWatchSource *) source;
x_reply_watch_func = (PopXReplyWatchFunc) callback;
- x_reply_watch_func (x_reply_watch_source->display,
+ x_reply_watch_func (x_reply_watch_source->display,
x_reply_watch_source->status,
x_reply_watch_source->error, user_data);
-
+
return FALSE;
}
@@ -98,7 +102,7 @@ pop_x_reply_watch_finalize (GSource *source)
PopXReplyWatchSource *x_reply_watch_source;
x_reply_watch_source = (PopXReplyWatchSource *) source;
-
+
pending_sources = g_object_get_data (G_OBJECT (x_reply_watch_source->display),
"pop-x-reply-sources");
@@ -108,10 +112,14 @@ pop_x_reply_watch_finalize (GSource *source)
pending_sources);
if (x_reply_watch_source->error != NULL)
- g_slice_free (XErrorEvent, x_reply_watch_source->error);
+ {
+ g_slice_free (XErrorEvent, x_reply_watch_source->error);
+ }
if (!g_source_is_destroyed (x_reply_watch_source->timeout_source))
- g_source_destroy (x_reply_watch_source->timeout_source);
+ {
+ g_source_destroy (x_reply_watch_source->timeout_source);
+ }
g_source_unref (x_reply_watch_source->timeout_source);
x_reply_watch_source->timeout_source = NULL;
@@ -127,7 +135,7 @@ static GSourceFuncs pop_x_reply_watch_funcs =
static XErrorHandler old_error_handler = NULL;
-typedef struct
+typedef struct
{
XErrorEvent *error;
PopXReplyWatchSource *source;
@@ -136,7 +144,8 @@ typedef struct
static gboolean
add_error_to_source_idle_handler (gpointer data)
{
- PopXReplyWatchErrorAndSource *error_and_source = (PopXReplyWatchErrorAndSource *) data;
+ PopXReplyWatchErrorAndSource *error_and_source = (
+ PopXReplyWatchErrorAndSource *) data;
g_assert (error_and_source->source != NULL);
@@ -180,7 +189,7 @@ pop_x_reply_watch_error_handler (Display *x_display,
idle_source = g_idle_source_new ();
g_source_set_priority (idle_source, 0);
- g_source_set_callback (idle_source,
+ g_source_set_callback (idle_source,
add_error_to_source_idle_handler,
error_and_source, NULL);
g_source_attach (idle_source, g_source_get_context (source));
@@ -191,7 +200,9 @@ pop_x_reply_watch_error_handler (Display *x_display,
}
if (old_error_handler != NULL)
- return old_error_handler (x_display, error);
+ {
+ return old_error_handler (x_display, error);
+ }
return 0;
}
@@ -214,7 +225,7 @@ pop_x_reply_watch_setup_error_handler (void)
}
static void
-pop_x_reply_watch_source_register_with_display (GSource *source,
+pop_x_reply_watch_source_register_with_display (GSource *source,
GdkDisplay *display)
{
GList *pending_sources;
@@ -237,7 +248,7 @@ pop_x_reply_watch_source_new (GdkDisplay *display,
gpointer request_func_data)
{
GSource *source;
- gulong request_id, next_request_id;
+ gulong request_id, next_request_id;
PopXReplyWatchSource *x_reply_watch_source;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
@@ -270,35 +281,40 @@ pop_x_reply_watch_source_new (GdkDisplay *display,
}
/* if we don't get an answer back in a quarter of a second, force
- * a round trip to ensure the request id gets incremented so the
+ * a round trip to ensure the request id gets incremented so the
* source gets dispatched
*/
x_reply_watch_source->timeout_source = g_timeout_source_new (250);
- g_source_set_callback (x_reply_watch_source->timeout_source,
- (GSourceFunc) gdk_display_sync, display, NULL);
- g_source_attach (x_reply_watch_source->timeout_source, g_source_get_context (source));
-
+ g_source_set_callback (x_reply_watch_source->timeout_source,
+ (GSourceFunc) gdk_display_sync, display, NULL);
+ g_source_attach (x_reply_watch_source->timeout_source,
+ g_source_get_context (source));
+
return source;
}
guint
-pop_x_reply_watch_add_full (gint priority,
- GdkDisplay *display,
- PopXRequestFunc request_func,
- gpointer request_func_data,
+pop_x_reply_watch_add_full (gint priority,
+ GdkDisplay *display,
+ PopXRequestFunc request_func,
+ gpointer request_func_data,
PopXReplyWatchFunc reply_func,
- gpointer reply_func_data,
- GDestroyNotify notify)
+ gpointer reply_func_data,
+ GDestroyNotify notify)
{
GSource *source;
guint id;
- source = pop_x_reply_watch_source_new (display, request_func, request_func_data);
+ source = pop_x_reply_watch_source_new (display, request_func,
+ request_func_data);
if (priority != G_PRIORITY_DEFAULT)
- g_source_set_priority (source, priority);
+ {
+ g_source_set_priority (source, priority);
+ }
- g_source_set_callback (source, (GSourceFunc) reply_func, reply_func_data, notify);
+ g_source_set_callback (source, (GSourceFunc) reply_func, reply_func_data,
+ notify);
id = g_source_attach (source, NULL);
g_source_unref (source);
@@ -306,13 +322,14 @@ pop_x_reply_watch_add_full (gint priority,
}
guint
-pop_x_reply_watch_add (GdkDisplay *display,
- PopXRequestFunc request_func,
- gpointer request_func_data,
+pop_x_reply_watch_add (GdkDisplay *display,
+ PopXRequestFunc request_func,
+ gpointer request_func_data,
PopXReplyWatchFunc reply_func,
- gpointer reply_func_data)
+ gpointer reply_func_data)
{
return pop_x_reply_watch_add_full (G_PRIORITY_DEFAULT,
display, request_func, request_func_data,
reply_func, reply_func_data, NULL);
}
+