netwm.h

00001 /*
00002 
00003   Copyright (c) 2000 Troll Tech AS
00004   Copyright (c) 2003 Lubos Lunak <l.lunak@kde.org>
00005 
00006   Permission is hereby granted, free of charge, to any person obtaining a
00007   copy of this software and associated documentation files (the "Software"),
00008   to deal in the Software without restriction, including without limitation
00009   the rights to use, copy, modify, merge, publish, distribute, sublicense,
00010   and/or sell copies of the Software, and to permit persons to whom the
00011   Software is furnished to do so, subject to the following conditions:
00012 
00013   The above copyright notice and this permission notice shall be included in
00014   all copies or substantial portions of the Software.
00015 
00016   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00019   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00020   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00021   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00022   DEALINGS IN THE SOFTWARE.
00023 
00024 */
00025 
00026 
00027 #ifndef   __net_wm_h
00028 #define   __net_wm_h
00029 
00030 #include "kdelibs_export.h"
00031 #include <qwidget.h>
00032 #ifdef Q_WS_X11
00033 #include <X11/Xlib.h>
00034 #include <X11/Xutil.h>
00035 #include <X11/Xatom.h>
00036 
00037 #include "netwm_def.h"
00038 
00039 // forward declaration
00040 struct NETRootInfoPrivate;
00041 struct NETWinInfoPrivate;
00042 template <class Z> class NETRArray;
00043 
00044 
00058 class KDECORE_EXPORT NETRootInfo : public NET {
00059 public:
00064     // update also NETRootInfoPrivate::properties[] size when extending this
00065     enum { PROTOCOLS, WINDOW_TYPES, STATES, PROTOCOLS2, ACTIONS,
00066         PROPERTIES_SIZE };
00067 
00101     NETRootInfo(Display *display, Window supportWindow, const char *wmName,
00102         const unsigned long properties[], int properties_size,
00103                 int screen = -1, bool doActivate = true);
00104 
00111     NETRootInfo(Display *display, Window supportWindow, const char *wmName,
00112         unsigned long properties, int screen = -1, bool doActivate = true) KDE_DEPRECATED;
00113 
00136     NETRootInfo(Display *display, const unsigned long properties[], int properties_size,
00137                 int screen = -1, bool doActivate = true);
00138 
00145     NETRootInfo(Display *display, unsigned long properties, int screen = -1,
00146         bool doActivate = true);
00147 
00153     NETRootInfo(const NETRootInfo &rootinfo);
00154 
00158     virtual ~NETRootInfo();
00159 
00165     Display *x11Display() const;
00166 
00172     Window rootWindow() const;
00173 
00179     Window supportWindow() const;
00180 
00186     const char *wmName() const;
00187 
00193     int screenNumber() const;
00194 
00201     bool isSupported( NET::Property property ) const;
00206     bool isSupported( NET::Property2 property ) const;
00211     bool isSupported( NET::WindowType type ) const;
00216     bool isSupported( NET::State state ) const;
00217 
00222     bool isSupported( NET::Action action ) const;
00223 
00235     const unsigned long* supportedProperties() const;
00236 
00243     // KDE4 better name?
00244     const unsigned long* passedProperties() const;
00245 
00261     unsigned long supported() const KDE_DEPRECATED;
00262 
00270     const Window *clientList() const;
00271 
00279     int clientListCount() const;
00280 
00289     const Window *clientListStacking() const;
00290 
00298     int clientListStackingCount() const;
00299 
00307     const Window *kdeSystemTrayWindows() const;
00308 
00316     int kdeSystemTrayWindowsCount() const;
00317 
00328     NETSize desktopGeometry(int desktop) const;
00329 
00337     NETPoint desktopViewport(int desktop) const;
00338 
00346     NETRect workArea(int desktop) const;
00347 
00355     const char *desktopName(int desktop) const;
00356 
00364     const Window *virtualRoots( ) const;
00365 
00373     int virtualRootsCount() const;
00374 
00380     int numberOfDesktops() const;
00381 
00387     int currentDesktop() const;
00388 
00394     Window activeWindow() const;
00395 
00404     void activate();
00405 
00413     // KDE4 'const Window*', also in the others below
00414     void setClientList(Window *windows, unsigned int count);
00415 
00424     void setClientListStacking(Window *windows, unsigned int count);
00425 
00433     void setKDESystemTrayWindows(Window *windows, unsigned int count);
00434 
00440     void setCurrentDesktop(int desktop);
00441 
00452     void setDesktopGeometry(int desktop, const NETSize &geometry);
00453 
00461     void setDesktopViewport(int desktop, const NETPoint &viewport);
00462 
00468     void setNumberOfDesktops(int numberOfDesktops);
00469 
00477     void setDesktopName(int desktop, const char *desktopName);
00478 
00491     void setActiveWindow(Window window, NET::RequestSource src,
00492         Time timestamp, Window active_window);
00493 
00500     void setActiveWindow(Window window);
00501 
00509     void setWorkArea(int desktop, const NETRect &workArea);
00510 
00518     void setVirtualRoots(Window *windows, unsigned int count);
00519     
00524     void setShowingDesktop( bool showing );
00529     bool showingDesktop() const;
00530 
00535     const NETRootInfo &operator=(const NETRootInfo &rootinfo);
00536 
00544     void closeWindowRequest(Window window);
00545 
00561     void moveResizeRequest(Window window, int x_root, int y_root,
00562                Direction direction);
00563 
00579     void moveResizeWindowRequest(Window window, int flags, int x, int y, int width, int height );
00580 
00585     void restackRequest(Window window, RequestSource source, Window above, int detail, Time timestamp);
00590     void restackRequest(Window window, Window above, int detail);
00591     
00607     void event( XEvent* event, unsigned long* properties, int properties_size );
00608     
00620     unsigned long event(XEvent *event);
00621 
00622 
00623 protected:
00630     virtual void addClient(Window window) { Q_UNUSED(window); }
00631 
00638     virtual void removeClient(Window window) { Q_UNUSED(window); }
00639 
00647     virtual void addSystemTrayWin(Window window) { Q_UNUSED(window); }
00648 
00656     virtual void removeSystemTrayWin(Window window) { Q_UNUSED(window); }
00657 
00665     virtual void changeNumberOfDesktops(int numberOfDesktops) { Q_UNUSED(numberOfDesktops); }
00666 
00676     virtual void changeDesktopGeometry(int desktop, const NETSize &geom) { Q_UNUSED(desktop); Q_UNUSED(geom); }
00677 
00687     virtual void changeDesktopViewport(int desktop, const NETPoint &viewport) { Q_UNUSED(desktop); Q_UNUSED(viewport); }
00688 
00696     virtual void changeCurrentDesktop(int desktop) { Q_UNUSED(desktop); }
00697 
00707     virtual KDE_DEPRECATED void changeActiveWindow(Window window) { Q_UNUSED(window); }
00708 
00715     virtual void closeWindow(Window window) { Q_UNUSED(window); }
00716 
00730     virtual void moveResize(Window window, int x_root, int y_root,
00731                     unsigned long direction) { Q_UNUSED(window); Q_UNUSED(x_root); Q_UNUSED(y_root); Q_UNUSED(direction); }
00732 
00733 
00734 private:
00735     void update( const unsigned long[] );
00736     void setSupported();
00737     void setDefaultProperties();
00738     void updateSupportedProperties( Atom atom );
00739     Role role;
00740 
00741 protected:
00742     virtual void virtual_hook( int id, void* data );
00743 private:
00744     NETRootInfoPrivate *p;
00745     friend class NETRootInfo2;
00746     friend class NETRootInfo3;
00747 };
00748 
00755 class KDECORE_EXPORT NETRootInfo2
00756     : public NETRootInfo
00757 {
00758 public:
00759     NETRootInfo2(Display *display, Window supportWindow, const char *wmName,
00760         unsigned long properties[], int properties_size,
00761                 int screen = -1, bool doActivate = true);
00765     NETRootInfo2(Display *display, const unsigned long properties[], int properties_size,
00766                 int screen = -1, bool doActivate = true);
00771     void sendPing( Window window, Time timestamp );
00772 protected:
00773     friend class NETRootInfo;
00780     virtual void gotPing( Window window, Time timestamp ) { Q_UNUSED(window); Q_UNUSED(timestamp); }
00791     virtual void changeActiveWindow(Window window,NET::RequestSource src,
00792         Time timestamp, Window active_window ) { Q_UNUSED(window); Q_UNUSED(src); Q_UNUSED(timestamp); Q_UNUSED(active_window);}
00802     virtual void restackWindow(Window window, Window above, int detail) { Q_UNUSED(window); Q_UNUSED(above); Q_UNUSED(detail); }
00803 
00816     virtual void moveResizeWindow(Window window, int flags, int x, int y, int width, int height) { Q_UNUSED(window); Q_UNUSED(flags); Q_UNUSED(x); Q_UNUSED(y); Q_UNUSED(width); Q_UNUSED(height); }
00817 
00818 // no private data, use NETRootInfoPrivate
00819 };
00820 
00827 class KDECORE_EXPORT NETRootInfo3
00828     : public NETRootInfo2
00829 {
00830 public:
00831     NETRootInfo3(Display *display, Window supportWindow, const char *wmName,
00832         unsigned long properties[], int properties_size,
00833                 int screen = -1, bool doActivate = true);
00837     NETRootInfo3(Display *display, const unsigned long properties[], int properties_size,
00838                 int screen = -1, bool doActivate = true);
00846     void takeActivity( Window window, Time timestamp, long flags );
00847 protected:
00848     friend class NETRootInfo;
00860     virtual void restackWindow(Window window, RequestSource source,
00861            Window above, int detail, Time timestamp) { Q_UNUSED(window); Q_UNUSED(source); Q_UNUSED(above); Q_UNUSED(detail); Q_UNUSED(timestamp); }
00869     virtual void gotTakeActivity(Window window, Time timestamp, long flags ) { Q_UNUSED(window); Q_UNUSED(timestamp); Q_UNUSED(flags); }
00870 // no private data, use NETRootInfoPrivate
00871 };
00872 
00879 class KDECORE_EXPORT NETRootInfo4
00880     : public NETRootInfo3
00881 {
00882 public:
00883     NETRootInfo4(Display *display, Window supportWindow, const char *wmName,
00884         unsigned long properties[], int properties_size,
00885                 int screen = -1, bool doActivate = true);
00886     NETRootInfo4(Display *display, const unsigned long properties[], int properties_size,
00887                 int screen = -1, bool doActivate = true);
00888 
00889 protected:
00890     friend class NETRootInfo;
00898     virtual void changeShowingDesktop(bool showing) { Q_UNUSED(showing); }
00899 // no private data, use NETRootInfoPrivate
00900 };
00901 
00916 class KDECORE_EXPORT NETWinInfo : public NET {
00917 public:
00922     // update also NETWinInfoPrivate::properties[] size when extending this
00923     enum { PROTOCOLS, PROTOCOLS2,
00924         PROPERTIES_SIZE };
00949     NETWinInfo(Display *display, Window window, Window rootWindow,
00950                const unsigned long properties[], int properties_size,
00951            Role role = Client);
00952 
00959     NETWinInfo(Display *display, Window window,
00960            Window rootWindow, unsigned long properties,
00961            Role role = Client);
00962 
00968     NETWinInfo(const NETWinInfo & wininfo);
00969 
00973     virtual ~NETWinInfo();
00974 
00979     const NETWinInfo &operator=(const NETWinInfo &wintinfo);
00980 
00989     bool hasNETSupport() const;
00990 
00997     // KDE4 better name?
00998     const unsigned long* passedProperties() const;
00999 
01009     unsigned long properties() const KDE_DEPRECATED;
01010 
01016     NETRect iconGeometry() const;
01017 
01024     unsigned long state() const;
01025 
01030     NETExtendedStrut extendedStrut() const;
01031 
01038     NETStrut strut() const;
01039 
01054     WindowType windowType( unsigned long supported_types ) const;
01055 
01063     WindowType windowType() const KDE_DEPRECATED;
01064 
01070     const char *name() const;
01071 
01077     const char *visibleName() const;
01078 
01088     const char *iconName() const;
01089 
01099     const char *visibleIconName() const;
01100 
01108     int desktop() const;
01109 
01115     int pid() const;
01116 
01122     Bool handledIcons() const;
01123 
01130     Window kdeSystemTrayWinFor() const;
01131 
01138     MappingState mappingState() const;
01139 
01149     void setIcon(NETIcon icon, Bool replace = True);
01150 
01156     void setIconGeometry(NETRect geometry);
01157 
01163     void setExtendedStrut(const NETExtendedStrut& extended_strut );
01164 
01171     void setStrut(NETStrut strut);
01172 
01183     void setState(unsigned long state, unsigned long mask);
01184 
01191     void setWindowType(WindowType type);
01192 
01198     void setName(const char *name);
01199 
01206     void setVisibleName(const char *visibleName);
01207 
01213     void setIconName(const char *name);
01214 
01221     void setVisibleIconName(const char *name);
01222 
01230     void setDesktop(int desktop);
01231 
01237     void setPid(int pid);
01238 
01244     void setHandledIcons(Bool handled);
01245 
01251     void setKDESystemTrayWinFor(Window window);
01252 
01259     void setFrameExtents(NETStrut strut);
01260 
01267     void setKDEFrameStrut(NETStrut strut);
01268 
01280     NETIcon icon(int width = -1, int height = -1) const;
01281 
01282     /*    
01283      * Sets user timestamp @p time on the window (property _NET_WM_USER_TIME).
01284      * The timestamp is expressed as XServer time. If a window
01285      * is shown with user timestamp older than the time of the last
01286      * user action, it won't be activated after being shown, with the special
01287      * value 0 meaning not to activate the window after being shown.
01288      * @since 3.2
01289      */
01290     void setUserTime( Time time );
01291     
01296     Time userTime() const;
01297 
01298     /*    
01299      * Sets the startup notification id @p id on the window.
01300      * @since 3.2
01301      */
01302     void setStartupId( const char* startup_id );
01303     
01308     const char* startupId() const;
01309 
01314     void setAllowedActions( unsigned long actions );
01315 
01320     unsigned long allowedActions() const;
01321 
01322     /*
01323      * Returns the WM_TRANSIENT_FOR property for the window, i.e. the mainwindow
01324      * for this window.
01325      * @since 3.2
01326      */
01327     Window transientFor() const;
01328 
01333     Window groupLeader() const;
01334     
01340     const char* windowClassClass() const;
01341 
01347     const char* windowClassName() const;
01348 
01353     const char* windowRole() const;
01354 
01359     const char* clientMachine() const;
01360 
01369     void kdeGeometry(NETRect &frame, NETRect &window);
01370 
01386     void event( XEvent* event, unsigned long* properties, int properties_size );
01387 
01399     unsigned long event(XEvent *event);
01400 
01407     static const int OnAllDesktops;
01408 
01409 
01410 protected:
01418     virtual void changeDesktop(int desktop) { Q_UNUSED(desktop); }
01419 
01429     virtual void changeState(unsigned long state, unsigned long mask) { Q_UNUSED(state); Q_UNUSED(mask); }
01430 
01431 private:
01432     void update( const unsigned long[] );
01433     void updateWMState();
01434     void setIconInternal(NETRArray<NETIcon>& icons, int& icon_count, Atom property, NETIcon icon, Bool replace);
01435     NETIcon iconInternal(NETRArray<NETIcon>& icons, int icon_count, int width, int height) const;
01436     Role role;
01437 
01438 protected:
01439     virtual void virtual_hook( int id, void* data );
01440 private:
01441     NETWinInfoPrivate *p;
01442 };
01443 
01444 
01445 //#define KWIN_FOCUS
01446 
01447 #endif
01448 #endif // __net_wm_h
KDE Home | KDE Accessibility Home | Description of Access Keys