[ekiga/ds-gtk3-new] X: remove the GdkGC handling



commit f8e39cbbcc92ecce9ca51da1a1e5899b3cbb6033
Author: Damien Sandras <dsandras beip be>
Date:   Sat Mar 16 15:45:20 2013 +0100

    X: remove the GdkGC handling
    
    Many thannks to Víctor Manuel Jáquez Leal <vjaquez _AT- igalia _DOT-
    com>.
    
    The main reason behind to keep depending on GTK+-2.0 was because the
    rendering subsystem demands the X graphic context of the widget, but
    GTK+-3.0 remove the GdkGC handling in favor of Cairo.
    
    Nevertheless, in order to keep the same functionality without
    refactoring all the video output subsystem, we can create the X graphic
    context of our widgets.
    
    This patch creates our own GC, using the Xlib function XCreateGC
    directly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685404
    
    This patch also contains other GTK+-3.0 porting fixes.

 lib/engine/gui/gtk-frontend/call-window.cpp |   27 +++++++++++++-----
 lib/engine/gui/gtk-frontend/ext-window.cpp  |   40 ++++++++-------------------
 2 files changed, 32 insertions(+), 35 deletions(-)
---
diff --git a/lib/engine/gui/gtk-frontend/call-window.cpp b/lib/engine/gui/gtk-frontend/call-window.cpp
index b5b67c1..a6e1037 100644
--- a/lib/engine/gui/gtk-frontend/call-window.cpp
+++ b/lib/engine/gui/gtk-frontend/call-window.cpp
@@ -134,6 +134,9 @@ struct _EkigaCallWindowPrivate
   GtkObject *adj_input_volume;
   GtkObject *adj_output_volume;
 #endif
+#ifndef WIN32
+  GC gc;
+#endif
 
   unsigned int levelmeter_timeout_id;
   unsigned int timeout_id;
@@ -1892,8 +1895,8 @@ gm_cw_audio_settings_window_new (EkigaCallWindow *cw)
   gtk_scale_set_draw_value (GTK_SCALE (hscale_play), false);
   gtk_box_pack_start (GTK_BOX (small_vbox), hscale_play, true, true, 0);
 
-  cw->priv->output_signal = gm_level_meter_new ();
-  gtk_box_pack_start (GTK_BOX (small_vbox), cw->priv->output_signal, true, true, 0);
+  //cw->priv->output_signal = gm_level_meter_new ();
+  //gtk_box_pack_start (GTK_BOX (small_vbox), cw->priv->output_signal, true, true, 0);
   gtk_box_pack_start (GTK_BOX (hbox), small_vbox, true, true, 2);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 3);
 
@@ -1926,8 +1929,8 @@ gm_cw_audio_settings_window_new (EkigaCallWindow *cw)
   gtk_scale_set_draw_value (GTK_SCALE (hscale_rec), false);
   gtk_box_pack_start (GTK_BOX (small_vbox), hscale_rec, true, true, 0);
 
-  cw->priv->input_signal = gm_level_meter_new ();
-  gtk_box_pack_start (GTK_BOX (small_vbox), cw->priv->input_signal, true, true, 0);
+//  cw->priv->input_signal = gm_level_meter_new ();
+//  gtk_box_pack_start (GTK_BOX (small_vbox), cw->priv->input_signal, true, true, 0);
   gtk_box_pack_start (GTK_BOX (hbox), small_vbox, true, true, 2);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, false, false, 3);
 
@@ -2516,6 +2519,9 @@ ekiga_call_window_init (EkigaCallWindow *cw)
   cw->priv->timeout_id = -1;
   cw->priv->levelmeter_timeout_id = -1;
   cw->priv->calling_state = Standby;
+#ifndef WIN32
+  cw->priv->gc = NULL;
+#endif
 
   g_signal_connect (cw, "delete_event",
                    G_CALLBACK (ekiga_call_window_delete_event_cb), NULL);
