Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Clipboard

This thread is locked; no one can reply to it. rss feed Print
Clipboard
Arthur Kalliokoski
Second in Command
February 2005
avatar

Neither my header files nor Google know what an ImageTypeAtom is, there are several references to ImageType, but those all seem to be gtk or C++ specific etc.

[EDIT]

I got a new computer, and had to reinstall a4.4 to compile the Clipboard*.c files, and while playing with the example programs and the demo, I just want to say that going to a fullscreen mode at the very start is a Bad Thing(TM). Bombing out with errors leaves you at 320x200 for a desktop mode.

They all watch too much MSNBC... they get ideas.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Neither my header files nor Google know what an ImageTypeAtom is, there are several references to ImageType, but those all seem to be gtk or C++ specific etc.

I'm a dimwit. Change line 351 of xcsi.c to :

   Atom ImageTypeAtom = StringTypeAtom;/// TODO : STRING , really? What Type should an image have?

Arthur Kalliokoski said:

I just want to say that going to a fullscreen mode at the very start is a Bad Thing(TM). Bombing out with errors leaves you at 320x200 for a desktop mode.

You'll probably hate me for saying this, but I can't remember a time that Windows didn't reset the video mode back to the original desktop setting when a program aborted.

I'm going to go work on adding support for INCR transfers. You might need it when trying to retrieve an image from the clipboard when you copy your desktop image or maybe other times as well. If only I could figure out what the supposed maximum transfer size was...

Arthur Kalliokoski
Second in Command
February 2005
avatar

wait...

They all watch too much MSNBC... they get ideas.

bamccaig
Member #7,536
July 2006
avatar

I'm a dimwit. Change line 351 of xcsi.c to :

Atom ImageTypeAtom = StringTypeAtom;/// TODO : STRING , really? What Type should an image have?

There's a file type for that. ;) It's called a patch file (or less formally a diff file).[1] You wouldn't know that in the Windows world though. Every one of you would just ... ugh ... edit the file manually. ;) For the record, the MSYS (or maybe MinGW) version of patch does work and should be sufficient to inline a basic patch for something like ^ that. :-X Cygwin's port definitely works. In fact, that simple of a patch is easy enough to write manually if you know what the original file looked like. :P

You'll probably hate me for saying this, but I can't remember a time that Windows didn't reset the video mode back to the original desktop setting when a program aborted.

Windows does things rather fucked up. Its programs actually seem to need to know what type of program they are and such and that controls what they can and can't do. As a result, most Windows programmers are probably oblivious to the concept of standard streams, command line arguments, or exit codes, making their software pretty useless unless you hire a babysitter... In Linux, I think a program is just a program, and if it happens to create and draw X windows, or enable full screen mode and set the screen resolution then so be it. Of course, if it crashes after it has changed the screen resolution then X remains in the state that it is in. You might think that Windows is doing a better job here, and perhaps given the context it is, but I think the Linux (perhaps it's more correct to say UNIX) way is far better. It would be nice though to create a temporary context that dies with the application regardless of a clean exit. Given the design I'm not sure that it would make sense to though (I'm not very familiar with how it works [yet]).

Arthur Kalliokoski
Second in Command
February 2005
avatar

I got it to say it successfully copied the CyberMan image, and blitting it just showed a white square.

The log file said

QueryAvailableTargets info : selection owner window's name : 
QueryAvailableTargets : 4 targets available :
   TARGETS
   TIMESTAMP
   MULTIPLE
   image/bmp

It also caused the Konquerer file browser to not refresh properly :-X.

They all watch too much MSNBC... they get ideas.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

bamccaig said:

There's a file type for that. ;) It's called a patch file (or less formally a diff file). You wouldn't know that in the Windows world though. You people just ... ugh ... edit the file manually. ;)

It's a one line change, of exactly 4 whole characters. 6 if you count Ctrl-S. :P
Compared to

patch xcsi.c xcsi.diff

I saved you exactly 16 characters of typing. :P

I know exactly what a diff and a patch is, not to mention that I have gnuwin32 diff and patch installed on my computer and I've used them to send patches to the allegro mailing list before. Not to mention earlier in this thread I used diff to see what changes Arthur had made to my source file to get it to compile. :P

