[Xfce4-commits] <xfce4-wmdock-plugin:master> Implementation of dockapp movement via event handler.

Andre Ellguth noreply at xfce.org
Mon Nov 4 13:36:23 CET 2013


Updating branch refs/heads/master
         to 2cb7071d1af48b065f8e46e279d6586806b3736e (commit)
       from d3e1aec12fe7f64c24a0c86ec352c04fc2d988c8 (commit)

commit 2cb7071d1af48b065f8e46e279d6586806b3736e
Author: Andre Ellguth <andre at ellguth.com>
Date:   Mon Sep 30 18:37:52 2013 +0200

    Implementation of dockapp movement via event handler.

 panel-plugin/catchwindow.c |    4 ++--
 panel-plugin/dockapp.c     |   20 +++++++++++++++-----
 panel-plugin/dockapp.h     |    4 ++--
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/panel-plugin/catchwindow.c b/panel-plugin/catchwindow.c
index 2a2252e..f494de4 100644
--- a/panel-plugin/catchwindow.c
+++ b/panel-plugin/catchwindow.c
@@ -187,8 +187,8 @@ void wmdock_window_open(WnckScreen *s, WnckWindow *w)
 
 		dapp->name = g_strdup(wnck_window_get_name(w));
 		dapp->cmd = cmd;
-		dapp->width = wi;
-		dapp->height = he;
+		dapp->width = (gint) wi;
+		dapp->height = (gint) he;
 
 		if(wmdockIcon && !IS_PANELOFF(wmdock)) {
 			gtk_widget_destroy(wmdockIcon);
diff --git a/panel-plugin/dockapp.c b/panel-plugin/dockapp.c
index da09029..222fd6f 100644
--- a/panel-plugin/dockapp.c
+++ b/panel-plugin/dockapp.c
@@ -49,7 +49,8 @@ static GtkTargetEntry targetList[] = {
 		{ "INTEGER", 0, 0 }
 };
 static guint nTargets = G_N_ELEMENTS (targetList);
-static DockappNode *dappOnMotion = NULL, *dappDummy = NULL;;
+static DockappNode *dappOnMotion = NULL, *dappDummy = NULL;
+static gint motionstartx = 0, motionstarty = 0;
 
 /**
  * Get the x coordinate child dockapp.
@@ -298,6 +299,8 @@ void wmdock_dockapp_button_press_handler(GtkWidget *tile, GdkEventButton *ev, Do
 {
 	debug("dockapp.c: Window button press event (dapp: `%s')", dapp->name);
 	dappOnMotion = dapp;
+	motionstartx = (gint) ev->x;
+	motionstarty = (gint) ev->y;
 	gtk_window_set_keep_above(GTK_WINDOW(dapp->tile), TRUE);
 }
 
@@ -337,15 +340,18 @@ void wmdock_dockapp_button_release_handler(GtkWidget *tile, GdkEventButton *ev,
  */
 void wmdock_dockapp_motion_notify_handler(GtkWidget *tile, GdkEventMotion *ev, DockappNode *dapp)
 {
-	gint gluepos;
+	gint gluepos, x, y, posx, posy;
 	DockappNode *dappSnap = NULL;
 	GdkModifierType m;
 
 	debug("dockapp.c: Window motion notify event (dapp: `%s')", dapp->name);
 
-	gdk_window_get_pointer(tile->window, NULL, NULL, &m);
-	if(tile && (m & GDK_BUTTON1_MASK)) {
-
+	gdk_window_get_pointer(dapp->tile->window, &x, &y, &m);
+	if(tile && dappOnMotion && (m & GDK_BUTTON1_MASK)) {
+		gtk_window_get_position(GTK_WINDOW(dapp->tile), &posx, &posy);
+		debug("dockapp.c: Mouse x: %d,  Mouse y: %d,  Dapp x: %d, Dapp y: %d,  Msx: %d,  Msy: %d",
+				x, y, posx, posy, motionstartx, motionstarty);
+		gtk_window_move(GTK_WINDOW(dapp->tile), posx - (motionstartx - x), posy - (motionstarty - y));
 	}
 
 	if(dappOnMotion == dapp) {
@@ -643,10 +649,14 @@ void wmdock_update_tile_background(DockappNode *dapp)
 		return;
 
 	gtk_widget_set_app_paintable(GTK_WIDGET(dapp->evbox), TRUE);
+	gtk_widget_set_app_paintable(GTK_WIDGET(dapp->bg), TRUE);
 	gdk_window_set_back_pixmap(GTK_WIDGET(dapp->evbox)->window, dapp->bgimg, FALSE);
+	gdk_window_set_back_pixmap(GTK_WIDGET(dapp->bg)->window, dapp->bgimg, FALSE);
 
 	if (GTK_WIDGET_FLAGS(GTK_WIDGET(dapp->evbox)) & GTK_MAPPED)
 		gtk_widget_queue_draw(GTK_WIDGET(dapp->evbox));
+	if (GTK_WIDGET_FLAGS(GTK_WIDGET(dapp->bg)) & GTK_MAPPED)
+		gtk_widget_queue_draw(GTK_WIDGET(dapp->bg));
 }
 
 
diff --git a/panel-plugin/dockapp.h b/panel-plugin/dockapp.h
index 2687107..7de5de3 100644
--- a/panel-plugin/dockapp.h
+++ b/panel-plugin/dockapp.h
@@ -37,8 +37,8 @@ typedef struct _dockapp DockappNode;
 struct _dockapp {
 	GtkSocket       *s;
 	GdkNativeWindow i;
-	int             width;
-	int             height;
+	gint            width;
+	gint            height;
 	GtkWidget       *bg;
 	GdkPixmap       *bgimg;
 	GtkWidget       *evbox;


More information about the Xfce4-commits mailing list