Skip to content

Commit

Permalink
"order" winoption to sort buttons / icons on taskbar, tray bar and sy…
Browse files Browse the repository at this point in the history
…stem tray for issues #242, #180, #198. Use _KDE_NET_SYSTEM_TRAY_WINDOWS for issue #242. Possible fixes for issue #209 which requires further testing.
  • Loading branch information
gijsbers committed Mar 11, 2018
1 parent 49b6201 commit 3ef2977
Show file tree
Hide file tree
Showing 15 changed files with 282 additions and 121 deletions.
4 changes: 4 additions & 0 deletions doc/icewm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,10 @@ _Ignore_::: Don't add an icon to the tray pane.
_Minimized_::: Add an icon the the tray. Remove the task pane button when minimized.
_Exclusive_::: Add an icon the the tray. Never create a task pane button.

+order: 0+:: The sorting order of task buttons and tray icons.
The default value is zero. Increasing positive values go farther right,
while decreasing negative values go farther left.
The order option applies to taskbar, tray and system tray.
+allWorkspaces: 0+:: If set to 1, window will be visible on all workspaces.
+appTakesFocus: 0+:: if set to 1, IceWM will assume the window supports the WM_TAKE_FOCUS protocol even if the window did not advertise that it does.
+dBorder: 1+:: If set to 0, window will not have a border.
Expand Down
19 changes: 6 additions & 13 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ libitk_la_SOURCES = \
yaction.h \
yinputline.h \
ylib.h \
ypoint.h \
yrect.h \
ykey.h \
yfull.h \
Expand Down Expand Up @@ -227,7 +226,6 @@ icewm_SOURCES = \
binascii.h \
yurl.cc \
yurl.h \
ypoint.h \
yrect.h \
wmsession.cc \
wmsession.h \
Expand Down Expand Up @@ -310,7 +308,6 @@ icesh_SOURCES = \
sysdep.h \
base.h \
WinMgr.h \
ylib.h \
icesh.cc
icesh_LDADD = libice.la $(CORE_LIBS) @LIBINTL@

Expand All @@ -321,28 +318,28 @@ icewm_session_SOURCES = \
intl.h \
sysdep.h \
yapp.h \
ytimer.h \
icesm.cc
icewm_session_LDADD = libice.la @LIBINTL@

icewmhint_SOURCES = \
intl.h \
debug.h \
sysdep.h \
base.h \
guievent.h \
icewmhint.cc
icewmhint_LDADD = libice.la $(CORE_LIBS) @LIBINTL@

icewmbg_SOURCES = \
intl.h \
debug.h \
sysdep.h \
base.h \
themable.h \
default.h \
WinMgr.h \
ykey.h \
yfull.h \
yxapp.h \
yprefs.h \
ypaths.h \
icewmbg.cc \
icewmbg_prefs.h
icewmbg_LDADD = libice.la $(IMAGE_LIBS) $(CORE_LIBS) @LIBINTL@
Expand All @@ -352,7 +349,6 @@ icesound_SOURCES = \
debug.h \
guievent.h \
intl.h \
sysdep.h \
upath.h \
ypointer.h \
ytimer.h \
Expand All @@ -377,7 +373,6 @@ icehelp_SOURCES = \
prefs.h \
yaction.h \
ylib.h \
ypoint.h \
yrect.h \
icehelp.cc
icehelp_LDADD = libitk.la libice.la $(IMAGE_LIBS) $(CORE_LIBS) @LIBINTL@
Expand Down Expand Up @@ -417,6 +412,8 @@ icewmtray_SOURCES = \
prefs.h \
yxtray.cc \
yxtray.h \
wmoption.cc \
wmoption.h \
ylib.h \
icetray.cc
icewmtray_LDADD = libitk.la libice.la $(IMAGE_LIBS) $(CORE_LIBS)
Expand All @@ -428,7 +425,6 @@ icesame_SOURCES = \
base.h \
MwmUtil.h \
yaction.h \
ypoint.h \
yrect.h \
ykey.h \
yfull.h \
Expand All @@ -442,7 +438,6 @@ icelist_SOURCES = \
base.h \
yaction.h \
yinputline.h \
ypoint.h \
yrect.h \
ykey.h \
yfull.h \
Expand All @@ -460,7 +455,6 @@ iceview_SOURCES = \
prefs.h \
yaction.h \
ylib.h \
ypoint.h \
yrect.h \
iceview.cc
iceview_LDADD = libitk.la libice.la $(IMAGE_LIBS) $(CORE_LIBS)
Expand All @@ -472,7 +466,6 @@ iceicon_SOURCES = \
base.h \
yaction.h \
ylib.h \
ypoint.h \
yrect.h \
iceicon.cc
iceicon_LDADD = libitk.la libice.la $(IMAGE_LIBS) $(CORE_LIBS)
Expand Down
8 changes: 7 additions & 1 deletion src/atasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ bool TaskBarApp::isFocusTraversable() {
return true;
}

int TaskBarApp::getOrder() const {
return fFrame->getTrayOrder();
}

void TaskBarApp::setShown(bool ashow) {
if (ashow != fShown) {
fShown = ashow;
Expand Down Expand Up @@ -333,7 +337,9 @@ TaskPane::~TaskPane() {
}

void TaskPane::insert(TaskBarApp *tapp) {
fApps.append(tapp);
IterType it = fApps.reverseIterator();
while (++it && it->getOrder() > tapp->getOrder());
(--it).insert(tapp);
}

void TaskPane::remove(TaskBarApp *tapp) {
Expand Down
4 changes: 3 additions & 1 deletion src/atasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
#define ATASKS_H_

#include "ywindow.h"
#include "wmclient.h"
#include "ytimer.h"

class TaskPane;
class TaskBarApp;
class IAppletContainer;
class ClientData;

class TaskBarApp: public YWindow, public YTimerListener {
public:
Expand All @@ -29,6 +30,7 @@ class TaskBarApp: public YWindow, public YTimerListener {
void setShown(bool show);
bool getShown() const { return fShown || fFlashing; }

int getOrder() const;
void setFlash(bool urgent);

private:
Expand Down
9 changes: 8 additions & 1 deletion src/atray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ bool TrayApp::isFocusTraversable() {
return true;
}

int TrayApp::getOrder() const {
return fFrame->getTrayOrder();
}

void TrayApp::setShown(bool ashow) {
if (ashow != fShown) {
fShown = ashow;
Expand Down Expand Up @@ -220,7 +224,10 @@ TrayApp *TrayPane::addApp(YFrameWindow *frame) {
TrayApp *tapp = new TrayApp(frame, this);

if (tapp != 0) {
fApps.append(tapp);
IterType it = fApps.reverseIterator();
while (++it && it->getOrder() > tapp->getOrder());
(--it).insert(tapp);

tapp->show();

if (!(frame->visibleOn(manager->activeWorkspace()) ||
Expand Down
1 change: 1 addition & 0 deletions src/atray.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class TrayApp: public YWindow, public YTimerListener {

void setShown(bool show);
bool getShown() const { return fShown; }
int getOrder() const;

private:
ClientData *fFrame;
Expand Down
4 changes: 2 additions & 2 deletions src/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ extern bool debug_z;

#define DBG if (debug)
#define MSG(x) DBG tlog x
#define TLOG(x) tlog x
#else
#define DBG if (0)
#define MSG(x)
#define TLOG(x)
#endif

#if defined(DEBUG) || defined(PRECON)
#define PRECONDITION(x) if (x); else precondition( #x , __FILE__, __LINE__)
#define NOTE(x) tlog("%s:%d:%s: %s", __FILE__, __LINE__, __func__, #x )
#define INFO(x,y) tlog("%s:%d:%s: " x, __FILE__, __LINE__, __func__, y )
#define XDBG if (true)
#define TLOG(x) tlog x
#else
#define PRECONDITION(x) // nothing
#define NOTE(x) // nothing
#define INFO(x,y) // nothing
#define XDBG if (false)
#define TLOG(x)
#endif
#define CARP(x) tlog("%s:%d:%s: %s", __FILE__, __LINE__, __func__, #x )

Expand Down
1 change: 1 addition & 0 deletions src/wmclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ClientData {
virtual void wmLower() = 0;
virtual void wmMinimize() = 0;
virtual int getWorkspace() const = 0;
virtual int getTrayOrder() const = 0;
virtual bool isSticky() const = 0;
virtual bool isAllWorkspaces() const = 0;
virtual void wmOccupyWorkspace(int workspace) = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/wmframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ YFrameWindow::YFrameWindow(
fWinTrayOption = WinTrayIgnore;
fWinState = 0;
fWinOptionMask = ~0;
fTrayOrder = 0;

fClientContainer = new YClientContainer(this, this);
fClientContainer->show();
Expand Down Expand Up @@ -2072,6 +2073,7 @@ void YFrameWindow::getDefaultOptions(bool &requestFocus) {
setRequestedLayer(wo.layer);
if (wo.tray != (long)WinTrayInvalid && wo.tray < WinTrayOptionCount)
setTrayOption(wo.tray);
fTrayOrder = wo.order;
}

ref<YIcon> newClientIcon(int count, int reclen, long * elem) {
Expand Down
4 changes: 3 additions & 1 deletion src/wmframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ class YFrameWindow:
bool isTypeDock(void) { return (fWindowType == wtDock); }

int getWorkspace() const { return fWinWorkspace; }
int getTrayOrder() const { return fTrayOrder; }
void setWorkspace(int workspace);
void setWorkspaceHint(long workspace);
long getActiveLayer() const { return fWinActiveLayer; }
Expand Down Expand Up @@ -435,6 +436,7 @@ class YFrameWindow:
fsWorkspaceHidden = 1 << 4
} FrameStateFlags;*/

bool fManaged;
bool fFocused;
unsigned fFrameFunctions;
unsigned fFrameDecors;
Expand Down Expand Up @@ -482,9 +484,9 @@ class YFrameWindow:
long fWinActiveLayer;
long fWinTrayOption;
long fWinState;
bool fManaged;
long fWinOptionMask;
long fOldLayer;
int fTrayOrder;

int fFullscreenMonitorsTop;
int fFullscreenMonitorsBottom;
Expand Down
5 changes: 5 additions & 0 deletions src/wmoption.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ WindowOption::WindowOption(ustring n_class_instance):
workspace(WinWorkspaceInvalid),
layer(WinLayerInvalid),
tray(WinTrayInvalid),
order(0),
gflags(0), gx(0), gy(0), gw(0), gh(0)
{
}
Expand Down Expand Up @@ -80,6 +81,8 @@ void WindowOptions::setWinOption(ustring n_class_instance,
op->workspace = inrange(workspace, 0, MAXWORKSPACES - 1)
? workspace
: WinWorkspaceInvalid;
} else if (strcmp(opt, "order") == 0) {
op->order = atoi(arg);
} else if (strcmp(opt, "geometry") == 0) {
int rx, ry;
unsigned int rw, rh;
Expand Down Expand Up @@ -273,6 +276,8 @@ void WindowOptions::combineOptions(WindowOption &cm, WindowOption &n) {
cm.layer = n.layer;
if (n.tray != (long)WinTrayInvalid)
cm.tray = n.tray;
if (n.order)
cm.order = n.order;
if ((n.gflags & XValue) && !(cm.gflags & XValue)) {
cm.gx = n.gx;
cm.gflags |= XValue;
Expand Down
1 change: 1 addition & 0 deletions src/wmoption.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct WindowOption {
int workspace;
int layer;
int tray;
int order;
int gflags;
int gx, gy;
unsigned gw, gh;
Expand Down
2 changes: 1 addition & 1 deletion src/wmtaskbar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ void TaskBar::setWorkspaceActive(long workspace, int active) {

bool TaskBar::windowTrayRequestDock(Window w) {
if (fDesktopTray) {
fDesktopTray->trayRequestDock(w);
fDesktopTray->trayRequestDock(w, "SystemTray");
return true;
}
return false;
Expand Down
Loading

0 comments on commit 3ef2977

Please sign in to comment.