[Xfce4-commits] <xfce4-wmdock-plugin:master> Disabled the posibilty to drag the dockapp by pressing the ALT key. Enabled motion dragging for smaller dockapps (less than 64 pixels).
Andre Ellguth
noreply at xfce.org
Mon Nov 4 13:36:30 CET 2013
Updating branch refs/heads/master
to cf255cb4dffd80d4dea7a5d9a4495d9d2d54009b (commit)
from 7ee37205b7cc23156e9d02b1622adaa193a96b2b (commit)
commit cf255cb4dffd80d4dea7a5d9a4495d9d2d54009b
Author: Andre Ellguth <andre at ellguth.com>
Date: Fri Oct 11 17:39:36 2013 +0200
Disabled the posibilty to drag the dockapp by pressing the ALT key.
Enabled motion dragging for smaller dockapps (less than 64 pixels).
panel-plugin/catchwindow.c | 5 +-
panel-plugin/dockapp.c | 232 ++++++++++++++++++++++----------------------
panel-plugin/dockapp.h | 3 -
panel-plugin/rcfile.c | 25 ++---
panel-plugin/rcfile.h | 3 +
5 files changed, 132 insertions(+), 136 deletions(-)
diff --git a/panel-plugin/catchwindow.c b/panel-plugin/catchwindow.c
index 28559b2..a0926bf 100644
--- a/panel-plugin/catchwindow.c
+++ b/panel-plugin/catchwindow.c
@@ -232,11 +232,8 @@ void wmdock_window_open(WnckScreen *s, WnckWindow *w)
if( IS_PANELOFF(wmdock) ) {
wmdock_order_dockapps(wmdock_get_primary_anchor_dockapp());
- /* Setup the event handler for the window. */
+ /* Setup the event-after handler for the window. */
g_signal_connect(G_OBJECT(dapp->tile), "event-after", G_CALLBACK(wmdock_dockapp_event_after_handler), dapp);
- g_signal_connect(G_OBJECT(dapp->tile), "motion_notify_event", G_CALLBACK(wmdock_dockapp_motion_notify_handler), dapp);
- g_signal_connect(G_OBJECT(dapp->tile), "button_press_event", G_CALLBACK(wmdock_dockapp_button_press_handler), dapp);
- g_signal_connect(G_OBJECT(dapp->tile), "button_release_event", G_CALLBACK(wmdock_dockapp_button_release_handler), dapp);
}
/* Clear the noisy background. */
wmdock_redraw_dockapp(dapp);
diff --git a/panel-plugin/dockapp.c b/panel-plugin/dockapp.c
index e6f4aaa..2f5f448 100644
--- a/panel-plugin/dockapp.c
+++ b/panel-plugin/dockapp.c
@@ -248,6 +248,95 @@ static gboolean wmdock_replace_tile_dummy(DockappNode *dapp)
}
+/**
+ * Event handle for the tile in panel off mode (button_press)
+ *
+ * @param tile The window of the event.
+ * @param ev GdkEventButton.
+ * @param dapp DockAppNode of the event.
+ */
+static void wmdock_dockapp_button_press_handler(GtkWidget *window, GdkEventButton *ev, DockappNode *dapp)
+{
+ 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);
+ gtk_window_set_keep_below(GTK_WINDOW(dapp->tile), FALSE);
+}
+
+
+/**
+ * Event handle for the tile in panel off mode (button_release)
+ *
+ * @param tile The window of the event.
+ * @param ev GdkEventButton.
+ * @param dapp DockAppNode of the event.
+ */
+static void wmdock_dockapp_button_release_handler(GtkWidget *window, GdkEventButton *ev, DockappNode *dapp)
+{
+ debug("dockapp.c: Window button release event (dapp: `%s')", dapp->name);
+ if(wmdock_replace_tile_dummy(dapp) == TRUE) {
+ debug("dockapp.c: Replaceable dummy tile found.");
+ wmdock_order_dockapps(wmdock_get_primary_anchor_dockapp() ? wmdock_get_primary_anchor_dockapp() : dapp);
+ } else {
+ wmdock_remove_anchors_tile_dummy();
+ wmdock_set_autoposition_dockapp(dapp, wmdock_get_parent_dockapp(dapp));
+ }
+ if(dappDummy) {
+ gtk_widget_hide(dappDummy->tile);
+ }
+
+ dappOnMotion = NULL;
+ gtk_window_set_keep_above(GTK_WINDOW(dapp->tile), FALSE);
+ gtk_window_set_keep_below(GTK_WINDOW(dapp->tile), TRUE);
+}
+
+
+/**
+ * Event handle for the tile in panel off mode (motion_notify)
+ *
+ * @param tile The window of the event.
+ * @param ev GdkEventButton.
+ * @param dapp DockAppNode of the event.
+ */
+static void wmdock_dockapp_motion_notify_handler(GtkWidget *window, GdkEventMotion *ev, DockappNode *dapp)
+{
+ 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(dapp->tile->window, &x, &y, &m);
+ if(window && 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) {
+ wmdock_remove_anchors_tile_dummy();
+ dappSnap = wmdock_get_snapable_dockapp(dapp, &gluepos);
+ if(dappSnap) {
+ debug("dockapp.c: Snapable dockapp `%s' for dockapp `%s', glue: %d.", dappSnap->name, dapp->name, gluepos);
+ if(!dappDummy) {
+ dappDummy = g_new0(DockappNode, 1);
+ dappDummy->name = g_strdup(DOCKAPP_DUMMY_TITLE);
+ dappDummy->tile = wmdock_create_tile_dummy();
+ }
+
+ dappSnap->glue[gluepos] = dappDummy;
+ wmdock_order_dockapps(dappDummy);
+ gtk_widget_show_all(dappDummy->tile);
+ } else if(dappDummy) {
+ gtk_widget_hide(dappDummy->tile);
+ }
+ }
+}
+
+
/* Return the translation from glue int postion to glue name.
*
* @param gluePos Position to be translated.
@@ -342,122 +431,17 @@ DockappNode *wmdock_get_primary_anchor_dockapp()
/**
- * Event handle for the tile in panel off mode (button_press)
- *
- * @param tile The window of the event.
- * @param ev GdkEventButton.
- * @param dapp DockAppNode of the event.
- */
-void wmdock_dockapp_button_press_handler(GtkWidget *tile, GdkEventButton *ev, DockappNode *dapp)
-{
- 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);
-}
-
-
-/**
- * Event handle for the tile in panel off mode (button_release)
- *
- * @param tile The window of the event.
- * @param ev GdkEventButton.
- * @param dapp DockAppNode of the event.
- */
-void wmdock_dockapp_button_release_handler(GtkWidget *tile, GdkEventButton *ev, DockappNode *dapp)
-{
- debug("dockapp.c: Window button release event (dapp: `%s')", dapp->name);
- if(wmdock_replace_tile_dummy(dapp) == TRUE) {
- debug("dockapp.c: Replaceable dummy tile found.");
- wmdock_order_dockapps(wmdock_get_primary_anchor_dockapp() ? wmdock_get_primary_anchor_dockapp() : dapp);
- } else {
- wmdock_remove_anchors_tile_dummy();
- wmdock_set_autoposition_dockapp(dapp, wmdock_get_parent_dockapp(dapp));
- }
- if(dappDummy) {
- gtk_widget_hide(dappDummy->tile);
- }
-
- dappOnMotion = NULL;
- gtk_window_set_keep_above(GTK_WINDOW(dapp->tile), FALSE);
-}
-
-
-/**
- * Event handle for the tile in panel off mode (motion_notify)
- *
- * @param tile The window of the event.
- * @param ev GdkEventButton.
- * @param dapp DockAppNode of the event.
- */
-void wmdock_dockapp_motion_notify_handler(GtkWidget *tile, GdkEventMotion *ev, DockappNode *dapp)
-{
- 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(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) {
- wmdock_remove_anchors_tile_dummy();
- dappSnap = wmdock_get_snapable_dockapp(dapp, &gluepos);
- if(dappSnap) {
- debug("dockapp.c: Snapable dockapp `%s' for dockapp `%s', glue: %d.", dappSnap->name, dapp->name, gluepos);
- if(!dappDummy) {
- dappDummy = g_new0(DockappNode, 1);
- dappDummy->name = g_strdup(DOCKAPP_DUMMY_TITLE);
- dappDummy->tile = wmdock_create_tile_dummy();
- }
-
- dappSnap->glue[gluepos] = dappDummy;
- wmdock_order_dockapps(dappDummy);
- gtk_widget_show_all(dappDummy->tile);
- } else if(dappDummy) {
- gtk_widget_hide(dappDummy->tile);
- }
- }
-}
-
-
-
-/**
* Event handler for the tile in panel off mode (event_after).
*
* @param tile The window of the event.
* @param ev Event informations.
* @param dapp DockappNode of the event.
*/
-void wmdock_dockapp_event_after_handler(GtkWidget *tile, GdkEvent *ev, DockappNode *dapp)
+void wmdock_dockapp_event_after_handler(GtkWidget *window, GdkEvent *ev, DockappNode *dapp)
{
- GdkModifierType m;
-
- debug("dockapp.c: Window event after: %d. (dapp: `%s'), dappOnMove: %s", ev->type, dapp->name,
+ debug("dockapp.c: Window event-after: %d. (dapp: `%s'), dappOnMove: %s", ev->type, dapp->name,
dappOnMotion ? "Yes": "No");
switch(ev->type) {
- case GDK_CONFIGURE:
- gdk_window_get_pointer(tile->window, NULL, NULL, &m);
- if(!dappOnMotion && (m & GDK_BUTTON1_MASK)) {
- dappOnMotion = dapp;
- gtk_window_set_keep_above(GTK_WINDOW(dapp->tile), TRUE);
- }
- wmdock_dockapp_motion_notify_handler(NULL, &ev->motion, dapp);
-
- if(!(dappOnMotion && !(m & GDK_BUTTON1_MASK)))
- break;
- /* No break if DockApp is moved and mouse btn released. */
- case GDK_BUTTON_RELEASE:
- case GDK_KEY_RELEASE:
- wmdock_dockapp_button_release_handler(NULL, &ev->button, dapp);
- break;
case GDK_FOCUS_CHANGE:
if(ev->focus_change.in == TRUE) {
/* `in' is true if window window got the focus. */
@@ -500,7 +484,6 @@ GtkWidget *wmdock_create_tile_dummy()
gtk_window_set_skip_pager_hint(GTK_WINDOW(dummy), TRUE);
gtk_window_set_opacity(GTK_WINDOW(dummy), 0.6);
gtk_widget_set_size_request(dummy, DEFAULT_DOCKAPP_WIDTH, DEFAULT_DOCKAPP_HEIGHT);
- // gtk_window_set_type_hint(GTK_WINDOW(dummy), GDK_WINDOW_TYPE_HINT_DND);
return (dummy);
}
@@ -516,8 +499,10 @@ void wmdock_dockapp_tofront(DockappNode *dapp) {
return;
if ( IS_PANELOFF(wmdock) ) {
+ gtk_window_set_keep_below(GTK_WINDOW(dapp->tile), FALSE);
gdk_window_raise(dapp->tile->window);
gtk_window_set_keep_above(GTK_WINDOW(dapp->tile), FALSE);
+ gtk_window_set_keep_below(GTK_WINDOW(dapp->tile), TRUE);
}
}
@@ -814,25 +799,30 @@ void wmdock_set_socket_postion(DockappNode *dapp, int x, int y)
GtkWidget *wmdock_create_tile_from_socket(DockappNode *dapp)
{
GtkWidget *tile = NULL;
- GtkWidget *fixed = NULL;
+ GtkWidget *_fixed = NULL;
+ GtkWidget *_evbox = NULL;
+
+ tile = _fixed = gtk_fixed_new();
+ gtk_container_set_border_width(GTK_CONTAINER(_fixed), 0);
- tile = fixed = gtk_fixed_new();
- gtk_container_set_border_width(GTK_CONTAINER(fixed), 0);
+ /* Create an internal eventbox to catch click events outside the socket. */
+ _evbox = gtk_event_box_new();
+ gtk_widget_set_size_request(GTK_WIDGET(_evbox), DEFAULT_DOCKAPP_WIDTH, DEFAULT_DOCKAPP_HEIGHT);
+ gtk_fixed_put(GTK_FIXED(_fixed), _evbox, 0, 0);
- /* Create an eventbox to catch all click and motion events. */
+ /* Create an eventbox to catch to click and motion events inside the socket. */
dapp->evbox = gtk_event_box_new();
gtk_event_box_set_above_child(GTK_EVENT_BOX(dapp->evbox), FALSE);
/* Add the GtkSocket with the dockapp fixed and centered. */
gtk_container_add(GTK_CONTAINER(dapp->evbox), GTK_WIDGET(dapp->s));
- gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(dapp->evbox),
+ gtk_fixed_put(GTK_FIXED(_fixed), GTK_WIDGET(dapp->evbox),
(DEFAULT_DOCKAPP_WIDTH - dapp->width) / 2, (DEFAULT_DOCKAPP_HEIGHT - dapp->height) / 2);
/* Add the background tile. */
dapp->bg = wmdock->propDispTile == TRUE ? gtk_image_new_from_pixbuf(gdkPbTileDefault) : gtk_image_new();
gtk_widget_set_size_request(GTK_WIDGET(dapp->bg), DEFAULT_DOCKAPP_WIDTH, DEFAULT_DOCKAPP_HEIGHT);
- gtk_fixed_put(GTK_FIXED(fixed), dapp->bg, 0, 0);
-
+ gtk_container_add(GTK_CONTAINER(_evbox), GTK_WIDGET(dapp->bg));
if( IS_PANELOFF(wmdock) ) {
/* If propDispPanelOff is true create a separate window with the
@@ -844,6 +834,10 @@ GtkWidget *wmdock_create_tile_from_socket(DockappNode *dapp)
gtk_window_set_title(GTK_WINDOW(tile), dapp->name);
gtk_window_set_default_size(GTK_WINDOW(tile), DEFAULT_DOCKAPP_WIDTH, DEFAULT_DOCKAPP_HEIGHT);
gtk_container_set_border_width(GTK_CONTAINER(tile), 0);
+ /* To disable dragging by alt key. */
+ gtk_window_set_type_hint(GTK_WINDOW(tile), GDK_WINDOW_TYPE_HINT_DOCK);
+ gtk_window_set_keep_below(GTK_WINDOW(tile), TRUE);
+ gtk_window_set_keep_above(GTK_WINDOW(tile), FALSE);
/* Disable window shrinking resizing and growing. */
gtk_window_set_policy (GTK_WINDOW(tile), FALSE, FALSE, FALSE);
@@ -856,10 +850,14 @@ GtkWidget *wmdock_create_tile_from_socket(DockappNode *dapp)
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(tile), TRUE);
gtk_window_set_skip_pager_hint(GTK_WINDOW(tile), TRUE);
- gtk_container_add(GTK_CONTAINER(tile), fixed);
+ gtk_container_add(GTK_CONTAINER(tile), _fixed);
+
+ g_signal_connect(G_OBJECT(tile), "motion_notify_event", G_CALLBACK(wmdock_dockapp_motion_notify_handler), dapp);
+ g_signal_connect(G_OBJECT(tile), "button_press_event", G_CALLBACK(wmdock_dockapp_button_press_handler), dapp);
+ g_signal_connect(G_OBJECT(tile), "button_release_event", G_CALLBACK(wmdock_dockapp_button_release_handler), dapp);
}
- gtk_widget_show(fixed);
+ gtk_widget_show(_fixed);
return (tile);
}
diff --git a/panel-plugin/dockapp.h b/panel-plugin/dockapp.h
index 3873eec..4e5a886 100644
--- a/panel-plugin/dockapp.h
+++ b/panel-plugin/dockapp.h
@@ -68,9 +68,6 @@ DockappNode *wmdock_get_parent_dockapp(DockappNode *);
DockappNode *wmdock_get_primary_anchor_dockapp();
void wmdock_dockapp_tofront(DockappNode *dapp);
void wmdock_dockapp_event_after_handler(GtkWidget *, GdkEvent *, DockappNode *);
-void wmdock_dockapp_button_press_handler(GtkWidget *, GdkEventButton *, DockappNode *);
-void wmdock_dockapp_button_release_handler(GtkWidget *, GdkEventButton *, DockappNode *);
-void wmdock_dockapp_motion_notify_handler(GtkWidget *, GdkEventMotion *, DockappNode *);
void wmdock_remove_anchor_dockapp(DockappNode *, DockappNode *);
void wmdock_order_dockapps(DockappNode *);
GtkWidget *wmdock_create_tile_dummy();
diff --git a/panel-plugin/rcfile.c b/panel-plugin/rcfile.c
index 0a24da2..034908c 100644
--- a/panel-plugin/rcfile.c
+++ b/panel-plugin/rcfile.c
@@ -64,7 +64,7 @@ void wmdock_read_rc_file (XfcePanelPlugin *plugin)
if(!rc)
return;
- rcCmds = xfce_rc_read_list_entry(rc, RCKEY_CMDLIST, ";");
+ rcCmds = xfce_rc_read_list_entry(rc, RCKEY_CMDLIST, RC_LIST_DELIMITER);
wmdock->propDispTile = xfce_rc_read_bool_entry (rc, RCKEY_DISPTILE, TRUE);
wmdock->propDispPropButton = xfce_rc_read_bool_entry (rc, RCKEY_DISPPROPBTN, FALSE);
wmdock->propDispAddOnlyWM = xfce_rc_read_bool_entry (rc, RCKEY_DISPADDONLYWM, TRUE);
@@ -72,7 +72,7 @@ void wmdock_read_rc_file (XfcePanelPlugin *plugin)
wmdock->filterList = g_strdup(xfce_rc_read_entry (rc, RCKEY_DAFILTER, DOCKAPP_FILTER_PATTERN));
/* TODO: Set panel off to FALSE. */
rcPanelOff = wmdock->propPanelOff = xfce_rc_read_bool_entry (rc, RCKEY_PANELOFF, TRUE);
- glueList = IS_PANELOFF(wmdock) ? xfce_rc_read_list_entry(rc, RCKEY_GLUELIST, ";") : NULL;
+ glueList = IS_PANELOFF(wmdock) ? xfce_rc_read_list_entry(rc, RCKEY_GLUELIST, RC_LIST_DELIMITER) : NULL;
wmdock->anchorPos = xfce_rc_read_int_entry(rc, RCKEY_ANCHORPOS, -1);
xfce_rc_close (rc);
@@ -124,17 +124,18 @@ void wmdock_read_rc_file (XfcePanelPlugin *plugin)
if( IS_PANELOFF( wmdock ) && g_strv_length(rcCmds) == g_strv_length(glueList) ) {
for (i = 0; glueList[i]; i++) {
- if(!launched[i] || glueList[i][0] == '\0' || !(glueInfo = g_strsplit(glueList[i], ",", 0)))
+ if(!launched[i] || glueList[i][0] == '\0' || !(glueInfo = g_strsplit(glueList[i], RC_GLUE_DELIMITER, 0)))
continue;
+ /* Cleanup the default anchors. */
+ memset(launched[i]->glue, '\0', sizeof(DockappNode *) * GLUE_MAX);
+
for (j = 0; glueInfo[j]; j++) {
n = g_ascii_strtoll(glueInfo[j], &glueName, 10);
if(n > G_MAXINT || n < 0 || n > g_strv_length(rcCmds)-1 || glueName == glueInfo[j] || glueName[0] != ':')
continue;
if((gluePos = wmdock_get_glue_position(&glueName[1])) == -1)
continue;
- if(j == 0) /* Cleanup the default anchors. */
- memset(launched[i]->glue, 0, sizeof(DockappNode *) * GLUE_MAX);
launched[i]->glue[gluePos] = launched[(gint) n];
debug("rcfile.c: Restored panel off position. (`%s', %s = %d)", launched[i]->cmd, &glueName[1], gluePos);
@@ -152,7 +153,7 @@ void wmdock_read_rc_file (XfcePanelPlugin *plugin)
void wmdock_write_rc_file (XfcePanelPlugin *plugin)
{
- gchar *file = NULL, *p = NULL;
+ gchar *file = NULL, *str = NULL;
XfceRc *rc;
gchar **cmdList = NULL;
gchar **glueList = NULL;
@@ -185,22 +186,22 @@ void wmdock_write_rc_file (XfcePanelPlugin *plugin)
if(dapp->glue[gluePos] && (n = g_list_index(wmdock->dapps, (gconstpointer) dapp->glue[gluePos])) != -1) {
/* ChildIndex1(n):position,ChildIndex2:postion,... */
if(strnlen((const char *) buf, sizeof(buf)-1) > 0)
- p = g_strdup_printf(",%d:%s", n, wmdock_get_glue_name(gluePos));
+ str = g_strdup_printf("%s%d:%s", RC_GLUE_DELIMITER, n, wmdock_get_glue_name(gluePos));
else
- p = g_strdup_printf("%d:%s", n, wmdock_get_glue_name(gluePos));
- g_strlcat(buf, p, sizeof(buf));
- g_free(p);
+ str = g_strdup_printf("%d:%s", n, wmdock_get_glue_name(gluePos));
+ g_strlcat(buf, str, sizeof(buf));
+ g_free(str);
}
}
glueList[i] = g_strdup(buf);
}
}
- xfce_rc_write_list_entry(rc, RCKEY_CMDLIST, cmdList, ";");
+ xfce_rc_write_list_entry(rc, RCKEY_CMDLIST, cmdList, RC_LIST_DELIMITER);
g_strfreev(cmdList);
if( IS_PANELOFF(wmdock) ) {
- xfce_rc_write_list_entry(rc, RCKEY_GLUELIST, glueList, ";");
+ xfce_rc_write_list_entry(rc, RCKEY_GLUELIST, glueList, RC_LIST_DELIMITER);
g_strfreev(glueList);
}
diff --git a/panel-plugin/rcfile.h b/panel-plugin/rcfile.h
index 7556487..8ad48c6 100644
--- a/panel-plugin/rcfile.h
+++ b/panel-plugin/rcfile.h
@@ -33,6 +33,9 @@
#define RCKEY_ANCHORPOS (const gchar *) "anchorpos"
#define RCKEY_GLUELIST (const gchar *) "glues"
+#define RC_LIST_DELIMITER (const gchar *) ";"
+#define RC_GLUE_DELIMITER (const gchar *) ","
+
/* Prototypes */
void wmdock_read_rc_file (XfcePanelPlugin *);
void wmdock_write_rc_file (XfcePanelPlugin *);
More information about the Xfce4-commits
mailing list