[ekiga] Moved gdk_window_set_always_on_top to lib/gui/gmwindow.*



commit ea49f61b8f0d3705a15141002fcf7f4b70ed9481
Author: Julien Puydt <jpuydt gnome org>
Date:   Tue Oct 20 17:38:47 2009 +0200

    Moved gdk_window_set_always_on_top to lib/gui/gmwindow.*
    
    It involved taking a helper function too, and I renamed it
    to gm_window_set_always_on_top so the name is less misleading.

 lib/gui/gmwindow.c      |   53 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/gui/gmwindow.h      |    7 ++++++
 src/gui/main_window.cpp |    4 +-
 src/gui/misc.cpp        |   49 -------------------------------------------
 src/gui/misc.h          |    5 ----
 5 files changed, 62 insertions(+), 56 deletions(-)
---
diff --git a/lib/gui/gmwindow.c b/lib/gui/gmwindow.c
index f212a33..aacfabd 100644
--- a/lib/gui/gmwindow.c
+++ b/lib/gui/gmwindow.c
@@ -44,6 +44,10 @@
 #include <string.h>
 #include <stdlib.h>
 
+#ifndef WIN32
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
+#endif
 
 /*
  * The GmWindow
@@ -496,3 +500,52 @@ gm_window_get_hide_on_delete (GmWindow *window)
   return window->priv->hide_on_delete;
 }
 
+// helper copied from gdk
+static void gdk_wmspec_change_state (gboolean add,
+				     GdkWindow *window,
+				     GdkAtom state1,
+				     GdkAtom state2);
+
+void
+gm_window_set_always_on_top (GdkWindow *window,
+			     gboolean enable)
+{
+#ifndef WIN32
+  gdk_wmspec_change_state (enable, window,
+			   gdk_atom_intern ("_NET_WM_STATE_ABOVE", FALSE), 0);
+#endif
+}
+
+/* Stolen from GDK */
+#ifndef WIN32
+static void
+gdk_wmspec_change_state (gboolean add,
+			 GdkWindow *window,
+			 GdkAtom state1,
+			 GdkAtom state2)
+{
+  GdkDisplay *display = 
+    gdk_screen_get_display (gdk_drawable_get_screen (GDK_DRAWABLE (window)));
+  XEvent xev;
+  
+#define _NET_WM_STATE_REMOVE        0    /* remove/unset property */
+#define _NET_WM_STATE_ADD           1    /* add/set property */
+#define _NET_WM_STATE_TOGGLE        2    /* toggle property  */  
+  
+  xev.xclient.type = ClientMessage;
+  xev.xclient.serial = 0;
+  xev.xclient.send_event = True;
+  xev.xclient.window = GDK_WINDOW_XID (window);
+  xev.xclient.message_type = 
+    gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
+  xev.xclient.format = 32;
+  xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+  xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
+  xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
+  
+  XSendEvent (GDK_WINDOW_XDISPLAY (window),
+	      GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (gdk_drawable_get_screen (GDK_DRAWABLE (window)))),
+	      False, SubstructureRedirectMask | SubstructureNotifyMask,
+	      &xev);
+}
+#endif
diff --git a/lib/gui/gmwindow.h b/lib/gui/gmwindow.h
index 343bf49..af90955 100644
--- a/lib/gui/gmwindow.h
+++ b/lib/gui/gmwindow.h
@@ -126,6 +126,13 @@ void gm_window_set_hide_on_delete (GmWindow *window,
  */
 gboolean gm_window_get_hide_on_delete (GmWindow *window);		    
 
+/** Makes sure the given window is always on top
+ * @param window is a GdkWindow
+ * @param enable whether to set or unset the always on top state
+ */
+void gm_window_set_always_on_top (GdkWindow* window,
+				  gboolean enable);
+
 G_END_DECLS
 
 #endif
diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp
index f7bea15..696c9ff 100644
--- a/src/gui/main_window.cpp
+++ b/src/gui/main_window.cpp
@@ -2547,7 +2547,7 @@ ekiga_main_window_set_stay_on_top (EkigaMainWindow *mw,
   g_return_if_fail (EKIGA_IS_MAIN_WINDOW (mw));
 
   /* Update the stay-on-top attribute */
-  gdk_window_set_always_on_top (GTK_WIDGET (mw)->window, stay_on_top);
+  gm_window_set_always_on_top (GTK_WIDGET (mw)->window, stay_on_top);
 }
 
 static void 
@@ -3796,7 +3796,7 @@ ekiga_main_window_show (GtkWidget *widget)
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (widget);
   if (gm_conf_get_bool (VIDEO_DISPLAY_KEY "stay_on_top") && mw->priv->current_call)
-    gdk_window_set_always_on_top (widget->window, TRUE);
+    gm_window_set_always_on_top (widget->window, TRUE);
   GTK_WIDGET_CLASS (ekiga_main_window_parent_class)->show (widget);
 }
 
diff --git a/src/gui/misc.cpp b/src/gui/misc.cpp
index fcd6a0b..2533d5f 100644
--- a/src/gui/misc.cpp
+++ b/src/gui/misc.cpp
@@ -46,11 +46,6 @@
 #include "gmdialog.h"
 #include "gmconf.h"
 
-#ifndef WIN32
-#include <gdk/gdkx.h>
-#include <X11/Xlib.h>
-#endif
-
 #include <glib/gi18n.h>
 
 
@@ -76,50 +71,6 @@ gnomemeeting_button_new (const char *lbl,
 }
 
 
-/* Stolen from GDK */
-#ifndef WIN32
-static void
-gdk_wmspec_change_state (gboolean add,
-			 GdkWindow *window,
-			 GdkAtom state1,
-			 GdkAtom state2)
-{
-  GdkDisplay *display = 
-    gdk_screen_get_display (gdk_drawable_get_screen (GDK_DRAWABLE (window)));
-  XEvent xev;
-  
-#define _NET_WM_STATE_REMOVE        0    /* remove/unset property */
-#define _NET_WM_STATE_ADD           1    /* add/set property */
-#define _NET_WM_STATE_TOGGLE        2    /* toggle property  */  
-  
-  xev.xclient.type = ClientMessage;
-  xev.xclient.serial = 0;
-  xev.xclient.send_event = True;
-  xev.xclient.window = GDK_WINDOW_XID (window);
-  xev.xclient.message_type = 
-    gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
-  xev.xclient.format = 32;
-  xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
-  xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
-  xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
-  
-  XSendEvent (GDK_WINDOW_XDISPLAY (window),
-	      GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (gdk_drawable_get_screen (GDK_DRAWABLE (window)))),
-	      False, SubstructureRedirectMask | SubstructureNotifyMask,
-	      &xev);
-}
-#endif
-
-
-void
-gdk_window_set_always_on_top (GdkWindow *window, 
-			      gboolean enable)
-{
-#ifndef WIN32
-  gdk_wmspec_change_state (enable, window, 
-			   gdk_atom_intern ("_NET_WM_STATE_ABOVE", FALSE), 0);
-#endif
-}
 
 
 gboolean 
diff --git a/src/gui/misc.h b/src/gui/misc.h
index b657aeb..72b4ab5 100644
--- a/src/gui/misc.h
+++ b/src/gui/misc.h
@@ -53,11 +53,6 @@ gnomemeeting_button_new (const char *label,
 			 GtkWidget *pixmap);
 
 
-void gdk_window_set_always_on_top (GdkWindow *window, 
-				   gboolean enable);
-
-
-
 /* DESCRIPTION  :  / 
  * BEHAVIOR     :  Returns TRUE if the specified window is present and visible
  *                 on the current workspace, FALSE otherwise.



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