Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-16-2006, 08:20 AM   #1 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
Linux message handling?

Ok i'm moving to cross-platform coding but i have a question.

In Windows i use PostMessage() and SendMessage() to put a message in the queue for processing.
Is there something similar for X ?
DJMaze is offline   Reply With Quote
Old 03-16-2006, 09:52 AM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
i think i got it.
Windows API uses GetMessage() the X API uses XNextEvent().

Am i correct?
DJMaze is offline   Reply With Quote
Old 03-16-2006, 06:58 PM   #3 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
LOL i am correct and the systems are way different.

Win32 has PeekMessage() and so does Xlib, but Win32 returns 0 and stops where Xlib blocks and waits for the next message to occure.

So to get the same effect as Win32 we must use something like:
PHP Code:
int ProcessQueue()
{
#ifdef WIN32
    
MSG message;
    while (
PeekMessage(&msgNULL00PM_REMOVE) > 0)
    {
        if (
MSG.message == WM_QUIT) { return 0; }
        
TranslateMessage(&message);
        
DispatchMessage(&message);
    }
#else
    
XEvent message;
    while (
XEventsQueued(display_connect_idQueuedAfterReading))
    {
        
XNextEvent(display_connect_id, &message);
        
MyMessageHandler(message);
    }
    return 
1// all messages handled
#endif

just my $0.02
DJMaze is offline   Reply With Quote
Old 03-16-2006, 07:01 PM   #4 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Do you have the option of using a cross platform toolkit like Qt to make things easier?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 03-16-2006, 07:11 PM   #5 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
I've tried many including wxWidgets, FLTK and GTK but they will not work for my application.

The issue is that i'm rewriting my music player and it allows to have trayicon and is multi-threaded to prevent racing since some graphical interfaces use heavy painting.
I know multi-threaded applications are in most people their eyes cumbersome and have no real benefit on single CPU's, but on multiple cpu's this is realy great.
Thanks to the multi-threading it also allows me to properly implement video playback over several monitors.

None of the toolkits properly provide me these powers unless i hack the source and recompile the library.

Secondly most widgets used in the toolkits are not used by my application so a 10MB library like wxWidgets is just nuts (unless i compile it staticaly)

My application is also used by many dj's, amusement parks and pubs. It would be nuts to make a less-stable system.
Although FLTK is rock solid and lightweight, it is missing some stuff i need and has default actions i don't want.

That's why i write my own toolkit
DJMaze is offline   Reply With Quote
Old 03-16-2006, 07:36 PM   #6 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Fair enough, I was just impressed by Qt's write once/compile most places ease of use. It looks like you're working on something a bit slimmer though.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 03-17-2006, 07:50 AM   #7 (permalink)
AssKoala
Anti-Zealot
 
AssKoala's Avatar
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 72
AssKoala is on a distinguished road
Send a message via AIM to AssKoala Send a message via MSN to AssKoala Send a message via Yahoo to AssKoala
Quote:
Originally Posted by DJMaze
I know multi-threaded applications are in most people their eyes cumbersome and have no real benefit on single CPU's, but on multiple cpu's this is realy great.
Completely and totally untrue (the bolded part). If a thread blocks on I/O, other threads can execute for the process (assuming you wrote a halfway decent application and you aren't using an OS with a crap scheduler (e.g. Linux pre-2.6 scheduler)).

Good luck with your app, though I thought you could get tray icons with Qt, just by switching to a different execution path depending on the OS.
__________________
If you always think like an expert, you'll always be a beginner. | "A handful of knowledgeable people is more effective than an army of fools" -Writing Secure Code, 2nd Ed.
AssKoala is offline   Reply With Quote
Old 03-17-2006, 08:44 AM   #8 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
ehm it was ment as:

in most people their eyes: "cumbersome and have no real benefit on single CPU's"

english is not my first language

Quote:
Originally Posted by AssKoala
Good luck with your app, though I thought you could get tray icons with Qt, just by switching to a different execution path depending on the OS.
Correct, so does wxWidgets.
I do have them all installed since X programming is new to me or else i get realy lost. But for now these toolkits don't benefit my work like i want it.

Googling for "convert win to x" and many more just results in nothing worthwhile to read so i'm digging thru all code and slowly find my way.
Posting questions in here and finding the answers myself is ok in my opinion since it will also help others with the same troublesome.
When we all gathered enough info about the differences in both API's and how to handle/convert code codenewbie could become a great asset for many coders including all the software companies that still only write software for crappy Windows since 80% is still on windows.
DJMaze is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
networking windows and linux problem cheawick Linux / BSD / OS X 4 12-31-2004 05:40 PM
Strong growth for Linux servers sde Code Newbie News 0 12-07-2004 06:39 AM
Adobe dipping toes into desktop Linux waters sde Code Newbie News 0 11-03-2004 06:27 AM
IBM to launch MS Office for Linux redhead Code Newbie News 0 02-16-2004 01:34 AM
Linux policies Belisarius Linux / BSD / OS X 0 08-09-2003 05:12 PM


All times are GMT -8. The time now is 11:53 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting