This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to bring application window to the top (foremost) of all windows ?

Tags: None
(comma "," separated)
pmendl
Registered Member
Posts
7
Karma
0
I am C++ developer, currently writting application that periodically check some network-based info and, if it finds important change, pops up showing that new change.
The wanted behaviour is to "popup" window (frame in fact) as active and topmost. If it would be possible not to steal focus at once, but wait after user clicks inside some editbox even better, but simple full focus will be good enough).

I tried the same things both in wxWidgets and Qt4, both times getting the same result in the KDE 3.5.9 environment:
Basically I minimise application on startup. As user I see the task in the taskbar and continue normal working with many other applications including Konqueror, Eclipse etc. On event in my code I call normalise() method to bring window to original size. The result is, that the window "normalise", but shows without focus, partly (or even completely) overlapped by other applications window(s). The taskbar icon flashes (what is correct and wanted).

I tried to append raise() method call after the normalise() one, but nothing changed. I understand, that multiplatform library-based raise() method raises window only inside of one application, not over all the desktop environment.
However I suspect, that there is some "kde-wide-raise()" method available somewhere in Kwin libraries, which could be called by application to achieve wanted behaviour (see top of this message).

I spent two halfdays searching and googling around KDE and kwin, but giving up and asking for kind help.

If there is some better documentation on kwin 3.x (am I right, that kwin is the place to search for cross applications windows manipulation and that versioning corresponds to the KDE one?) other than the almost not commented automatic doxygen one, I would highly appreciate any link, as there are more window arrangements I would like to take care on in my application, e.g. automatically popup on all desktops, eventually even minimise to trayicon instead of tasklist etc.


pmendl, proud to be a member of KDE forums since 2008-Nov.
User avatar
msoeken
Mentor
Posts
300
Karma
4
OS
Have a look at http://doc.trolltech.com/4.4/qt.html#WindowType-enum. These values can be passed to the QWidget constructor and can change the behavior of your window.


Image
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size]
Seli
Registered Member
Posts
7
Karma
0
pmendl wrote:I am C++ developer

And have you noticed this is a user forum?

currently writting application that periodically check some network-based info and, if it finds important change, pops up showing that new change.
The wanted behaviour is to "popup" window (frame in fact) as active and topmost.


Do not do or want that. It was quite a lot of work to write code to prevent broken applications like this from breaking users' workflow. Use KNotification (KNotify in KDE3) from kdelibs.

If there is some better documentation on kwin 3.x (am I right, that kwin is the place to search for cross applications windows manipulation and that versioning corresponds to the KDE one?) other than the almost not commented automatic doxygen one, I would highly appreciate any link, as there are more window arrangements I would like to take care on in my application, e.g. automatically popup on all desktops, eventually even minimise to trayicon instead of tasklist etc.


I think you probably don't understand the purpose of a window manager or why it has 'manager' in its name. Applications are not supposed to do window manipulation, especially not cross applications. If the KNotif* answer above is not enough for you, find an appropriate developers mailing list at http://www.kde.org/mailinglists/ and ask there.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
This appears to be a developer question on how to work with KDE libraries, so moved appropriately. Also, KNotifcations do go to the top and float there, but do not steal focus. There is nothing worse when an application steals focus when you are typing ( like when the google home page loads just as you are in the middle of typing a url )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
pmendl
Registered Member
Posts
7
Karma
0
bcooksley wrote:This appears to be a developer question on how to work with KDE libraries, so moved appropriately.

Excuse me addressing the wrong forum. Even if long time C++ programmer, I am very new to KDE inside and still bit confused about proper resources.


pmendl, proud to be a member of KDE forums since 2008-Nov.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Don't worry about putting it in the wrong forum, a moderator will usually move it if they believe it is in the wrong place :-)


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
DanielW
KDE Developer
Posts
71
Karma
0
OS
If you really want it to integrate into KDE you should use KNotification for notifying the user about an event.

The user has to some extend control on how and if it will show on his desktop.

See for more info and usage details:

http://api.kde.org/4.1-api/kdelibs-apid ... ation.html

For KDE 3.5 the "same" class is part of libkopete see:

http://api.kde.org/3.5-api/kdenetwork-a ... ation.html

Last edited by DanielW on Fri Nov 21, 2008 7:46 am, edited 1 time in total.


DanielW, proud to be a member of KDE forums since 2008-Oct.
pmendl
Registered Member
Posts
7
Karma
0
DanielW wrote:If you really want it to integrate into KDE you should use KNotification for notifying the user about an event.

The user has to some extend control on how and if it will show on his desktop.

See for more info and usage details:

http://api.kde.org/4.1-api/kdelibs-apid ... ation.html

For KDE 3.5 the "same" class is part of libkopete see:

http://api.kde.org/3.5-api/kdenetwork-a ... ation.html


Many thanks for the links!

I wanted to test immediately, so added small class to activate KNotification. Header file:
Code: Select all
#ifndef DONOTIFY_H_
#define DONOTIFY_H_

#include

class DoNotify : public QObject {
   Q_OBJECT

public slots:
   void NotifyKDE(void);
};

