MCDE dtlaunch: told of a new clipboard owner by XFixes, not asking every second (t0080)

XFixesSelectSelectionInput on CLIPBOARD; the event names the new owner, whose
text is read once.  configure.ac checks libXfixes and gives only dtlaunch
XFIXESLIB and XFIXES_CPPFLAGS (-DHAVE_XFIXES); a define in config.h would have
recompiled every file.  Without the library or the extension the owner is asked
every 5 s (POLL_MS, was 1 s).  The recipe lists x11/libXfixes/buildlink3.mk.

Measured with strace (writes to the X socket, 10 s idle after 4 s): 10 before,
0 with XFixes, 2 in the fallback (5.0 s and 10.0 s; tested with an LD_PRELOAD
shim that makes XFixesQueryExtension fail -- Xvfb -extension XFIXES aborts for
any Motif client, also an unmodified dtpad).  Both paths still put a copy made
by xclip during idle into the history (screenshots).  The sysroot has Xfixes.h,
libXfixes.so.4.1 and the pkg-config files; the cross build of the recipe change
is not run yet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
lotherkandClaude Sonnet 5.5 committed 2026-11-14 22:58:59 +00:00
1 parent a5f891cd08
commit a6cb7c3f87
5 files changed
+92 -14

No files matched your search

+18 -3
View File
@@ -345,9 +345,24 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
the first opening (tests, `tools/mcde-shot.sh`). Measured: typing `disp`
lists the pane second (`docs/screenshots/leopard/Spotlight-mcde.png`);
Return on `displays` starts `dtsystemsettings -pane displays` and its
window "Displays" appears. **Not done yet:** the two-column list grouped by
category, documents/mail/PDF/web results, the magnifier button in dtbar with
`-at X,Y`, and the clipboard without the 1 s poll (XFixes).
window "Displays" appears. **The clipboard history is told, it does not
ask** (t0080): `XFixesSelectSelectionInput` on CLIPBOARD
(`XFixesSetSelectionOwnerNotifyMask`), the new owner is read once when the
event arrives. `configure.ac` checks libXfixes and gives only dtlaunch
`XFIXESLIB` and `XFIXES_CPPFLAGS` (-DHAVE_XFIXES) -- not a define in
`config.h`, which would recompile the whole tree. Without the library or the
extension the owner is asked every 5 s (`POLL_MS`). Measured with `strace`
(writes to the X socket, 10 s idle after a 4 s start): **10 with the 1 s
poll, 0 with XFixes, 2 (at 5.0 s and 10.0 s) in the fallback** (the fallback
tested with an LD_PRELOAD shim that makes `XFixesQueryExtension` fail: an
Xvfb started with `-extension XFIXES` aborts as soon as any Motif client
connects, `privates.h: dixGetPrivateAddr: Assertion key->initialized`, also
for an unmodified dtpad, so it cannot serve for this). Both paths still
catch a copy (`xclip` while the launcher idles, then `dtlaunch -show`: the
history shows it). The recipe has `x11/libXfixes/buildlink3.mk` for it --
not yet through a real cross build. **Not done yet:** the two-column list
grouped by category, documents/mail/PDF/web results, and the magnifier button
in dtbar with `-at X,Y`.
- **Printers**: `dtsystemsettings/printers.c` lists the CUPS queues
(`mcde_sys_printers`: lpstat -p/-d, parsed), shows the chosen one (state,
location, model, default, shared), and adds one from what mDNS finds
+11
View File
@@ -641,6 +641,17 @@ AC_CHECK_LIB(Xt, XtInitialize, [XTOOLLIB="-lXt ${XTOOLLIB}"], ,
[${EXTRA_INCS} ${EXTRA_LIBS}])
AC_CHECK_LIB(Xmu, XmuMakeAtom, [XTOOLLIB="-lXmu ${XTOOLLIB}"], ,
[${EXTRA_INCS} ${EXTRA_LIBS}])
dnl MCDE: dtlaunch is told of a new clipboard owner by XFixes instead of asking
dnl for the clipboard every second (tasksd t0080); without libXfixes it asks
dnl every 5 s. Only dtlaunch uses it: XFIXESLIB and XFIXES_CPPFLAGS are its own
dnl (not a define in config.h: that would recompile every file of the tree).
XFIXESLIB=""
XFIXES_CPPFLAGS=""
AC_CHECK_LIB(Xfixes, XFixesSelectSelectionInput,
[XFIXESLIB="-lXfixes"; XFIXES_CPPFLAGS="-DHAVE_XFIXES"], ,
[${EXTRA_INCS} ${EXTRA_LIBS}])
AC_SUBST(XFIXESLIB)
AC_SUBST(XFIXES_CPPFLAGS)
AC_CHECK_LIB(ICE, IceCloseConnection, [XTOOLLIB="-lICE ${XTOOLLIB}"], ,
[${EXTRA_INCS} ${EXTRA_LIBS}])
AC_CHECK_LIB(SM, SmcOpenConnection, [XTOOLLIB="-lSM ${XTOOLLIB}"], ,
+1
View File
@@ -219,6 +219,7 @@ post-install: pam-install
.include "../../x11/libXScrnSaver/buildlink3.mk"
.include "../../x11/libXinerama/buildlink3.mk"
.include "../../x11/libXrandr/buildlink3.mk"
.include "../../x11/libXfixes/buildlink3.mk"
.include "../../x11/libXdmcp/buildlink3.mk"
.include "../../x11/xbitmaps/buildlink3.mk"
.include "../../x11/libXmu/buildlink3.mk"
+2 -1
View File
@@ -5,7 +5,8 @@ MAINTAINERCLEANFILES = Makefile.in
bin_PROGRAMS = dtlaunch
dtlaunch_SOURCES = dtlaunch.c model.c model.h
dtlaunch_LDADD = $(XTOOLLIB) -lm
dtlaunch_CPPFLAGS = $(XFIXES_CPPFLAGS)
dtlaunch_LDADD = $(XFIXESLIB) $(XTOOLLIB) -lm
check_PROGRAMS = test_model
test_model_SOURCES = test_model.c model.c model.h
+60 -10
View File
@@ -15,9 +15,13 @@
* closes. Up and Down move in the list. The panes are asked for once, from
* `dtsystemsettings -list-panes' (a pipe and exec, no shell, no display).
*
* The clipboard history: every second the owner of CLIPBOARD is asked for its
* text (Xt selections, ICCCM); a new text goes to the top, at most HISTORY
* entries, kept in memory only -- passwords pass through the clipboard.
* The clipboard history: when the owner of CLIPBOARD changes (an XFixes
* selection event: the launcher is told, it does not ask) the new owner is
* asked for its text (Xt selections, ICCCM); a new text goes to the top, at
* most HISTORY entries, kept in memory only -- passwords pass through the
* clipboard. Without XFixes (libXfixes missing at build time, or the X server
* has no such extension) the owner is asked every POLL_MS; idle, the launcher
* with XFixes sends nothing to the server (tasksd t0080).
*
* One launcher per display: the first one owns the selection _MCDE_DTLAUNCH;
* `dtlaunch -show' asks that one to open and exits; `dtlaunch -quit' asks it
@@ -47,6 +51,9 @@
#include <X11/Shell.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#ifdef HAVE_XFIXES
#include <X11/extensions/Xfixes.h>
#endif
#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>
@@ -59,7 +66,7 @@
#define HISTORY 50
#define MAXITEMS 40
#define MAXCLIP (64 * 1024)
#define POLL_MS 1000
#define POLL_MS 5000 /* only without XFixes: how often to ask */
typedef enum { K_APP, K_SNIPPET, K_CLIP, K_CALC, K_PANE } Kind;
@@ -87,6 +94,7 @@ static struct {
size_t npanes;
int panes_loaded;
char *initial_text; /* -text: the field of the first opening */
int xfixes_event; /* event type of XFixesSelectionNotify, or 0 */
char *history[HISTORY];
size_t nhistory;
Item items[MAXITEMS];
@@ -359,18 +367,47 @@ got_clipboard(Widget w, XtPointer client, Atom *selection, Atom *type,
XtFree((char *)value);
}
/* ask OWNER of CLIPBOARD for its text, unless that is the launcher itself (it
* offers text of its own: offer()) or nobody */
static void
request_clipboard(Window owner, Time t)
{
if (owner != None && owner != XtWindow(L.top))
XtGetSelectionValue(L.top, L.a_clipboard, L.a_utf8,
got_clipboard, NULL, t);
}
/* without XFixes: ask every POLL_MS */
static void
poll_clipboard(XtPointer client, XtIntervalId *id)
{
Window owner = XGetSelectionOwner(L.dpy, L.a_clipboard);
(void)client; (void)id;
if (owner != None && owner != XtWindow(L.top))
XtGetSelectionValue(L.top, L.a_clipboard, L.a_utf8,
got_clipboard, NULL, XtLastTimestampProcessed(L.dpy));
request_clipboard(XGetSelectionOwner(L.dpy, L.a_clipboard),
XtLastTimestampProcessed(L.dpy));
(void)XtAppAddTimeOut(L.app, POLL_MS, poll_clipboard, NULL);
}
/* Be told when the owner of CLIPBOARD changes, instead of asking: 1 when the
* X server has XFixes and the launcher was built with it, else 0 (the caller
* then polls). The text there now is read once, so the history starts with it. */
static int
watch_clipboard(void)
{
#ifdef HAVE_XFIXES
int ev_base, err_base;
if (!XFixesQueryExtension(L.dpy, &ev_base, &err_base))
return 0;
L.xfixes_event = ev_base + XFixesSelectionNotify;
XFixesSelectSelectionInput(L.dpy, L.root, L.a_clipboard,
XFixesSetSelectionOwnerNotifyMask);
request_clipboard(XGetSelectionOwner(L.dpy, L.a_clipboard), CurrentTime);
return 1;
#else
return 0;
#endif
}
/* ---- showing, hiding, doing -------------------------------------------- */
/* The panes of System Settings: what `dtsystemsettings -list-panes' prints,
@@ -932,7 +969,8 @@ main(int argc, char **argv)
fprintf(stderr, "dtlaunch: hot key \"%s\" not understood\n",
res.hotkey);
}
(void)XtAppAddTimeOut(L.app, POLL_MS, poll_clipboard, NULL);
if (!watch_clipboard())
(void)XtAppAddTimeOut(L.app, POLL_MS, poll_clipboard, NULL);
if (show_now)
show();
@@ -948,6 +986,18 @@ main(int argc, char **argv)
show();
continue;
}
#ifdef HAVE_XFIXES
if (L.xfixes_event != 0 && ev.type == L.xfixes_event) {
XFixesSelectionNotifyEvent *sn =
(XFixesSelectionNotifyEvent *)&ev;
/* a new owner of CLIPBOARD: read what it has now */
if (sn->selection == L.a_clipboard)
request_clipboard(sn->owner,
sn->selection_timestamp);
continue;
}
#endif
if (ev.type == ClientMessage &&
ev.xclient.message_type == L.a_show) {
show();