Bill the Cat said:

THBBFT!

{"name":"603460","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/0\/90b3fb297211d5b8314a51d47479e84a.jpg","w":370,"h":406,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/0\/90b3fb297211d5b8314a51d47479e84a"}603460

I got it to say it successfully copied the CyberMan image, and blitting it just showed a white square.

Well, that's progress, sort of... It means the bitmap saved and loaded, so at least it was recognized as a bitmap. I'll try testing some things here.

Maybe the transfer process corrupted the file somehow?
Can you see anything wrong with using cat to pipe the file into xcsi's stdin?

cat xcsi_image_temp.bmp | xcsi -c -s=bmp
 

Is there a better way to feed a file to xcsi through stdin?

Try copying images from other programs and see what paste (key V) does with those.

Arthur Kalliokoski said:

It also caused the Konquerer file browser to not refresh properly :-X.

Are you sure it was ClipboardTest or xcsi that caused it? I can't see why it would do that. I respond to all SelectionRequest and SelectionNotify events where appropriate.

bamccaig
Member #7,536
July 2006
avatar

It's a one line change, of exactly 4 whole characters. 6 if you count Ctrl-S. :P
Compared to

patch xcsi.c xcsi.diff

I saved you exactly 16 characters of typing. :P

That's not true. You aren't considering the keystrokes and mouse movements to navigate to that line of the file and manually edit it (which in itself can be error prone). The computer can do it much faster and more reliably (not to mention bash completion on the command and patch file). Also, you usually don't specify the file to patch (that's stored in the patch itself), and the patch file is either provided on stdin or with the -i option (at least in Linux, but I think it's the same in Cygwin and MSYS). ;)

I know exactly what a diff and a patch is, not to mention that I have gnuwin32 diff and patch installed on my computer and I've used them to send patches to the allegro mailing list before. Not to mention earlier in this thread I used diff to see what changes Arthur had made to my source file to get it to compile. :P

:-X

Is there a better way to feed a file to xcsi through stdin?

You could just use the stream redirection operator:

xcsi -c -s=bmp < xcsi_image_temp.bmp

Arthur Kalliokoski
Second in Command
February 2005
avatar

cat xcsi_image_temp.bmp | xcsi -c -s=bmp

I copied CyberMan.bmp to xcsi_image_temp.bmp, then ran the command. Nothing happened as far as I could see, so I blasted the the xcsi log to screen again, and saw a whole slew of SelectionRequest to Konqueror. I deleted the log and ran that cat command again, but no new log was created. But then both Konqueror and Firefox were pretty much catatonic when trying to post this. Get your own Linux to futz with! I'm not playing anymore! >:(

They all watch too much MSNBC... they get ideas.

bamccaig
Member #7,536
July 2006
avatar

I said:

You could just use the stream redirection operator...

I would imagine that STDIN would be considered text by default though so you may or may not need to do something special to treat it as binary data to get reliable results. :-/

Arthur Kalliokoski
Second in Command
February 2005
avatar

bamccaig said:

I would imagine that STDIN would be considered text by default though so you may or may not need to do something special to treat it as binary data to get reliable results.

I thought it was only Windows that differentiated between text and binary data? The "rb" and "wb" parameters to fread() & fwrite().

They all watch too much MSNBC... they get ideas.

bamccaig
Member #7,536
July 2006
avatar

I thought it was only Windows that differentiated between text and binary data? The "rb" and "wb" parameters to fread() & fwrite().

You're probably right. Windows and other weird OSes are the only ones that consider newlines as multi-character... I imagine that it depends how the file is read also (some routines will assume text), but those wouldn't be used when reading images anyway so maybe I'm just being paranoid...

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

bamccaig said:

You could just use the stream redirection operator:

xcsi -c -s=bmp < xcsi_image_temp.bmp

Okay, thanks, I'll try that instead.

I copied CyberMan.bmp to xcsi_image_temp.bmp, then ran the command. Nothing happened as far as I could see

No problem there, when you set the clipboard or primary selection with xcsi, it forks and then waits for SelectionRequest events.

Arthur Kalliokoski said:

so I blasted the the xcsi log to screen again, and saw a whole slew of SelectionRequest to Konqueror.

Define 'whole slew'. Do you mean 50, 100, 500 requests? Also, do you remember the target that it was requesting? TARGETS would be normal, but image/bmp would be rather expensive to do on each update.

Arthur Kalliokoski said:

I deleted the log and ran that cat command again, but no new log was created.

That's okay, no requests, no log entries.

Arthur Kalliokoski said:

But then both Konqueror and Firefox were pretty much catatonic when trying to post this.

It's hard for me to determine why without xcsi_log.txt to tell me what was going on while the programs were unresponsive. If you use pskill to stop xcsi from running, does that return konqueror and firefox to a normal responsive state?

Arthur Kalliokoski said:

Get your own Linux to futz with! I'm not playing anymore! >:(

It's up to you. I wouldn't have gotten this far without your help though, so many thanks for what you've done so far.

bamccaig said:

I would imagine that STDIN would be considered text by default though so you may or may not need to do something special to treat it as binary data to get reliable results. :-/

Hmm, you may be right. STDIN is probably being read as text. Although I don't believe that any character translations like \n to <CR><LF> are being performed on Linux, so technically, using getchar should act as if it were binary data.

Maybe I need to specify an input file as an argument to xcsi and then open the file in binary read mode and specify an output file as an argument and open the file in binary write mode.

bamccaig
Member #7,536
July 2006
avatar

Hmm, you may be right. STDIN is probably being read as text. Although I don't believe that any character translations like \n to <CR><LF> are being performed on Linux, so technically, using getchar should act as if it were binary data.

Maybe I need to specify an input file as an argument to xcsi and then open the file in binary read mode and specify an output file as an argument and open the file in binary write mode.

In reality I can't think of a case where binary and text files should be interpreted differently in Linux. :-/ So I don't think it would matter. Either way, I would hope that it is possible to change STDIN to binary mode because it is a very good practice to use it when it makes sense. Even if you do support a command line argument (probably a good idea if you intend for the program to be used directly), that depends on the data being in a file, and sometimes you want to write the data directly to the process without using the underlying file system.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

That's easy enough to support though, the 4th (file) argument would be optional. If present, i/o would be performed through the specified file, otherwise through stdin.

Append
I'm currently posting this from FireFox using openSUSE 11.3 in a virtual machine under Vista. Whee! I have to say though, so far I'm not that impressed with Linux. It's okay, but it's nothing to brag about. I could also install either Fedora 14 or Ubuntu 10.10 if anyone recommends that. I'm currently using Gnome as my desktop.

Anyway, now that I have a Linux install up and running, maybe I can see about fixing the problems Arthur was having with my clipboard. It may be a few days though, until I get A4.4 up and running again.

Arthur Kalliokoski
Second in Command
February 2005
avatar

It's okay, but it's nothing to brag about.

Give it time, son, give it time. OTOH, you have to use it regularly to achieve nirvana, once every couple months it'll always seem strange.

They all watch too much MSNBC... they get ideas.

AMCerasoli
Member #11,955
May 2010
avatar

Trezker, if you manage to do the clipboard lib could you post it in the Depot?, I was reading the topic but I get lost in page 3-4, so if you can do it using Allegro 5 I would like to try it, since I need something like that in my program. thanks

bamccaig
Member #7,536
July 2006
avatar

I'm currently posting this from FireFox using openSUSE 11.3 in a virtual machine under Vista. Whee! I have to say though, so far I'm not that impressed with Linux. It's okay, but it's nothing to brag about. I could also install either Fedora 14 or Ubuntu 10.10 if anyone recommends that. I'm currently using Gnome as my desktop.

What specifically do you find unimpressive? The Linux desktop is nothing to gawk at. It's functional, but generally not that much different from Windows (and I presume OS X). You can install some eye candy if you want (i.e., compiz). KDE4 is also a bit more fancy, but last time I checked I also found it a bit less polished. Just remember that if it's not doing something that you want it to do there might already be a way to make it with configuration options. And if not, a way can always be added. :P The real power of a Linux (or UNIX) system though is on the command line shell. You now have one that works and works well. Learn to use it to your advantage.

I personally recommend Fedora, but that's mostly because it's the distribution that I have the most experience with (and might become an official contributor to soon...).

It may be a few days though, until I get A4.4 up and running again.

Now that you're in Linux getting A4.4 up and running is a breeze. :P

m c
Member #5,337
December 2004
avatar

Edgar sorry I went away I was busy with IRL stuff, you know how it goes.

I don't think that loading packfiles from memory is supposed to be very difficult though? But then I read the docs and it says

Quote:

Note that prior to version 4.1.18, some internal fields were accidentally documented - but PACKFILE should be treated as an opaque structure, just like the libc FILE type.

So maybe my memory is obsolete now.

(\ /)
(O.o)
(> <)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

bamccaig said:

What specifically do you find unimpressive?

So far :

  • 1) The file manager - there's no folder tree to navigate folders, only hard links to special folders.

  • 2) Software management

    • a) zypper search only gives you package names, it doesn't tell you how to download specific versions of a certain package. This gave me a bunch of trouble because I'm trying to install the VirtualBox Guest Additions and I have to have the same kernel development version as the kernel I'm using.

    • b) YaST Software Management
      - I run it, and it tells me

      Quote:

      System management is locked by the application with pid 22596 (usr/sbin/packagekitd). Close this application before trying again.

      So I can't even use YaST to update software without killing another process (and that process doesn't even show up on the taskbar, nor do I know what the equivalent of Windows Task Manager is in openSUSE, if there even is one...).

  • 3) Application viewer / start menu
    The start menu shows favorite applications, and recent applications, with an option to show all applications, but when you show all the applications, you get a whole bunch of icons instead of a simple menu. I never liked OSX for all the stupid icon views it has, and it's equally annoying in Linux.

Trezker, if you manage to do the clipboard lib could you post it in the Depot?, I was reading the topic but I get lost in page 3-4, so if you can do it using Allegro 5 I would like to try it, since I need something like that in my program. thanks

I don't think Trezker is working on his version of the clipboard library anymore. As far as I know, I'm the only one who's still actively developing this. So far my version has support for copy/paste of text/images on Windows and support for copy/paste of text and almost images on Linux. No MacOSX support yet though.

It's also only Allegro 4 at this point, but if someone writes al_bitmap_to_hbitmap and hbitmap_to_al_bitmap functions then it could easily be converted to work with Allegro 5.

m c said:

Edgar sorry I went away I was busy with IRL stuff, you know how it goes.

No big deal. Thanks for trying it though. The latest version is here if you want to give it a go. Arthur was having some problems with it though and I'm currently trying to get my Linux development environment set up to test it.

BAF
Member #2,981
December 2002
avatar

KDE4 is far too plastic-y looking. It looks like a cheap toy, and functions about equally as well. Linux user interfaces are a joke, they're about on par with Windows 95.

Evert
Member #794
November 2000
avatar

The file manager

You can almost certainly configure it for whatever your preferred view is (not sure I understand what you mean though) or use a different one that suits you better.

Quote:

a) zypper search only gives you package names, it doesn't tell you how to download specific versions of a certain package. This gave me a bunch of trouble because I'm trying to install the VirtualBox Guest Additions and I have to have the same kernel development version as the kernel I'm using.

Does it have a manpage? Or a --help option? My guess is that you simply add the version number (as "-versionnumber") to the package name.
Ultimately though, you should use whatever the latest version in the repository is. As long as you update the kernel and the sources at the same time, you should be ok.

Quote:

b) YaST Software Management
- I run it, and it tells me
Quote:

System management is locked by the application with pid 22596 (usr/sbin/packagekitd). Close this application before trying again.

So I can't even use YaST to update software without killing another process (and that process doesn't even show up on the taskbar, nor do I know what the equivalent of Windows Task Manager is in openSUSE, if there even is one...).

$ kill -9 22596
I'm sure there's a way to do it through the GUI, but I've never used it.

Quote:

The start menu shows favorite applications, and recent applications, with an option to show all applications, but when you show all the applications, you get a whole bunch of icons instead of a simple menu. I never liked OSX for all the stupid icon views it has, and it's equally annoying in Linux.

Not sure what you're referring to here either, but it depends very much on what window manager you use. Some of them don't have a "start menu" at all, for others its entirely optional.

None of those things have specifically to do with "Linux", but more with the window manager you're using, and how that window manager is configured (which can depend a lot on the distribution). Just experiment with different options and see if there's one you like better.

bamccaig
Member #7,536
July 2006
avatar

So far :

  • 1) The file manager - there's no folder tree to navigate folders, only hard links to special folders.

  • 2) Software management

    • a) zypper search only gives you package names, it doesn't tell you how to download specific versions of a certain package. This gave me a bunch of trouble because I'm trying to install the VirtualBox Guest Additions and I have to have the same kernel development version as the kernel I'm using.

    • b) YaST Software Management
      - I run it, and it tells me

      Quote:

      System management is locked by the application with pid 22596 (usr/sbin/packagekitd). Close this application before trying again.

      So I can't even use YaST to update software without killing another process (and that process doesn't even show up on the taskbar, nor do I know what the equivalent of Windows Task Manager is in openSUSE, if there even is one...).

  • 3) Application viewer / start menu
    The start menu shows favorite applications, and recent applications, with an option to show all applications, but when you show all the applications, you get a whole bunch of icons instead of a simple menu. I never liked OSX for all the stupid icon views it has, and it's equally annoying in Linux.

So basically your complaint is that it's not Windows? :P There is a learning curve involved. If you installed Linux looking for a free Windows then I'm afraid that you'll be sorely disappointed. On the other hand, GNU/Linux distributions do most things better than Windows, once you get used to them. And the things that they don't do better usually still work pretty well and are always open to improvement. There are still a handful of things that need improvement, but then you paid fuck all so who are you complaining to?

Then again, I'm not too sure about your choice of distribution. I've never used OpenSUSE so I can't really critique it fairly, but I have heard of problems and know Fedora to be relatively smooth sailing and Debian-based distros (Ubuntu being the most n00b friendly, I guess) are pretty well kept up as well. It's possible that you've chosen a lemon, though I suspect that your biggest problems are just change. Those are going to be there no matter what distribution you choose. Either stick it out or try a different distribution. Honestly, the best way to learn is to make the OS your primary OS. Then you have to learn. Of course, it still takes time. I wonder why you were even trying to make an X implementation if you're completely new to unices... :-X

The file explorer can be configured somewhat. It should be able to satisfy your desires. I'm too drunk to figure out what those are though. The one option that I always enable isn't even present anymore when I check Nautilus' dialog, though it does behave correctly still. Aside from that, Nautilus (Gnome's default file manager AFAIK) works pretty predictable. Can you better describe what is wrong?

As for versions of software, I honestly couldn't tell you. In my experience, I either deal with whatever version my distribution offers through its package manager, or attempt to build from source (which can go easily and can go difficult, depending mostly on dependencies). I would suggest that you ask yourself when you need a particular version. Often, the version available with the default options is sufficient. If not then you'll just have to accept the need for manual processing. Often the GUI interfaces in Linux are hacked together by people trying to fill a niche. The most complete and powerful interfaces are usually accessible from the command line first. Don't expect to point and click your way through Linux.

As for the existing PID lock, that is a GUI manager designed to show you when updates are available. There should be an icon in the analogue to the notification area (usually next to the time). Generally, you won't hurt anything by killing that process either if you feel so bold. It's a reasonable thing to occur though, and once you've gained more experience you'll learn to appreciate it. That said, as I mentioned earlier, I have zero experience with OpenSUSE (or any SUSE derivatives) so I can't honestly say how the system is built or even what package format is used. If you really can't survive with it then try a different distribution.

I have no idea what you're talking about regarding the icons on the menu. Maybe that's a theme used by OpenSUSE. With Fedora, Gnome's default menu(s), at least as far Fedora 13, are even easier to use than on Windows. Applications are grouped by type, and each option typically has an icon and a name, and displays a summary when moused-over.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Evert said:

