From b4cf94aacd0f9fcffd802b0a8e47e0d162ca1f20 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Mon, 6 Apr 2015 17:58:12 +0200 Subject: [PATCH] Code refactoring: replaced macro 'XDND' by 'USE_DOCK_XDND' for consistency The usual way to define a macro in is to name macro with 'USE_xxx' when they are used to enable a feature 'xxx'. As the feature concerns the Dock and not DnD in general (WINGs support is not disabled), make it a bit more clear in the macro name and document the configure flag in the Installation Manual. Took opportunity to compile the corresponding file only when the feature is not disabled. Signed-off-by: Christophe CURIS --- configure.ac | 7 ++++--- doc/build/Compilation.texi | 5 +++++ src/Makefile.am | 4 +++- src/appicon.c | 8 ++++---- src/appicon.h | 2 +- src/dialog.c | 2 +- src/dock.c | 30 +++++++++++++++--------------- src/dock.h | 2 +- src/dockedapp.c | 8 ++++---- src/event.c | 8 ++++---- src/misc.c | 4 ++-- src/screen.h | 2 +- src/startup.c | 4 ++-- src/xdnd.c | 14 +++++++------- 14 files changed, 54 insertions(+), 46 deletions(-) diff --git a/configure.ac b/configure.ac index 4e55a948..6a023766 100644 --- a/configure.ac +++ b/configure.ac @@ -502,15 +502,16 @@ AS_IF([test "x$enable_modelock" = "xyes"], dnl XDND Drag-nd-Drop support dnl ========================= AC_ARG_ENABLE([xdnd], - [AS_HELP_STRING([--disable-xdnd], [disable Drag-nd-Drop support])], + [AS_HELP_STRING([--disable-xdnd], [disable support for Drag-and-Drop on the dock @<:@default=enabled@:>@])], [AS_CASE(["$enableval"], [yes|no], [], [AC_MSG_ERROR([bad value $enableval for --disable-xdnd]) ]) ], [enable_xdnd=yes]) AS_IF([test "x$enable_xdnd" = "xyes"], - [supported_xext="$supported_xext XDnD" - AC_DEFINE([XDND], [1], [whether Drag-nd-Drop support should be enabled])], + [supported_core="$supported_core XDnD" + AC_DEFINE([USE_DOCK_XDND], [1], [whether Drag-and-Drop on the dock should be enabled])], [unsupported="$unsupported XDnd"]) +AM_CONDITIONAL([USE_DOCK_XDND], [test "x$enable_dock_xdnd" != "xno"]) dnl XShape support diff --git a/doc/build/Compilation.texi b/doc/build/Compilation.texi index 8d1fcfd6..4db3ae0f 100644 --- a/doc/build/Compilation.texi +++ b/doc/build/Compilation.texi @@ -571,6 +571,11 @@ Disable support for Motif's MWM Window Manager hints. These attributes were introduced by the Motif toolkit to ask for special window appearance requests. Nowadays this is covered by the NetWM/EWMH specification, but there are still applications that rely on MWM Hints. +@item --disable-xdnd +Disable support for dragging and dropping files on the dock, which launches a user-specified command +with that file. +Starting from version 0.65.6 this feature is enabled by default. + @item --enable-ld-version-script This feature is auto-detected, and you should not use this option. When compiling a library (@file{wrlib}, ...), @emph{gcc} has the possibility to filter the list of diff --git a/src/Makefile.am b/src/Makefile.am index 56ebe084..7fe9db72 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -84,7 +84,6 @@ wmaker_SOURCES = \ usermenu.c \ usermenu.h \ xdnd.h \ - xdnd.c \ xinerama.h \ xinerama.c \ xmodifier.h \ @@ -108,6 +107,9 @@ wmaker_SOURCES = \ wsmap.c \ wsmap.h +if USE_DOCK_XDND +wmaker_SOURCES += xdnd.c +endif if USE_MWM_HINTS wmaker_SOURCES += motif.h motif.c endif diff --git a/src/appicon.c b/src/appicon.c index ed03ffc1..14dba971 100644 --- a/src/appicon.c +++ b/src/appicon.c @@ -51,7 +51,7 @@ #include "placement.h" #include "misc.h" #include "event.h" -#ifdef XDND +#ifdef USE_DOCK_XDND #include "xdnd.h" #endif @@ -130,7 +130,7 @@ WAppIcon *wAppIconCreateForDock(WScreen *scr, const char *command, const char *w tile = TILE_CLIP; aicon->icon = icon_create_for_dock(scr, command, wm_instance, wm_class, tile); -#ifdef XDND +#ifdef USE_DOCK_XDND wXDNDMakeAwareness(aicon->icon->core->window); #endif @@ -309,7 +309,7 @@ static WAppIcon *wAppIconCreate(WWindow *leader_win) aicon->wm_instance = wstrdup(leader_win->wm_instance); aicon->icon = icon_create_for_wwindow(leader_win); -#ifdef XDND +#ifdef USE_DOCK_XDND wXDNDMakeAwareness(aicon->icon->core->window); #endif @@ -332,7 +332,7 @@ void wAppIconDestroy(WAppIcon * aicon) wIconDestroy(aicon->icon); if (aicon->command) wfree(aicon->command); -#ifdef XDND +#ifdef USE_DOCK_XDND if (aicon->dnd_command) wfree(aicon->dnd_command); #endif diff --git a/src/appicon.h b/src/appicon.h index 2456ba26..eb1904bc 100644 --- a/src/appicon.h +++ b/src/appicon.h @@ -37,7 +37,7 @@ typedef struct WAppIcon { WIcon *icon; int x_pos, y_pos; /* absolute screen coordinate */ char *command; /* command used to launch app */ -#ifdef XDND +#ifdef USE_DOCK_XDND char *dnd_command; /* command to use when something is */ /* dropped on us */ #endif diff --git a/src/dialog.c b/src/dialog.c index 25c321ec..b7b8f530 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -1316,7 +1316,7 @@ void wShowInfoPanel(WScreen *scr) strbuf = wstrappend(strbuf, ", MWM"); #endif -#ifdef XDND +#ifdef USE_DOCK_XDND strbuf = wstrappend(strbuf, ", XDnD"); #endif diff --git a/src/dock.c b/src/dock.c index 8853fa3f..d4aca092 100644 --- a/src/dock.c +++ b/src/dock.c @@ -72,7 +72,7 @@ static WMPropList *dCommand = NULL; static WMPropList *dPasteCommand = NULL; -#ifdef XDND /* XXX was OFFIX */ +#ifdef USE_DOCK_XDND static WMPropList *dDropCommand = NULL; #endif static WMPropList *dAutoLaunch, *dLock; @@ -135,7 +135,7 @@ static void make_keys(void) dCommand = WMRetainPropList(WMCreatePLString("Command")); dPasteCommand = WMRetainPropList(WMCreatePLString("PasteCommand")); -#ifdef XDND +#ifdef USE_DOCK_XDND dDropCommand = WMRetainPropList(WMCreatePLString("DropCommand")); #endif dLock = WMRetainPropList(WMCreatePLString("Lock")); @@ -1496,13 +1496,13 @@ static WMPropList *make_icon_state(WAppIcon *btn) if (btn->dock != btn->icon->core->screen_ptr->dock && (btn->xindex != 0 || btn->yindex != 0)) WMPutInPLDictionary(node, dOmnipresent, omnipresent); -#ifdef XDND /* was OFFIX */ +#ifdef USE_DOCK_XDND if (btn->dnd_command) { command = WMCreatePLString(btn->dnd_command); WMPutInPLDictionary(node, dDropCommand, command); WMReleasePropList(command); } -#endif /* XDND */ +#endif /* USE_DOCK_XDND */ if (btn->paste_command) { command = WMCreatePLString(btn->paste_command); @@ -1682,7 +1682,7 @@ static WAppIcon *restore_icon_state(WScreen *scr, WMPropList *info, int type, in aicon->icon->core->descriptor.parent_type = WCLASS_DOCK_ICON; aicon->icon->core->descriptor.parent = aicon; -#ifdef XDND /* was OFFIX */ +#ifdef USE_DOCK_XDND cmd = WMGetFromPLDictionary(info, dDropCommand); if (cmd) aicon->dnd_command = wstrdup(WMGetFromPLString(cmd)); @@ -1769,7 +1769,7 @@ WAppIcon *wClipRestoreState(WScreen *scr, WMPropList *clip_state) wScreenKeepInside(scr, &icon->x_pos, &icon->y_pos, ICON_SIZE, ICON_SIZE); } } -#ifdef XDND /* was OFFIX */ +#ifdef USE_DOCK_XDND value = WMGetFromPLDictionary(clip_state, dDropCommand); if (value && WMIsPLString(value)) icon->dnd_command = wstrdup(WMGetFromPLString(value)); @@ -2035,7 +2035,7 @@ void wDockDoAutoLaunch(WDock *dock, int workspace) } } -#ifdef XDND /* was OFFIX */ +#ifdef USE_DOCK_XDND static WDock *findDock(WScreen *scr, XEvent *event, int *icon_pos) { WDock *dock; @@ -2117,7 +2117,7 @@ int wDockReceiveDNDDrop(WScreen *scr, XEvent *event) } return False; } -#endif /* XDND */ +#endif /* USE_DOCK_XDND */ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon) { @@ -2221,7 +2221,7 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon if (wPreferences.auto_arrange_icons) wArrangeIcons(dock->screen_ptr, True); -#ifdef XDND /* was OFFIX */ +#ifdef USE_DOCK_XDND if (icon->command && !icon->dnd_command) { int len = strlen(icon->command) + 8; icon->dnd_command = wmalloc(len); @@ -2401,7 +2401,7 @@ void wDockDetach(WDock *dock, WAppIcon *icon) wfree(icon->command); icon->command = NULL; } -#ifdef XDND /* was OFFIX */ +#ifdef USE_DOCK_XDND if (icon->dnd_command) { wfree(icon->dnd_command); icon->dnd_command = NULL; @@ -3347,7 +3347,7 @@ static void trackDeadProcess(pid_t pid, unsigned char status, WDock *dock) char msg[PATH_MAX]; char *cmd; -#ifdef XDND +#ifdef USE_DOCK_XDND if (icon->drop_launch) cmd = icon->dnd_command; else @@ -4770,11 +4770,11 @@ static WDock * drawerRestoreState(WScreen *scr, WMPropList *drawer_state) drawer = wDockCreate(scr, WM_DRAWER, WMGetFromPLString(value)); /* restore DnD command and paste command */ -#ifdef XDND +#ifdef USE_DOCK_XDND value = WMGetFromPLDictionary(drawer_state, dDropCommand); if (value && WMIsPLString(value)) drawer->icon_array[0]->dnd_command = wstrdup(WMGetFromPLString(value)); -#endif /* XDND */ +#endif /* USE_DOCK_XDND */ value = WMGetFromPLDictionary(drawer_state, dPasteCommand); if (value && WMIsPLString(value)) @@ -4912,14 +4912,14 @@ static WMPropList *drawerSaveState(WDock *drawer) WMPutInPLDictionary(drawer_state, dPosition, pstr); WMReleasePropList(pstr); -#ifdef XDND +#ifdef USE_DOCK_XDND /* Store its DnD command */ if (ai->dnd_command) { pstr = WMCreatePLString(ai->dnd_command); WMPutInPLDictionary(drawer_state, dDropCommand, pstr); WMReleasePropList(pstr); } -#endif /* XDND */ +#endif /* USE_DOCK_XDND */ /* Store its paste command */ if (ai->paste_command) { diff --git a/src/dock.h b/src/dock.h index 23281a9e..1e00e5f7 100644 --- a/src/dock.h +++ b/src/dock.h @@ -92,7 +92,7 @@ WAppIcon *wDockFindIconForWindow(WDock *dock, Window window); void wDockDoAutoLaunch(WDock *dock, int workspace); void wDockLaunchWithState(WAppIcon *btn, WSavedState *state); -#ifdef XDND +#ifdef USE_DOCK_XDND int wDockReceiveDNDDrop(WScreen *scr, XEvent *event); #endif diff --git a/src/dockedapp.c b/src/dockedapp.c index 44eaacda..a7c12d79 100644 --- a/src/dockedapp.c +++ b/src/dockedapp.c @@ -66,7 +66,7 @@ static void updatePasteCommand(WAppIcon * icon, char *command) icon->paste_command = command; } -#ifdef XDND +#ifdef USE_DOCK_XDND static void updateDNDCommand(WAppIcon * icon, char *command) { if (icon->dnd_command) @@ -77,7 +77,7 @@ static void updateDNDCommand(WAppIcon * icon, char *command) } icon->dnd_command = command; } -#endif /* XDND */ +#endif /* USE_DOCK_XDND */ static void updateSettingsPanelIcon(AppSettingsPanel * panel) { @@ -199,7 +199,7 @@ static void panelBtnCallback(WMWidget * self, void *data) text = NULL; } updateCommand(panel->editedIcon, text); -#ifdef XDND +#ifdef USE_DOCK_XDND /* cannot free text from this, because it will be not be duplicated * in updateDNDCommand */ text = WMGetTextFieldText(panel->dndCommandField); @@ -307,7 +307,7 @@ void ShowDockAppSettingsPanel(WAppIcon * aicon) panel->dndCommandLabel = WMCreateLabel(panel->dndCommandFrame); WMResizeWidget(panel->dndCommandLabel, 256, 18); WMMoveWidget(panel->dndCommandLabel, 10, 45); -#ifdef XDND +#ifdef USE_DOCK_XDND WMSetTextFieldText(panel->dndCommandField, aicon->dnd_command); WMSetLabelText(panel->dndCommandLabel, _("%d will be replaced with the file name")); #else diff --git a/src/event.c b/src/event.c index 3e2ecb6f..ce316eee 100644 --- a/src/event.c +++ b/src/event.c @@ -40,7 +40,7 @@ #ifdef USE_XSHAPE # include #endif -#ifdef XDND +#ifdef USE_DOCK_XDND #include "xdnd.h" #endif @@ -539,7 +539,7 @@ static void saveTimestamp(XEvent * event) break; case SelectionNotify: w_global.timestamp.last_event = event->xselection.time; -#ifdef XDND +#ifdef USE_DOCK_XDND wXDNDProcessSelection(event); #endif break; @@ -1073,10 +1073,10 @@ static void handleClientMessage(XEvent * event) scr->flags.ignore_focus_events = event->xclient.data.l[0] ? 1 : 0; } else if (wNETWMProcessClientMessage(&event->xclient)) { /* do nothing */ -#ifdef XDND +#ifdef USE_DOCK_XDND } else if (wXDNDProcessClientMessage(&event->xclient)) { /* do nothing */ -#endif /* XDND */ +#endif /* USE_DOCK_XDND */ } else { /* * Non-standard thing, but needed by OffiX DND. diff --git a/src/misc.c b/src/misc.c index a12a97de..137d78ea 100644 --- a/src/misc.c +++ b/src/misc.c @@ -622,7 +622,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) } break; -#ifdef XDND +#ifdef USE_DOCK_XDND case 'd': if (!scr->xdestring) { scr->flags.dnd_data_convertion_status = 1; @@ -639,7 +639,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline) strcat(out, scr->xdestring); optr += slen; break; -#endif /* XDND */ +#endif /* USE_DOCK_XDND */ case 's': if (!selection) { diff --git a/src/screen.h b/src/screen.h index dd524b81..8ffb6f9a 100644 --- a/src/screen.h +++ b/src/screen.h @@ -283,7 +283,7 @@ typedef struct _WScreen { /* for window shortcuts */ WMArray *shortcutWindows[MAX_WINDOW_SHORTCUTS]; -#ifdef XDND +#ifdef USE_DOCK_XDND char *xdestring; #endif diff --git a/src/startup.c b/src/startup.c index c369dba3..5f43cfdc 100644 --- a/src/startup.c +++ b/src/startup.c @@ -68,7 +68,7 @@ #include "wmspec.h" #include "event.h" #include "switchmenu.h" -#ifdef XDND +#ifdef USE_DOCK_XDND #include "xdnd.h" #endif @@ -469,7 +469,7 @@ void StartUp(Bool defaultScreenOnly) w_global.atom.wm.ignore_focus_events = atom[20]; -#ifdef XDND +#ifdef USE_DOCK_XDND wXDNDInitializeAtoms(); #endif diff --git a/src/xdnd.c b/src/xdnd.c index afbbd44c..63e6d9c3 100644 --- a/src/xdnd.c +++ b/src/xdnd.c @@ -20,19 +20,20 @@ /* Many part of code are ripped of an example from JX's site */ -#include "wconfig.h" +#include "config.h" -#ifdef XDND +#include +#include +#include + +#include +#include #include "WindowMaker.h" #include "dock.h" #include "xdnd.h" #include "workspace.h" -#include -#include -#include -#include static Atom _XA_XdndAware; static Atom _XA_XdndEnter; @@ -315,4 +316,3 @@ Bool wXDNDProcessClientMessage(XClientMessageEvent *event) } return False; } -#endif