@@ -2563,12 +2569,19 @@ ekiga_call_window_draw (GtkWidget *widget,
   display_info.y = a.y;
 
 #ifdef WIN32
-  display_info.hwnd = ((HWND) GDK_WINDOW_HWND (video_widget->window));
+  display_info.hwnd = ((HWND) GDK_WINDOW_HWND (gtk_widget_get_window (video_widget)));
 #else
-  display_info.window = GDK_WINDOW_XID (gtk_widget_get_window (video_widget));
-
+  display_info.window = gdk_x11_window_get_xid (gtk_widget_get_window (video_widget));
   g_return_val_if_fail (display_info.window != 0, handled);
 
+  if (!cw->priv->gc) {
+    Display *display;
+    display = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (video_widget));
+    cw->priv->gc = XCreateGC(display, display_info.window, 0, 0);
+    g_return_val_if_fail (cw->priv->gc != NULL, handled);
+  }
+  display_info.gc = cw->priv->gc;
+
   gdk_flush();
 #endif
 
diff --git a/lib/engine/gui/gtk-frontend/ext-window.cpp b/lib/engine/gui/gtk-frontend/ext-window.cpp
index d005a72..f7384dd 100644
--- a/lib/engine/gui/gtk-frontend/ext-window.cpp
+++ b/lib/engine/gui/gtk-frontend/ext-window.cpp
@@ -40,7 +40,7 @@ G_DEFINE_TYPE (EkigaExtWindow, ekiga_ext_window, GTK_TYPE_WINDOW);
 
 struct _EkigaExtWindowPrivate {
 #ifndef WIN32
-  GdkGC* gc;
+  GC gc;
 #endif
   GtkWidget *video, *zin, *zout;
   boost::shared_ptr<Ekiga::VideoOutputCore> vocore;
@@ -146,23 +146,6 @@ constructor (GType type, guint n_properties, GObjectConstructParam *params)
 }
 
 static void
-dispose (GObject* gobject)
-{
-  EkigaExtWindow *ew = EKIGA_EXT_WINDOW (gobject);
-
-#ifndef WIN32
-  if (ew->priv->gc) {
-    g_object_unref (ew->priv->gc);
-    ew->priv->gc = NULL;
-  }
-#endif
-
-  clear_display_info (ew);
-
-  G_OBJECT_CLASS (ekiga_ext_window_parent_class)->dispose (gobject);
-}
-
-static void
 finalize (GObject* gobject)
 {
   EkigaExtWindow *ew = EKIGA_EXT_WINDOW (gobject);
@@ -197,15 +180,15 @@ show (GtkWidget *widget)
 }
 
 static gboolean
-expose_event (GtkWidget *widget, GdkEventExpose *event)
+draw_event (GtkWidget *widget,
+            cairo_t *context)
 {
   EkigaExtWindow *ew = EKIGA_EXT_WINDOW (widget);
   Ekiga::DisplayInfo info;
   gboolean handled;
   GtkAllocation alloc;
 
-  handled = GTK_WIDGET_CLASS (ekiga_ext_window_parent_class)->expose_event (widget,
-                                                                            event);
+  handled = (*GTK_WIDGET_CLASS (ekiga_ext_window_parent_class)->draw) (widget, context);
 
   gtk_widget_get_allocation (ew->priv->video, &alloc);
   info.x = alloc.x;
@@ -214,15 +197,17 @@ expose_event (GtkWidget *widget, GdkEventExpose *event)
 #ifdef WIN32
   info.hwnd = (HWND) GDK_WINDOW_HWND (gtk_widget_get_window (ew->priv->video));
 #else
+  info.window = gdk_x11_window_get_xid (gtk_widget_get_window (ew->priv->video));
+  g_return_val_if_fail (info.window != 0, handled);
+
   if (!ew->priv->gc) {
-    ew->priv->gc = gdk_gc_new (gtk_widget_get_window (ew->priv->video));
+    Display *display;
+    display = GDK_WINDOW_XDISPLAY (gtk_widget_get_window (ew->priv->video));
+    ew->priv->gc = XCreateGC(display, info.window, 0, 0);
     g_return_val_if_fail (ew->priv->gc != NULL, handled);
   }
 
-  info.gc = GDK_GC_XGC (ew->priv->gc);
-
-  info.window = GDK_WINDOW_XWINDOW (gtk_widget_get_window (ew->priv->video));
-  g_return_val_if_fail (info.window != 0, handled);
+  info.gc = ew->priv->gc;
 
   gdk_flush ();
 #endif
@@ -243,11 +228,10 @@ ekiga_ext_window_class_init (EkigaExtWindowClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->constructor = constructor;
-  object_class->dispose = dispose;
   object_class->finalize = finalize;
 
   widget_class->show = show;
-  widget_class->expose_event = expose_event;
+  widget_class->draw = draw_event;
   widget_class->focus_in_event = focus_in_event;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]