Does it have a manpage? Or a --help option?

Yes, the --help option didn't describe versioning syntax, but after taking a look at the manpage today, it was there. But I figured out how to do it with the YaST Software Manager first.

Evert said:

None of those things have specifically to do with "Linux", but more with the window manager you're using, and how that window manager is configured (which can depend a lot on the distribution). Just experiment with different options and see if there's one you like better.

Well, to be fair, the window manager is an integral part of Linux. Maybe other window managers perform better, but I don't know that yet. I'll keep working with it and see how it goes.

bamccaig said:

So basically your complaint is that it's not Windows?

In a sense, yes, because Windows works. To be fair, I've sorted out most of the things that I didn't like so far. And to be honest, it's fairly common that you complain that Windows isn't Linux. Pot meet kettle?

There was a drop down list above the special folder links in the file manager and it had a folder tree view in the list. Yay! So I'm happy with that now.

YaST Software Manager is working now. Some process was downloading some kind of update list which interfered with the Software Manager. The upside is that the Software Manager lets me view and choose which version of a package to install, so I'm currently downloading the (hopefully) correct kernel-default-devel package.

bamccaig said:

Either stick it out or try a different distribution.

Well, it's not so bad I would give up on it after just a day using it. I did find the equivalent of Windows Task Manager, the Gnome System Monitor, so that's good.

bamccaig said:

I wonder why you were even trying to make an X implementation if you're completely new to unices... :-X

The main point of this library was that it would be cross platform, wasn't it? And to reveal the truth of it, this will be an addition to my GUI library, so I'm committed to it, because I want to be able to build applications as well as games with my library. Even if I'm new to Linux, I'm not new to C/C++. All it took was learning to use a new lib (Xlib). If you're not willing to branch out sometimes, then you'll never grow, am I correct? :D

m c
Member #5,337
December 2004
avatar

log file attached.

Viewing the bitmap in the program is just a white square, and I can neither paste the bitmap nor the text into other programs (in fact they either show the paste option grayed out, or it is active but selecting it does nothing and then after about 10 seconds I get a dialog box saying that there is no data available in the clipboard).

I remember that on linux if you try to paste some data from the clipboard after closing the program that it was copied from, then it is no longer available, so I don't really like the way that copy+paste works on linux.

One example is the screenshot utility, I would normally press print screen, choose "copy to clipboard" and then close the dialog that comes up, and then paste into GIMP, but I have to remember to leave the dialog open until I have pasted into gimp otherwise the screenshot data is lost....

[EDIT] I just tried again, and it is really 30 seconds not 10 seconds before it says "no data found in clipboard"

[EDIT 2] Also to get it to work I had to change many "xcsi blah blah" into "./xcsi blah blah" in Clipboard.c for ALLEGRO_UNIX section

(\ /)
(O.o)
(> <)

Evert
Member #794
November 2000
avatar

bamccaig said:

I've never used OpenSUSE so I can't really critique it fairly, but I have heard of problems and know Fedora to be relatively smooth sailing and Debian-based distros (Ubuntu being the most n00b friendly, I guess) are pretty well kept up as well.

Opposite for me: Fedora (and earlier RedHat) has always given me a headache, never had any real problems with SuSE (later OpenSuSE).
Never tried a Debian-based distribution though.

But I figured out how to do it with the YaST Software Manager first.

I remember it being fairly straightforward with YaST, but haven't used it recently enough that I could explain off the top of my head how to do it.

Quote:

Well, to be fair, the window manager is an integral part of Linux. Maybe other window managers perform better, but I don't know that yet.

No, you see, it is not an integral part of Linux. It's not even an integral part of X11. That's why you can swap it for another window manager that works completely differently so easily.

m c said:

I remember that on linux if you try to paste some data from the clipboard after closing the program that it was copied from, then it is no longer available, so I don't really like the way that copy+paste works on linux.

That depends. There's no such thing as "/the/ clipboard". There's several different ones, some of which may behave the way you describe and others that don't.
Those that don't may deal exclusively with text though.



Go to: