You are not logged in.

1

Friday, June 17th 2005, 5:09pm

Support for XUrgencyHint

Can someone tell me which version of KDE supports the XUrgencyHint?

My expectation is that using the XUrgencyHint is similar to flashing a window on win32 window managers. This is a common feature used by many IM applications such as Gaim.

If this feature is supported on KDE what is the user experience. Does the window button flash in the panel? Does the titlebar flash?

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Monday, June 20th 2005, 9:38am

I think KWin of KDE3.3 supports this, maybe already 3.2

It flashes the taskbar entry when a window requests attention

Cheers,
_
Qt/KDE Developer
Debian User

myak

Beginner

Posts: 6

Location: Warsaw, PL

  • Send private message

3

Thursday, June 23rd 2005, 4:18pm

Yeah, it flashes the taskbar entry but how to make it stop flashing?

There's this piece of code:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void ChatDlg::doFlash(bool yes)
{
    XWMHints *hints = XGetWMHints(qt_xdisplay(), this->winId());
    if (yes) {
        if (!(hints->flags & UrgencyHint))
            hints->flags |= UrgencyHint;
    }
    else {
        if (hints->flags & UrgencyHint)
            hints->flags &= ~UrgencyHint;
    }

    XSetWMHints(qt_xdisplay(), this->winId(), hints);
    XFree(hints);
}

(ChatDlg is subclass of QWidget)

And when window which has UrgencyHint flag set gets focus and then losts it the taskbar entry still flashes. I have to focus and unfocus the window 2-3 (sometimes more) times to stop the flashing, it seems completely random. yes argument is correct - when window gets focus it's set to false and when it should start flashing it's set to true - I've checked it already.

Am I doing something wrong or is it KDE's fault (I doubt it)?
Marcin Jakubowski
jid: kadat@hqdev.net

This post has been edited 2 times, last edit by "myak" (Jun 23rd 2005, 4:35pm)


Latem

Beginner

Posts: 31

Location: New Brunswick, Canada

Occupation: Student/Programmer

  • Send private message

4

Friday, June 24th 2005, 12:54am

If I understand what you want correctly, I think you want to flash the taskbar entry of a perticular window. Then, I think you can use NETWinInfo::setState() method. NETWinInfo is in kdecore. I think you would use it something like this:

Source code

1
2
NETWinInfo info( qt_xdisplay(), winId, qt_xrootwin(), 0 );
info.setState( NET::DemandsAttention );


At least that's how they use it in KWin.cpp.

To make it so it's timed, create a timer, or do a one shot timer, and on timeout, do the same thing but set the state to 0. I think that's how it can be done.

NETWinInfo is in kdecore. There is no docs for KWin in >= 3.3, but there are files kwin.h and kwin.cpp, and you can take a look at KWin::demandAttention() or something like that in kwin.cpp.

I was trying to do the same thing, and someone on IRC gave me this info.

Latem
The march of progress:
C:
printf("%10.2f", x);
C++:
cout << setw(10) << setprecision(2) << showpoint << x;
Java:
java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
String s = formatter.format(x);
for (int i = s.length(); i < 10; i++) System.out.print(' ');
System.out.print(s);

myak

Beginner

Posts: 6

Location: Warsaw, PL

  • Send private message

5

Friday, June 24th 2005, 1:15am

I'm looking for a Xlib + Qt (without KDE) solution but you may have pointed me in a right direction - thanks very much!

KWin::demandAttention() only sets one flag but I'm looking at kdecore's netwm.cpp and it may have solution to my problem. But still, if someone has a code snippet which does exactly (or almost exactly) what I want then please share :)

PS. @Latem: nice signature :)
Marcin Jakubowski
jid: kadat@hqdev.net

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

6

Friday, June 24th 2005, 2:24pm

You could ask on a xlib developer mailinglist or, if it works in other window managers and just not in KWin, on the kwin developer list.

Actually I would have expected that the application doesn't reset the flag itself, but lets the window manager do that once its criteria for user interaction are statisfied.

Cheers,
_
Qt/KDE Developer
Debian User

myak

Beginner

Posts: 6

Location: Warsaw, PL

  • Send private message

7

Saturday, June 25th 2005, 2:23pm

Actually, I tried diffrent approach (without hints) and it worked:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Display *xdisplay = qt_xdisplay();
    Window rootwin = qt_xrootwin(), winId = this->winId();

    static Atom demandsAttention = XInternAtom(xdisplay, "_NET_WM_STATE_DEMANDS_ATTENTION", true);
    static Atom wmState = XInternAtom(xdisplay, "_NET_WM_STATE", true);

    XEvent e;
    e.xclient.type = ClientMessage;
    e.xclient.message_type = wmState;
    e.xclient.display = xdisplay;
    e.xclient.window = winId;
    e.xclient.format = 32;
    e.xclient.data.l[1] = demandsAttention;
    e.xclient.data.l[2] = 0l;
    e.xclient.data.l[3] = 0l;
    e.xclient.data.l[4] = 0l;

    if (yes) {
        e.xclient.data.l[0] = 1;
   }
    else {
        e.xclient.data.l[0] = 0;
    }
    XSendEvent(xdisplay, rootwin, False, (SubstructureRedirectMask | SubstructureNotifyMask), &e);


Thanks for your help, I wouldn't find that without it :)
Marcin Jakubowski
jid: kadat@hqdev.net

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

8

Saturday, June 25th 2005, 2:48pm

As you need that on X11 and Windows, it would be nice if you could post both parts, maybe using #ifdef in one function, on qtforum in the tutorisl, tips&tricks section.

And/or on the Qt wiki.

I think a collection of "communicating with the windowing system across platforms" Qt-only code snippets would be cool

Cheers,
_
Qt/KDE Developer
Debian User

myak

Beginner

Posts: 6

Location: Warsaw, PL

  • Send private message

9

Saturday, June 25th 2005, 6:26pm

Quoted

Originally posted by anda_skoa
As you need that on X11 and Windows, it would be nice if you could post both parts, maybe using #ifdef in one function, on qtforum in the tutorisl, tips&tricks section.

Ok, here it is. Hope someone will find this useful :)

Quoted

Originally posted by anda_skoa
And/or on the Qt wiki.

Unfortunately, I have no experience with wikis at all so if you (or someone else of course) have some time then please feel free to convert my post in tips&tricts section of qtforum to wiki.
Marcin Jakubowski
jid: kadat@hqdev.net

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

10

Saturday, June 25th 2005, 7:21pm

Thanks a lot!

Cheers,
_
Qt/KDE Developer
Debian User