Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x11utills.cpp is being fixed (deprecation fix, other adjustments), RE… #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 35 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,32 @@

![Screenshots](https://github.com/zakariakov/qobbar/blob/master/example/qobbar1.png)

<img src="https://gitlab.com/zakariakov/qobbar/blob/master/example/qobbar3.jpg">

<img src="https://gitlab.com/zakariakov/qobbar/blob/master/example/qobbar4.png">

<img src="https://gitlab.com/zakariakov/qobbar/blob/master/example/qobbar1.png">

qobbar is a status bar based on Qt5, X11 and libGl. As a status indicating panel
with menu control, the package of this desktop environment application is to be seen
as not yet fully functional, as it is a work in progress. Certain features or
components of it work sufficiently but should still be improved, others remain
to be completed or augmented.

### Dependencies

- libX11
- libXcomposite
- libXdamage
- libQt5X11Extras
- libQt5Widgets
- libQt5Gui
- libQt5Concurrent
- libQt5DBus
- libQt5Core
- libQt5X11Extras (its version has to be in accordance with Qt v5.10.0 or newer)
- libQt5Widgets (its version has to be in accordance with Qt v5.10.0 or newer)
- libQt5Gui (its version has to be in accordance with Qt v5.10.0 or newer)
- libQt5Concurrent (its version has to be in accordance with Qt v5.10.0 or newer)
- libQt5DBus (its version has to be in accordance with Qt v5.10.0 or newer)
- libQt5Core (its version has to be in accordance with Qt v5.10.0 or newer)
- libGL
- libpthread
- libstdc++


### Building from source
Expand All @@ -41,7 +53,7 @@

The default UserScope paths "$HOME/.config/qobbar/qobbar.conf"

to create user configuration
to create a user configuration

~~~ sh
$ mkdir -p "$HOME/.config/qobbar"
Expand All @@ -50,7 +62,9 @@

or create any configuration file in "$HOME/.config/qobbar"

the suffix ".conf" is obligatoire ex;"myconf.conf"
from the name of the configuration file the suffix ".conf"

is obligatory; for example "myconf.conf" would be allright.

### Running the app

Expand All @@ -66,9 +80,9 @@
" -r --right right-to-left layout direction."
~~~

to run the default configuration just run "qobbar".
To run the default configuration, just run "qobbar"

or cp any configuration in the example folder to $HOME/.config/qobbar.
or cp any configuration in the example folder to $HOME/.config/qobbar

to run any configuration ex: top-bar.conf run "qobbar -c top-bar".

Expand Down Expand Up @@ -107,19 +121,15 @@ to run any configuration ex: top-bar.conf run "qobbar -c top-bar".
~~~ sh
- Top <bool> panel top or bottom default=true
- BorderColor <string> color Hex or xrdb.color<num>
- BarLeft <list> Ex:statu1,statu2
- BarCenter <list> Ex:Time,Date
- BarRight <list> Ex:Pager
- BarLeft <list> Ex:Systray,statu1,statu2
- BarCenter <list> Ex:Time,Date
- BarRight <list> Ex:Pager
- BarLeftSpacing <int> default=0
- BarRightSpacing <int> default=0
- BarCenterSpacing <int> default=0
- MarginLeft <int> default=0
- MarginTop <int> default=0
- MarginRight <int> default=0
- MarginBottom <int> default=0
- Systray <bool> default=false
- Systray <bool> default=false

-----padding has no effect in tilling i3wm -----
-----padding has no effect in tiling WM -----
- PaddingBottom <int> default=0
- PaddingLeft <int> default=0
- PaddingRight <int> default=0
Expand All @@ -132,7 +142,7 @@ to run any configuration ex: top-bar.conf run "qobbar -c top-bar".

~~~ sh
- ActiveBackground <string> default window highlight
- ActiveAlpha <int> 0-to-255 default=255
- ActiveAlpha <int> 0-to-255 default=255
- ActiveForeground <string> default window highlightText
- ActiveUnderline <string> color Hex or xrdb.color
- ActiveOverline <string> color Hex or xrdb.color
Expand All @@ -142,19 +152,18 @@ to run any configuration ex: top-bar.conf run "qobbar -c top-bar".

~~~ sh
- DesktopDesplay <string> "name" "index" "icon" default=index
icon-[0-9] ex: home,office,multimedia,
icon-[0-9] ex: home,office,multimedia,
NOTE: The desktop name needs to match the name configured by the WM
You can get a list of the defined desktops using:
You can get a list of the defined desktops using:
$ xprop -root _NET_DESKTOP_NAMES

- IconsList <list> list of icon 0 to 9
- ActiveIcon <string> if DesktopDesplay==icon default=NULL
~~~

#### Status

~~~ sh
- Command <string> Command to desplay
- Command <string> Command to display
- Interval <int> second default 1
- MaxSize <int> default 100
- Label <string>
Expand All @@ -164,6 +173,7 @@ to run any configuration ex: top-bar.conf run "qobbar -c top-bar".
- ClickRight <string> Command to exec
- MouseWheelUp <string> Command to exec
- MouseWheelDown <string> Command to exec
- ActiveIcon <string> if DesktopDesplay==icon default=NULL
~~~


Expand All @@ -184,8 +194,7 @@ to run any configuration ex: top-bar.conf run "qobbar -c top-bar".
ActiveForeground=#ffffff
ActiveOverline=#ffff00
DesktopDesplay="icon"
IconsList=,,,,,,
ActiveIcon=
IconsList=,,,
Foreground=#8A8383
Border=1
ActiveAlpha=0
Expand Down Expand Up @@ -225,5 +234,3 @@ to run any configuration ex: top-bar.conf run "qobbar -c top-bar".
NOTE : to use this qobmenu [**@zakariakov**](https://github.com/zakariakov/qobmenu)

or jgmenu (https://github.com/johanmalm/jgmenu)


68 changes: 41 additions & 27 deletions utils/x11utills.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#include "x11utills.h"

#include <QApplication>
#include <QX11Info>
#include <QImage>
#include <QHash>
#include <array>
#include <memory>
#include <vector>
#include <iostream>

#include <QString>
#include <QRect>
#include <QtGlobal>

// Keep all the X11 stuff with scary defines below normal headers.
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>

Expand Down Expand Up @@ -148,7 +151,7 @@ bool X11UTILLS::isWindowForTaskbar(Window window)
// Let's expect that _KDE_NET_WM_WINDOW_TYPE_OVERRIDE can be set for
// regular windows too. If it should be hidden we should expect
// one of atoms listed above.
// << atom("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
// << atom("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");

foreach (Atom i, ignoreList)
{
Expand Down Expand Up @@ -240,27 +243,38 @@ bool X11UTILLS::getClientIcon(Window _wid, QPixmap& _pixreturn)
XGetWindowProperty(QX11Info::display(), _wid, atom("_NET_WM_ICON"),
0, LONG_MAX, False, AnyPropertyType,
&type, &format, &nitems, &extra,
(uchar**)&data);
(unsigned char**) &data);
if (!data)
{

return false;
}

else
{
QImage img (data[0], data[1], QImage::Format_ARGB32);

//TODO FIX deprecated
//img.sizeInBytes()
//
// Fixed: Here is the old code, not using the new img.sizeInBytes() :
//
// for (int i=0; i<img.byteCount()/4; ++i)
// ((uint*)img.bits())[i] = data[i+2];

for (int i=0; i<img.sizeInBytes()/4; ++i)
// ((uint*)img.bits())[i] = data[i+2];
//
// The new code can only fulfil its job for Qt 5.10 and newer versions. What comes in here, is
// ssize_t that has to be regarded as a delivering-back data type representing a constant. But
// don't be mislead from the naming of ssize_t. It must not necessarily behave like a signed
// version of size_t. It may do so, but this is not a must. POSIX only garantees for
// a ssize_t range between [-1...(2^15)-1]. The range of ssize_t regarding values lower
// than -1 seems to be environment specific. Fortunately, the fact, that ssize_t is signed,
// doesn't pose a compiling problem here. The compiler informs us, if ssize_t is statically
// casted into an int, a long int has to be taken at least. And there's no problem with that.
{
for (long int i=0; i<(static_cast<long int>(ssize_t(img.sizeInBytes())))/4; ++i)
((uint*)img.bits())[i] = data[i+2];

_pixreturn = QPixmap::fromImage(img);
XFree(data);

_pixreturn = (QPixmap::fromImage(img));
XFree(data);
}
return true;
}
}


Expand Down Expand Up @@ -582,7 +596,7 @@ void X11UTILLS::setWindowLayer(unsigned long _wid, int layer)
2);

}
//alowed
//allowed


QHash<QString ,bool> X11UTILLS::states(unsigned long window)
Expand Down Expand Up @@ -612,7 +626,7 @@ QHash<QString ,bool>hash;


}
XFree(data);
XFree(data);
}

return hash;
Expand Down Expand Up @@ -648,12 +662,12 @@ QHash<QString ,bool> X11UTILLS::allowed(unsigned long window)

return hash;
}
/************************************************
The Window Manager MUST set this property on the root window to be the ID of a child
window created by himself, to indicate that a compliant window manager is active.

http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#id2550836
************************************************/
//************************************************
// The Window Manager MUST set this property on the root window to be the ID of a child
// window created by himself, to indicate that a compliant window manager is active.
//
// http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#id2550836
//************************************************

bool X11UTILLS::isWindowManagerActive()
{
Expand Down Expand Up @@ -687,7 +701,7 @@ QRect rect;
XSizeHints hints;
int rx, ry;

// QHash<QString ,int>hash;
// QHash<QString ,int>hash;
Window junkwin;
XWindowAttributes win_attributes;
if (!XGetWindowAttributes(QX11Info::display(), window, &win_attributes)){
Expand Down Expand Up @@ -723,7 +737,7 @@ QRect rect;
/* WM reparented, so find edges of the frame */
/* Only works for ICCCM-compliant WMs, and then only if the
window has corner gravity. We would need to know the original width
of the window to correctly handle the other gravities. */
of the window to correctly handle the other gravities. */

XWindowAttributes frame_attr;

Expand Down