#endif /* DONOTIFY_H_ */
and implementation:
Code: Select all
#include "DoNotify.h"

#include

void DoNotify::NotifyKDE(void) {
   KNotification * notification = KNotification::event   (
         "online", // eventId
         "Test notification" // text
   );
}

Not connected yet, however trying to syntax-check run application (able to run before this class addition) I am getting linker errors:
Code: Select all
DoNotify.o: In function `DoNotify::NotifyKDE()':
DoNotify.cpp:(.text+0x11): undefined reference to `KComponentData::KComponentData()'
DoNotify.cpp:(.text+0x65): undefined reference to `KNotification::event(QString const&, QString const&, QPixmap const&, QWidget*, QFlags const&, KComponentData const&)'
DoNotify.cpp:(.text+0x9d): undefined reference to `KComponentData::~KComponentData()'
DoNotify.cpp:(.text+0xfd): undefined reference to `KComponentData::~KComponentData()'
collect2: ld returned 1 exit status

I have installed kdelibs5 and kdelibs5-dev packages under Debian/lenny. What am I missing, please?


pmendl, proud to be a member of KDE forums since 2008-Nov.
User avatar
msoeken
Mentor
Posts
300
Karma
4
OS
How did you compile it. Can you post your g++ command or Makefile or CMakeLists.txt or .pro File whatever you are using.


Image
[size=x-small]code | [url=cia.vc/stats/author/msoeken]cia.vc[/url] | [url=kde.org/support]donating KDE[/url] | [url=tinyurl.com/cto4ns]wishlist[/url][/size]
pmendl
Registered Member
Posts
7
Karma
0
msoeken wrote:How did you compile it. Can you post your g++ command or Makefile or CMakeLists.txt or .pro File whatever you are using.


This is the complete .pro file of the whole project (taken from original source with only Notifier.h DoNotify.h and Notifier.cpp DoNotify.cpp added in respective sections.
Code: Select all
######################################################################
# Automatically generated by qmake (2.01a) Sun Nov 4 16:24:23 2007
######################################################################
#  This file is part of QuteScoop.
#  Copyright (C) 2007-2008 Martin Domig
#
#  QuteScoop is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  QuteScoop is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with QuteScoop.  If not, see
######################################################################
 
TEMPLATE = app
FORMS = MainWindow.ui PilotDetails.ui ClientSelectionDialog.ui ControllerDetails.ui AirportDetails.ui PreferencesDialog.ui
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT += network opengl
#CONFIG += debug
CONFIG += release

mac {
   ICON = Dolomynum.icns
   CONFIG += x86 ppc
}

win32 {
   RC_FILE = windowsicon.rc
   #CONFIG += console
}

# Input
HEADERS +=    Notifier.h DoNotify.h GLWidget.h Window.h LineReader.h Client.h
         FileReader.h FirReader.h Fir.h Tessellator.h
         Airport.h Whazzup.h WhazzupData.h PilotDetails.h
         ClientDetails.h Controller.h Pilot.h ClientSelectionWidget.h
         ControllerDetails.h MapObject.h AirportDetails.h
         AirportDetailsAtcModel.h AirportDetailsArrivalsModel.h
         NavData.h AirportDetailsDeparturesModel.h
         PreferencesDialog.h Settings.h SearchResultModel.h
         MapObjectVisitor.h SearchVisitor.h Waypoint.h MetarModel.h Metar.h
         MetarSearchVisitor.h FriendsVisitor.h

SOURCES +=  Notifier.cpp DoNotify.cpp GLWidget.cpp QuteScoop.cpp Window.cpp LineReader.cpp
         Client.cpp FileReader.cpp FirReader.cpp Fir.cpp
         Tessellator.cpp Airport.cpp Whazzup.cpp WhazzupData.cpp
         PilotDetails.cpp ClientDetails.cpp Controller.cpp Pilot.cpp
         ClientSelectionWidget.cpp ControllerDetails.cpp MapObject.cpp
         AirportDetails.cpp AirportDetailsAtcModel.cpp
         AirportDetailsArrivalsModel.cpp NavData.cpp
         AirportDetailsDeparturesModel.cpp
         PreferencesDialog.cpp Settings.cpp SearchResultModel.cpp
         SearchVisitor.cpp Waypoint.cpp MetarModel.cpp Metar.cpp
         MetarSearchVisitor.cpp FriendsVisitor.cpp
         

I am using Eclipse (4.3) to make/run application and Makefile header seems to be proper and current:
Code: Select all
#############################################################################
# Makefile for building: QuteScoop
# Generated by qmake (2.01a) (Qt 4.4.3) on: p� lis 21 11:22:00 2008
# Project:  QuteScoop.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile QuteScoop.pro
#############################################################################


pmendl, proud to be a member of KDE forums since 2008-Nov.
DanielW
KDE Developer
Posts
71
Karma
0
OS
Well, you have to link to libkdeui.


DanielW, proud to be a member of KDE forums since 2008-Oct.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You will be missing the instruction to add the appropriate target link libraries. I do not know how to add them manually into a QMake project (.pro). If this is going to be a KDE application, then I would recommend using CMake instead.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell