X clipboard and SDL

I’ve asked Sam about this before and he told me that it might be added to
1.3, but I have an application which could really benefit from reading the
system’s clipboard. Since waiting an arbitrary number of months for a
feature that may or may not be implemented is not really a good solution,
I tried to figure out how to get the information myself using different
functions for each OS. sigh

Our Win32 people know how to do it for Win32. I can find out how to do it
in MacOS X. The problem is X11… I’ve looked over the source for xclip,
a cmdline tool to give clipboard access to scripts, and either I’m
misreading the heavily documented code, or how X handles the clipboard is
extremely retarded by design and cannot be implemented except in SDL
unless you want your SDL app to suddenly not see keyboard events or
something anymore.

While I suspect it is true both that I misunderstood the code and that the
way X handles the clipboard is highly retarded by design (or lack of it),
I am holding out hope that my conclusion is not also true. So, can anyone
explain how to do it? From what I did manage to understand, I probably
want to read from XA_PRIMARY. I think. Actually, I have no idea if
that’s what I want or not at the moment.

Naturally, I’d really rather see SDL have the feature so I don’t have to
worry about how to support things like the convoluted mess related to X11
in my otherwise very clean, simple, and portable code. =p At the moment
it looks like win32 will probably get the feature and Linux is going to
get a stub function. MacOS X is up in the air still, I don’t think we
have anyone actually working on that platform at the moment.–
Joseph Carter No conceit in my family

Mercury: gpm isn’t a very good web browser. fix it.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020129/0a945413/attachment.pgp

Joseph Carter wrote:

I’ve asked Sam about this before and he told me that it might be added to
1.3, but I have an application which could really benefit from reading the
system’s clipboard.

I’m not convinced it’s an essential SDL feature. It is only useful in
windowed mode, which is mostly a convenience/debug variant of
fullscreen mode, the “proper” SDL way of operation. Once we allow one
GUI/windowing tie-in, more demands for other things will come.

From what I did manage to understand, I probably
want to read from XA_PRIMARY.

Right. The details are in the Xlib docs and in the ICCCM. Remember that the
X11 selection semantics are quite different from those in win32 or MacOS.
For example, there is no “clipboard” holding the selected data anywhere,
but only a promise from a client to deliver the selection upon request.

I’ve asked Sam about this before and he told me that it might be added to
1.3, but I have an application which could really benefit from reading the
system’s clipboard. Since waiting an arbitrary number of months for a
feature that may or may not be implemented is not really a good solution,
I tried to figure out how to get the information myself using different
functions for each OS. sigh

This would be very useful. A while back I ported the Squeak Smalltalk
environment to SDL, and I could have used this feature. I ended up disabling
clipboard access from Squeak, which would not be acceptable for a real
release.

Our Win32 people know how to do it for Win32. I can find out how to do it
in MacOS X. The problem is X11… I’ve looked over the source for xclip,
a cmdline tool to give clipboard access to scripts, and either I’m
misreading the heavily documented code, or how X handles the clipboard is
extremely retarded by design and cannot be implemented except in SDL
unless you want your SDL app to suddenly not see keyboard events or
something anymore.

I think X uses an atom to store the clipboard contents. Can’t you just
retrieve its value?

While I suspect it is true both that I misunderstood the code and that the
way X handles the clipboard is highly retarded by design (or lack of it),
I am holding out hope that my conclusion is not also true. So, can anyone
explain how to do it? From what I did manage to understand, I probably
want to read from XA_PRIMARY. I think. Actually, I have no idea if
that’s what I want or not at the moment.
Naturally, I’d really rather see SDL have the feature so I don’t have to
worry about how to support things like the convoluted mess related to X11
in my otherwise very clean, simple, and portable code. =p At the moment
it looks like win32 will probably get the feature and Linux is going to
get a stub function. MacOS X is up in the air still, I don’t think we
have anyone actually working on that platform at the moment.

Though some will fear feature creep, personally I think portable clipboard
access could be a useful feature. Maybe someone could code up an SDL_clipboard
addon?

-JohnOn Tue, Jan 29, 2002 at 03:32:00AM -0800, Joseph Carter wrote:


John R. Hall - Resident, Sol System, 3rd Planet Out
Student, Georgia Tech; Author, Programming Linux Games

The problem with the clipboard under X is that there are a number
of different protocols. Luckily most environments are moving towards
Xdnd for drag and drop and clipboard issues:

http://www.newplanetsoftware.com/xdnd/

ICCCM compliant applications will usually store the "cut/paste"
stuff in the CLIPBOARD Atom, and the current selection in PRIMARY.

http://www.freedesktop.org/standards/clipboards.txt

Provides quite a bit of insight into this topic, and what problems
you’ll currently run into.

If you write it, I wouldn’t mind seeing a patch / new lib for SDL :)–
David J. Goehrig dave at cthulhu-burger.org

All reports, excluding those of historical fact, may be considered speculative.
- a faceless Compaq disclaimer

Mattias Engdeg?rd wrote:

Joseph Carter wrote:

I’ve asked Sam about this before and he told me that it might be added to
1.3, but I have an application which could really benefit from reading the
system’s clipboard.

I’m not convinced it’s an essential SDL feature. It is only useful in
windowed mode, which is mostly a convenience/debug variant of
fullscreen mode, the “proper” SDL way of operation. Once we allow one
GUI/windowing tie-in, more demands for other things will come.

I have to agree with Mattias on this one. It seems to me that largely
due to it’s ease of use and cross platform input handling people are
grabbing on to SDL as a general purpose replacement for the native GUI
APIs on the supported platforms and trying to do things in SDL that
really require a full GUI. There are already a number of cross platform
GUI’s they are all complicated to learn and use for the simple reason
that adding all the functionality that programmers have asked for in a
GUI results in a large complex system. Adding features to SDL to support
more GUI features is a slippery slope that can lead to a version of SDL
that is as complex and hard to learn as Windows or X11.

I would suggest that a cross platform package that supports the
clipboard of different systems would be a very valuable thing to have.
And, it would be very useful for many SDL developers. But it is not
properly part of the core of SDL because it can be developed without
changing any other part of SDL. I think that is the key point I am
making. You don’t have to change SDL to write this package. In contrast,
support for multiple windows requires changes to core SDL routines, even
changes in the event structure to identify the source window. So, it
that were added it would have to be part of core SDL, not an add on
package.

	Bob Pendleton

Hey guys, there’s an example of using the system clipboard at:
http://www.libsdl.org/demos.html

Look for "scrap"
It works on X11 and Win32 cutting and pasting both text and images.

A much simplified version of that code has been used in Loki’s titles
since the very beginning.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

I’ve asked Sam about this before and he told me that it might be added to
1.3, but I have an application which could really benefit from reading the
system’s clipboard.

I’m not convinced it’s an essential SDL feature. It is only useful in
windowed mode, which is mostly a convenience/debug variant of
fullscreen mode, the “proper” SDL way of operation. Once we allow one
GUI/windowing tie-in, more demands for other things will come.

The primary place SDL is used is under a windowing system, regardless of
how it is actually used. The reason the feature is requested in the first
place is in fact that writing IP addresses down on a piece of paper, then
running the game fullscreen and typing them in is not exactly a fun
prospect.

Your argument against the feature is at best a slippery slope argument,
and I honestly don’t really care at this point if SDL has the feature or
not - I have already been told to wait at least a year for it and I can’t
do that. In the meantime I have a need for something SDL doesn’t do and I
still am no closer to finding out even that it can be done.

From what I did manage to understand, I probably
want to read from XA_PRIMARY.

Right. The details are in the Xlib docs and in the ICCCM. Remember that the
X11 selection semantics are quite different from those in win32 or MacOS.
For example, there is no “clipboard” holding the selected data anywhere,
but only a promise from a client to deliver the selection upon request.

Then it sounds like I did not misunderstand the code. I resubmit that SDL
must do it because only SDL can.On Tue, Jan 29, 2002 at 01:43:40PM +0100, Mattias Engdegard wrote:


Joseph Carter Now I’ll take over the world

QF is going to get zipfile support today
heh… infozip?
If I’m lucky yes
knghtbrd: You’re kidding, right? :wink:

  • Deek takes away Knghtbrd’s crack pipe. :wink:

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020129/3c991033/attachment.pgp

I do believe that being able to read and write the
clipboard is an important feature even in a limited
state. I am running into the same issue with
copy/pasting IP addresses. Obviously I can make a
separate library that would be cross-platform to
perform just this function but I don’t believe that
would be the best place for it. I don’t think anyone
wants to make SDL a windowing system or anything the
like, but for games like mine and I’m sure many others
even the limited use of copy/paste is beneficial to
the programmer and the user.

Alan__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com

— Sam Lantinga wrote:

Hey guys, there’s an example of using the system
clipboard at:
http://www.libsdl.org/demos.html

Look for "scrap"
It works on X11 and Win32 cutting and pasting both
text and images.

A much simplified version of that code has been used
in Loki’s titles
since the very beginning.

See ya,
-Sam Lantinga, Software Engineer, Blizzard
Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

DOH I didn’t see your message and replied to
another… thanks Sam! Do you think we can integrate
this into SDL?

Alan__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com

DOH I didn’t see your message and replied to
another… thanks Sam! Do you think we can integrate
this into SDL?

Maybe at some point.
In the meantime, just rip it out of scrap and use it directly.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Joseph Carter wrote:

The primary place SDL is used is under a windowing system, regardless of
how it is actually used.

No.

The reason the feature is requested in the first

place is in fact that writing IP addresses down on a piece of paper, then
running the game fullscreen and typing them in is not exactly a fun
prospect.

That is quite a different matter, and should perhaps not be handled by
SDL at all. Remember, SDL is not a toolkit for windowed user interfaces

[…]

Naturally, I’d really rather see SDL have the feature so I don’t have
to worry about how to support things like the convoluted mess related
to X11 in my otherwise very clean, simple, and portable code. =p At
the moment it looks like win32 will probably get the feature and Linux
is going to get a stub function. MacOS X is up in the air still, I
don’t think we have anyone actually working on that platform at the
moment.

I’m interested in anything you come up with. No former experience with
the X11 clipboard though, so I can’t help you there…

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Tuesday 29 January 2002 12:32, Joseph Carter wrote:

I have no problem with a separate library that implements this kind of
stuff - it just has to be possible to do without hacking SDL.

I’d guess most of this stuff could be made possible by providing a “semi
public” platform specific SDL API for such libraries to use…

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Tuesday 29 January 2002 13:43, Mattias Engdeg?rd wrote:

Joseph Carter wrote:

I’ve asked Sam about this before and he told me that it might be added
to 1.3, but I have an application which could really benefit from
reading the system’s clipboard.

I’m not convinced it’s an essential SDL feature. It is only useful in
windowed mode, which is mostly a convenience/debug variant of
fullscreen mode, the “proper” SDL way of operation. Once we allow one
GUI/windowing tie-in, more demands for other things will come.

The primary place SDL is used is under a windowing system, regardless of
how it is actually used.

No.

Show me an accellerated OpenGL supported by SDL which does NOT require a
windowing system at the moment. When SDL is used on Win32, you have a
windowing system. On a Mac? Windowing system. Be? Windowing system
again. Linux? X11 is certainly a windowing system, and the standard if
not the primary development platform. And even in the Linux framebuffer
it is reasonable for the game to support the GPM copy buffer if it can be
done.

GGI is quite, quite dead as a practical platform to develop SDL apps for
anymore, except as a novelty and SVGALib is depercated for literally every
task you can apply it toward if you have any other option whatsoever. I
don’t see many places SDL runs which do not have a clipboard available for
SDL to read.

The reason the feature is requested in the first

place is in fact that writing IP addresses down on a piece of paper, then
running the game fullscreen and typing them in is not exactly a fun
prospect.

That is quite a different matter, and should perhaps not be handled by
SDL at all. Remember, SDL is not a toolkit for windowed user interfaces

SDL is a cross-platform API for games. Last I checked, Quake is a game.
It’s quite a popular game, one which came with support for pasting from
the win32 clipboard, I might add.

I’m not asking for a set of GUI tools. I don’t want portable dialog boxes
and pulldown menus (and if I do, it’s my job to write those things anyway,
not SDL’s, and I don’t think anyone can disupute that,) What we are
talking about is the inability to mark an address from say a webpage or a
terminal window and feed this to the game. This is not an isolated
problem affecting exactly one game. Indeed it probably affects most of
the network multiplayer games out there today. Maybe you won’t use the
feature. I think the rest of us probably would.On Wed, Jan 30, 2002 at 11:13:47AM +0100, Mattias Engdegard wrote:


Joseph Carter No conceit in my family

  • woot smiles serenely.
    I don’t want to seem over eager about getting into knghtbrd’s
    siglist.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020130/31dcbf32/attachment.pgp

What little I know about X11, I do not wish to expand on. Given the
choice between writing code for X11 and leaving the Linux platform to go
work on a Mac or something which is not braindead by design (pr lack of
it, as the case seems to be…)

After all, that’s what I am using SDL for isn’t it? To have a portable
way of coding for multiple platforms without dealing with the stupidities
of any of them directly (including my own!)

I do not have a way to poll for X events without competing with SDL for
those events. That seems to be required for implementing clipboard
support in X11. I’ve got Sam’s scrap demo here, but if that doesn’t have
what I need, I’m relatively certain that I can’t implement the support
without SDL changes. Even then, this feature does IMO belong in SDL
because it is an appropriate and desired feature for the kind of program
SDL was designed to be used for.On Wed, Jan 30, 2002 at 11:11:42PM +0100, David Olofson wrote:

Naturally, I’d really rather see SDL have the feature so I don’t have
to worry about how to support things like the convoluted mess related
to X11 in my otherwise very clean, simple, and portable code. =p At
the moment it looks like win32 will probably get the feature and Linux
is going to get a stub function. MacOS X is up in the air still, I
don’t think we have anyone actually working on that platform at the
moment.

I’m interested in anything you come up with. No former experience with
the X11 clipboard though, so I can’t help you there…


Joseph Carter Sooner or later, BOOM!

Unix is mature OS, windows is still in diapers and they smell badly.
– Rafael Skodlar

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020130/9fe83952/attachment.pgp

Joseph Carter wrote:

What we are
talking about is the inability to mark an address from say a webpage or a
terminal window and feed this to the game

since you want to interact with other applications and transfer data between
them, that part sounds like a good use for a traditional UI toolkit.
Nothing forces you to use SDL for the non-game parts

To risk perpetuating a thread that’s gone around in at least three
complete circles already. Isn’t supporting the clipboard of very nearly
the same as setting the window’s title via the window manager?

A lot of the arguments here are based on the fact that SDL isn’t meant
to interact with a windowed environment because its intended use is in
fullscreen.

This is a question, not an argument. Isn’t the clipboard give or take
the same as something as exotic as changing the minimized icon art in
the windowed environment?On Wed, 2002-01-30 at 18:08, Mattias Engdegard wrote:

Joseph Carter wrote:

What we are
talking about is the inability to mark an address from say a webpage or a
terminal window and feed this to the game

since you want to interact with other applications and transfer data between
them, that part sounds like a good use for a traditional UI toolkit.
Nothing forces you to use SDL for the non-game parts


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Isn’t involving a toolkit library, with all the related portability
issues, another API to deal with etc, quite a high cost for an IP
entering “widget”, especially considering that it can’t even coexist with
the game display in full screen mode when desired…?

Either way, I’ve already expressed my opinion on this: If it doesn’t
belong in SDL, just have SDL provide some “hooks” (that seem to be
required for some platforms), and then implement this kind of stuff in
external libraries.

support != implementation

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Thursday 31 January 2002 00:08, Mattias Engdeg?rd wrote:

Joseph Carter wrote:

What we are
talking about is the inability to mark an address from say a webpage
or a terminal window and feed this to the game

since you want to interact with other applications and transfer data
between them, that part sounds like a good use for a traditional UI
toolkit. Nothing forces you to use SDL for the non-game parts

I do not have a way to poll for X events without competing with SDL for
those events. That seems to be required for implementing clipboard
support in X11. I’ve got Sam’s scrap demo here, but if that doesn’t have
what I need, I’m relatively certain that I can’t implement the support
without SDL changes. Even then, this feature does IMO belong in SDL
because it is an appropriate and desired feature for the kind of program
SDL was designed to be used for.

http://www.icculus.org/~relnev/copy.c

This code is broken, as:

  1. it doesn’t wait for the proper event
  2. it uses CurrentTime instead of a normal time value
    (both can be fixed by using SDL_SYSWMEVENT, see SDL_syswm.h for details)

but it’s a start.

Steven FullerOn Wed, 30 Jan 2002, Joseph Carter wrote:

Mattias Engdeg?rd wrote:

Joseph Carter wrote:

What we are
talking about is the inability to mark an address from say a webpage or a
terminal window and feed this to the game

since you want to interact with other applications and transfer data between
them, that part sounds like a good use for a traditional UI toolkit.
Nothing forces you to use SDL for the non-game parts

That’s great to know, please point me to a list of available SDL widgets
for the major cross platform GUI toolkits. I’m aware of the half done
one for GTK, but I hadn’t been able to find any others.

	Bob P.> 

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-----------------------------------+

  • Bob Pendleton is seeking contract +
  • and consulting work. Find out more +
  • at http://www.jump.net/~bobp +
    ±-----------------------------------+