dock updates see changelog

This commit is contained in:
K D Hedger
2023-11-20 13:34:51 +00:00
parent 05dd2bb703
commit 8799776d3b
17 changed files with 318 additions and 294 deletions

View File

@ -1,10 +1,12 @@
0.1.0
Removed legacy code.
Code clean.
Fixed volume slider icons.
Fixed clock.
Prefs file is ~/.config/LFS/lfsdock.rc
Tweaked prefs name.
Removed unused defines.
Fixed stting absolute position.
Fixed setting absolute position.
Fixed clock.
Set font details.
Dock can only be north or south gravity.

View File

@ -7,8 +7,8 @@ lfsdock_SOURCES = $(COMMONSRC)
man1_MANS = ../resources/man/lfsdock.1
#pixfilesdir = $(pkgdatadir)/pixmaps
#pixfiles_DATA = ../resources/pixmaps/*
pixfilesdir = $(pkgdatadir)/pixmaps
pixfiles_DATA = ../resources/pixmaps/*
bin_PROGRAMS = lfsdock

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1 +1 @@
COMMONSRC = ../src/callbacks.cpp ../src/clock.cpp ../src/globals.cpp ../src/launchers.cpp ../src/main.cpp ../src/slider.cpp
COMMONSRC = ../src/callbacks.cpp ../src/clock.cpp ../src/desktopSwitcher.cpp ../src/globals.cpp ../src/launchers.cpp ../src/main.cpp ../src/slider.cpp

View File

@ -1,21 +1,21 @@
/*
*
* ©K. D. Hedger. Sat 6 Feb 13:59:35 GMT 2021 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:09:02 GMT 2023 keithdhedger@gmail.com
* This file (callbacks.cpp) is part of LFSPanel.
* This file (callbacks.cpp) is part of LFSDock.
* LFSPanel is free software: you can redistribute it and/or modify
* LFSDock 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.
* (at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* LFSDock 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 LFSPanel. If not, see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#include "globals.h"
@ -77,17 +77,6 @@ bool gadgetDrop(void *lwc,propertyStruct *data,void* ud)
bool timerCB(LFSTK_applicationClass *p,void* ud)
{
Window sink;
Window childwindow;
int sinkx;
int sinky;
unsigned int buttonmask;
XQueryPointer(apc->display,apc->rootWindow,&sink,&childwindow,&sinkx,&sinky,&sinkx,&sinky,&buttonmask);
if(buttonmask!=0)
return(true);
readMsg();
if(clockButton!=NULL)
@ -131,7 +120,7 @@ bool exitCB(LFSTK_gadgetClass*p,void* ud)
return(true);
}
bool moveCB(LFSTK_gadgetClass*p,void* ud)
bool enterCB(LFSTK_gadgetClass*p,void* ud)
{
if(ud!=NULL)
{

View File

@ -1,21 +1,21 @@
/*
*
* ©K. D. Hedger. Sat 6 Feb 13:59:29 GMT 2021 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:09:12 GMT 2023 keithdhedger@gmail.com
* This file (callbacks.h) is part of LFSPanel.
* This file (callbacks.h) is part of LFSDock.
* LFSPanel is free software: you can redistribute it and/or modify
* LFSDock 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.
* (at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* LFSDock 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 LFSPanel. If not, see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CALLBACKS_
@ -26,5 +26,5 @@ bool gadgetDrop(void *lwc,propertyStruct *data,void* ud);
bool timerCB(LFSTK_applicationClass *p,void* ud);
void readMsg(void);
bool exitCB(LFSTK_gadgetClass*p,void* ud);
bool moveCB(LFSTK_gadgetClass*p,void* ud);
bool enterCB(LFSTK_gadgetClass*p,void* ud);
#endif

View File

@ -1,30 +1,25 @@
/*
*
* ©K. D. Hedger. Mon 21 Sep 13:41:36 BST 2015 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:09:27 GMT 2023 keithdhedger@gmail.com
* This file (clock.cpp) is part of LFSPanel.
* This file (clock.cpp) is part of LFSDock.
* LFSPanel is free software: you can redistribute it and/or modify
* LFSDock 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.
* (at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* LFSDock 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 LFSPanel. If not, see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <signal.h>
#include <ctime>
#include "globals.h"
//LFSTK_labelClass *clockButton=NULL;
LFSTK_buttonClass *clockButton=NULL;
void updateClock(void)
@ -44,25 +39,15 @@ void updateClock(void)
int addClock(int x,int y,int grav)
{
int xpos=0;
int width=iconSize;
int retval=width;
if(clockButton!=NULL)
{
printError("Duplicate clock");
return(0);
}
if(grav==NorthWestGravity)
xpos=x;
else
xpos=x-width;
clockButton=new LFSTK_buttonClass(mainwind,"--:--:--",xpos,((iconSize+extraSpace)/2)-(GADGETHITE/2),iconSize,GADGETHITE,NorthWestGravity);
clockButton->LFSTK_setFontString(prefs.LFSTK_getCString(prefs.LFSTK_hashFromKey("font")),true);
clockButton=new LFSTK_buttonClass(mainwind,"--:--:--",x,y+(iconSize/2)-(GADGETHITE/2),iconSize,GADGETHITE);
setGadgetDetails(clockButton);
clockButton->LFSTK_setFontString(prefs.LFSTK_getCString(prefs.LFSTK_hashFromKey("font")),true);
clockButton->LFSTK_setAlpha(1.0);
clockButton->LFSTK_setIgnores(false,false);
@ -75,5 +60,5 @@ int addClock(int x,int y,int grav)
clockButton->drawLabelBG=true;
clockButton->autoLabelBGColour=true;
return(retval);
return(iconSize);
}

View File

@ -1,24 +1,23 @@
/*
*
* ©K. D. Hedger. Mon 21 Sep 13:41:31 BST 2015 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:09:41 GMT 2023 keithdhedger@gmail.com
* This file (clock.h) is part of LFSPanel.
* This file (clock.h) is part of LFSDock.
* LFSPanel is free software: you can redistribute it and/or modify
* LFSDock 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.
* (at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* LFSDock 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 LFSPanel. If not, see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CLOCK_
#define _CLOCK_

View File

@ -0,0 +1,95 @@
/*
*
* ©K. D. Hedger. Sun 19 Nov 19:10:19 GMT 2023 keithdhedger@gmail.com
* This file (desktopSwitcher.cpp) is part of LFSDock.
* LFSDock 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.
* LFSDock 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 LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#include "globals.h"
LFSTK_toggleButtonClass *switchButton;
bool switchIsUp=false;
bool deskSwitcherExitCB(LFSTK_gadgetClass*p,void* ud)
{
geometryStruct geom2;
int adj;
if(switchButton->LFSTK_getValue()==1)
return(true);
adj=extraSpace*posMultiplier;
p->LFSTK_getGeom(&geom2);
p->LFSTK_moveGadget(geom2.x,geom2.y+adj);
switchIsUp=false;
return(true);
}
bool deskSwitcherEnterCB(LFSTK_gadgetClass*p,void* ud)
{
geometryStruct geom;
int adj;
if(switchIsUp==true)
return(true);
adj=extraSpace*posMultiplier;
p->LFSTK_getGeom(&geom);
p->LFSTK_moveGadget(geom.x,geom.y-adj);
switchIsUp=true;
return(true);
}
bool deskListCB(void* p,void* ud)
{
return(true);
}
int addDesktopSwitcer(int x,int y,int grav)
{
char *icon=NULL;
if(switchButton!=NULL)
{
printError("Duplicate switcher");
return(0);
}
switchButton=new LFSTK_toggleButtonClass(mainwind,"",x,y,iconSize,iconSize);
switchButton->LFSTK_setToggleStyle(TOGGLENORMAL);
switchButton->LFSTK_setMouseCallBack(NULL,deskListCB,NULL);
switchButton->LFSTK_setMouseMoveCallBack(deskSwitcherEnterCB,deskSwitcherExitCB,NULL);
setGadgetDetails(switchButton);
switchButton->LFSTK_setAlpha(1.0);
switchButton->LFSTK_setStyle(BEVELNONE);
switchButton->LFSTK_setColourName(NORMALCOLOUR,panelBGColour);
switchButton->LFSTK_setColourName(PRELIGHTCOLOUR,panelBGColour);
switchButton->LFSTK_setColourName(ACTIVECOLOUR,panelBGColour);
switchButton->LFSTK_setFontColourName(NORMALCOLOUR,panelTextColour,true);
switchButton->LFSTK_setFontColourName(PRELIGHTCOLOUR,panelTextColour,true);
switchButton->LFSTK_setFontColourName(ACTIVECOLOUR,panelTextColour,true);
icon=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"remote-desktop","");
if(icon!=NULL)
{
switchButton->LFSTK_setImageFromPath(icon,LEFT,true);
free(icon);
}
else
switchButton->LFSTK_setImageFromPath(DATADIR "/pixmaps/windows.png",LEFT,true);
return(iconSize);
}

View File

@ -0,0 +1,30 @@
/*
*
* ©K. D. Hedger. Sun 19 Nov 19:12:44 GMT 2023 keithdhedger@gmail.com
* This file (desktopSwitcher.h) is part of LFSDock.
* LFSDock 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.
* LFSDock 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 LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DESKTOPSWITCHER_
#define _DESKTOPSWITCHER_
#include "globals.h"
extern LFSTK_toggleButtonClass *switchButton;
int addDesktopSwitcer(int x,int y,int grav);
#endif

View File

@ -1,59 +1,57 @@
/*
*
* ©K. D. Hedger. Sun 20 Sep 14:41:10 BST 2015 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:08:31 GMT 2023 keithdhedger@gmail.com
* This file (globals.cpp) is part of LFSPanel.
* This file (globals.cpp) is part of LFSDock.
* LFSPanel is free software: you can redistribute it and/or modify
* LFSDock 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.
* (at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* LFSDock 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 LFSPanel. If not, see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#include "globals.h"
//prefs
LFSTK_prefsClass prefs;
std::string configDir;
std::string launchersDir;
std::string configFile;
LFSTK_windowClass *popWindow=NULL;
LFSTK_labelClass *popLabel=NULL;
launcherList *ll=NULL;
int iconSize=16;
int posMultiplier=1;
std::string configDir;
std::string launchersDir;
std::string configFile;
LFSTK_windowClass *popWindow=NULL;
LFSTK_labelClass *popLabel=NULL;
launcherList *ll=NULL;
int iconSize=16;
int posMultiplier=1;
int panelSize=2;
int panelWidth=-1;
const monitorStruct *mons=NULL;
int onMonitor=0;
int panelPos=PANELCENTRE;
int panelGravity=PANELNORTH;
const char *panelTextColour="";
const char *panelBGColour="";
int extraSpace=16;
int panelSize=2;
int panelWidth=-1;
const monitorStruct *mons=NULL;
int onMonitor=0;
int panelPos=PANELCENTRE;
int panelGravity=PANELNORTH;
const char *panelTextColour="";
const char *panelBGColour="";
int extraSpace=16;
int queueID;
msgBuffer buffer;
int queueID;
msgBuffer buffer;
const char *desktopTheme=NULL;
bool realMainLoop=true;
int refreshRate=1;
const char *desktopTheme=NULL;
bool realMainLoop=true;
int refreshRate=1;
//panel window
LFSTK_applicationClass *apc=NULL;
LFSTK_windowClass *mainwind=NULL;
int leftOffset=0;
int launcherSide=NOLAUNCHERS;
//atoms
@ -69,31 +67,6 @@ Atom UTF8_STRING=None;
const char *possibleError="Unknown";
void setSizes(int *x,int *y,int *w,int *h,int *size,int *grav,bool fromleft)
{
*w=iconSize;
*h=iconSize;
*size=(*w)-12;
switch(*grav)
{
case PANELNORTH:
case PANELSOUTH:
if(fromleft==true)
{
*grav=NorthWestGravity;
*x=*x;
}
else
{
*grav=NorthEastGravity;
*x=*x-*w+1;
}
*y=0;
break;
}
}
void sendNotify(const char *name,const char *message)//TODO//could be better
{
#ifdef _GOTNOTIFYSEND_

View File

@ -1,21 +1,21 @@
/*
*
* ©K. D. Hedger. Sun 20 Sep 14:41:04 BST 2015 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:08:47 GMT 2023 keithdhedger@gmail.com
* This file (globals.h) is part of LFSPanel.
* This file (globals.h) is part of LFSDock.
* LFSPanel is free software: you can redistribute it and/or modify
* LFSDock 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.
* (at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* LFSDock 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 LFSPanel. If not, see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
@ -32,6 +32,7 @@
#include "callbacks.h"
#include "clock.h"
#include "slider.h"
#include "desktopSwitcher.h"
#ifndef _GLOBALS_
#define _GLOBALS_
@ -59,56 +60,54 @@ struct launcherList
enum {NOLAUNCHERS,LAUNCHERINLEFT};
//prefs
extern LFSTK_prefsClass prefs;
extern std::string configDir;
extern std::string launchersDir;
extern std::string configFile;
extern LFSTK_windowClass *popWindow;
extern LFSTK_labelClass *popLabel;
extern launcherList *ll;
extern int iconSize;
extern int posMultiplier;
extern LFSTK_prefsClass prefs;
extern std::string configDir;
extern std::string launchersDir;
extern std::string configFile;
extern LFSTK_windowClass *popWindow;
extern LFSTK_labelClass *popLabel;
extern launcherList *ll;
extern int iconSize;
extern int posMultiplier;
extern int panelSize;
extern int panelWidth;
extern const monitorStruct *mons;
extern int onMonitor;
extern int panelPos;
extern int panelGravity;
extern const char *panelTextColour;
extern const char *panelBGColour;
extern int panelSize;
extern int panelWidth;
extern const monitorStruct *mons;
extern int onMonitor;
extern int panelPos;
extern int panelGravity;
extern const char *panelTextColour;
extern const char *panelBGColour;
extern int extraSpace;
extern int extraSpace;
extern int queueID;
extern msgBuffer buffer;
extern bool realMainLoop;
extern int queueID;
extern msgBuffer buffer;
extern bool realMainLoop;
extern const char *desktopTheme;
extern int refreshRate;
extern const char *desktopTheme;
extern int refreshRate;
//panel window
extern LFSTK_applicationClass *apc;
extern LFSTK_windowClass *mainwind;
extern int leftOffset;
extern int launcherSide;
extern LFSTK_windowClass *mainwind;
extern int launcherSide;
//atoms
extern Atom WM_STATE;
extern Atom NET_WM_WINDOW_TYPE_NORMAL;
extern Atom NET_WM_STATE_HIDDEN;
extern Atom NET_WM_WINDOW_TYPE_DIALOG;
extern Atom NET_WM_DESKTOP;
extern Atom NET_WM_WINDOW_TYPE;
extern Atom NET_WM_STATE;
extern Atom NET_WM_NAME;
extern Atom UTF8_STRING;
extern Atom WM_STATE;
extern Atom NET_WM_WINDOW_TYPE_NORMAL;
extern Atom NET_WM_STATE_HIDDEN;
extern Atom NET_WM_WINDOW_TYPE_DIALOG;
extern Atom NET_WM_DESKTOP;
extern Atom NET_WM_WINDOW_TYPE;
extern Atom NET_WM_STATE;
extern Atom NET_WM_NAME;
extern Atom UTF8_STRING;
extern const char *possibleError;
extern const char *possibleError;
void printError(const char *err);
void setSizes(int *x,int *y,int *w,int *h,int *size,int *grav,bool fromleft);
void dropDesktopFile(const char *data,launcherList *launcher);
void sendNotify(const char *message1,const char *message2);
void setGadgetDetails(LFSTK_gadgetClass *gadget);

View File

@ -18,10 +18,7 @@
* along with LFSPanel. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ftw.h>
#include <stdio.h>
#include <string>
#include <glib.h>
#include "launchers.h"
@ -109,51 +106,34 @@ int launcherBuildCB(const char *fpath,const struct stat *sb,int typeflag)
return(0);
}
int addLaunchers(int x,int y,int grav,bool fromleft)
int addLaunchers(int x,int y,int grav)
{
char *launchers;
launcherList *loopll;
ll=NULL;
launcherList *loopll=NULL;
char *icon=NULL;
int xpos=x;
int ypos=y;
int width=0;
int height=0;
int thisgrav=grav;
int iconsize=16;
int maxwidth=0;
int sx,sy;
int adj;
asprintf(&launchers,"%s/launchers-DOCK",apc->configDir.c_str());
ftw(launchers,launcherBuildCB,16);
setSizes(&xpos,&ypos,&width,&height,&iconsize,&thisgrav,fromleft);
maxwidth=width;
sx=xpos;
sy=ypos;
popWindow=new LFSTK_toolWindowClass(apc->display,mainwind,"_NET_WM_WINDOW_TYPE_MENU",0,0,200,100,"lfstkpopup",apc);
popWindow=new LFSTK_toolWindowClass(apc->display,mainwind,"_NET_WM_WINDOW_TYPE_MENU",0,0,100,100,"lfstkpopup",apc);
popLabel=new LFSTK_labelClass(popWindow,"ANAME",0,0,GADGETWIDTH*8,GADGETHITE,WestGravity);
popLabel->LFSTK_setCairoFontDataParts("sB",20);
popLabel->LFSTK_setTile(NULL,0);
popWindow->LFSTK_setWindowColourName(NORMALCOLOUR,"#c0808080");
if(posMultiplier==-1)
adj=0;
else
adj=extraSpace;
loopll=ll;
while(loopll!=NULL)
{
icon=NULL;
loopll->bc=new LFSTK_buttonClass(mainwind,"",sx,sy+adj,width,height,thisgrav);
loopll->bc=new LFSTK_buttonClass(mainwind,"",xpos,ypos,iconSize,iconSize);
loopll->bc->LFSTK_setMouseCallBack(NULL,launcherCB,(void*)loopll);
loopll->bc->LFSTK_setGadgetDropCallBack(gadgetDrop,(void*)loopll);
loopll->bc->LFSTK_setMouseMoveCallBack(moveCB,exitCB,USERDATA(loopll));
fprintf(stderr,"name=>>%s<<\n",loopll->entry.name);
loopll->bc->LFSTK_setMouseMoveCallBack(enterCB,exitCB,USERDATA(loopll));
loopll->bc->gadgetAcceptsDnD=true;
fprintf(stderr,"name=>>%s x=%i<<\n",loopll->entry.name,xpos);
if((loopll->icon!=NULL) && (desktopTheme!=NULL))
icon=apc->globalLib->LFSTK_findThemedIcon(desktopTheme,loopll->icon,"");
@ -167,18 +147,9 @@ fprintf(stderr,"name=>>%s<<\n",loopll->entry.name);
if(icon!=NULL)
free(icon);
loopll=loopll->next;
if((grav==PANELNORTH) || (grav==PANELSOUTH))
{
if(fromleft==false)
sx-=width;
else
sx+=width;
}
else
sy+=height;
maxwidth+=width;
xpos+=iconSize;
}
free(launchers);
return(maxwidth-width);
return(xpos);
}

View File

@ -26,6 +26,6 @@
extern launcherList *ll;
int addLaunchers(int x,int y,int grav,bool fromleft);
int addLaunchers(int x,int y,int grav);
#endif

View File

@ -1,21 +1,21 @@
/*
*
* ©K. D. Hedger. Mon 7 Sep 13:20:24 BST 2015 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:08:13 GMT 2023 keithdhedger@gmail.com
* This file (lfswmprefs.cpp) is part of LFSApplications.
* This file (main.cpp) is part of LFSDock.
* LFSApplications is free software: you can redistribute it and/or modify
* LFSDock 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.
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* LFSApplications is distributed in the hope that it will be useful,
* LFSDock 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 LFSApplications. If not,see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
@ -31,6 +31,8 @@
#define RCNAME "lfsdock"
int windowWidth=0;
void loadPrefs(const char *env)
{
prefs.LFSTK_loadVarsFromFile(env);
@ -45,34 +47,42 @@ void loadPrefs(const char *env)
void addGadgets(void)
{
int offset=leftOffset;
int offset=0;
int adj;
if(posMultiplier==-1)
adj=0;
else
adj=extraSpace;
for(int j=0; j<prefs.LFSTK_getStringObject("gadgetsleft")->length();j++)
{
switch(prefs.LFSTK_getStringObject("gadgetsleft")->at(j))
{
case 'C':
offset+=addClock(offset,mons->y,NorthWestGravity);
offset+=addClock(offset,adj,NorthWestGravity);
break;
case 'S':
offset+=iconSize;
case 's':
offset+=8;
break;
case 'l':
if(launcherSide==NOLAUNCHERS)
{
launcherSide=LAUNCHERINLEFT;
offset+=addLaunchers(offset,mons->y,panelGravity,true);
offset+=addLaunchers(offset,adj,panelGravity);
}
else
printError("Duplicate launcher widget");
break;
case 's':
offset+=addSlider(offset,mons->y,panelGravity,true);//TODO//
case 'S':
offset+=addSlider(offset,adj,panelGravity);
break;
case 'D':
offset+=addDesktopSwitcer(offset,adj,panelGravity);
break;
}
}
offset++;
leftOffset=offset;
windowWidth=offset;
}
int errHandler(Display *dpy,XErrorEvent *e)
@ -128,14 +138,14 @@ void sanityCheck(void)
int main(int argc,char **argv)
{
char *env;
XEvent event;
int psize;
int thold;
int px,py;
timeval tv={0,0};
int key=666;
int refreshmulti=0;
char *env;
XEvent event;
int psize;
int thold;
int px,py;
timeval tv={0,0};
int key=666;
int refreshmulti=0;
configDir=getenv("HOME") + std::string("/.config/LFS/");
launchersDir=configDir + std::string("launchers-DOCK");
@ -217,20 +227,17 @@ int main(int argc,char **argv)
desktopTheme=mainwind->globalLib->desktopIconTheme.c_str();
mons=apc->LFSTK_getMonitorData(onMonitor);
leftOffset=0;
mainwind->LFSTK_setTile(NULL,0);
mainwind->LFSTK_setWindowColourName(NORMALCOLOUR,"#00000000");
windowWidth=0;
addGadgets();
if(leftOffset==0)
if(windowWidth==0)
{
fprintf(stderr,"Not using empty panel ...\n");
fprintf(stderr,"Not using empty dock ...\n");
exit(0);
}
psize=leftOffset;
psize=windowWidth;
px=mons->x;
py=mons->y;
switch(panelGravity)
@ -268,13 +275,10 @@ int main(int argc,char **argv)
mainwind->LFSTK_resizeWindow(panelWidth,iconSize+extraSpace,true);
if(posMultiplier==1)
{
mainwind->LFSTK_moveWindow(px,py-extraSpace,true);
}
mainwind->LFSTK_moveWindow(px,py-extraSpace,true);
else
{
mainwind->LFSTK_moveWindow(px,py,true);
}
mainwind->LFSTK_moveWindow(px,py,true);
mainwind->LFSTK_showWindow(true);
mainwind->LFSTK_setKeepAbove(true);

View File

@ -1,41 +1,38 @@
/*
*
* ©K. D. Hedger. Thu 3 Jan 12:11:08 GMT 2019 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:09:57 GMT 2023 keithdhedger@gmail.com
* This file (slider.cpp) is part of LFSPanel.
* This file (slider.cpp) is part of LFSDock.
* LFSPanel is free software: you can redistribute it and/or modify
* LFSDock 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.
* (at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* LFSDock 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 LFSPanel. If not, see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <alsa/asoundlib.h>
#include "globals.h"
LFSTK_scrollBarClass *vsb=NULL;
LFSTK_scrollBarClass *vsb=NULL;
LFSTK_windowClass *scwindow=NULL;
bool windowVisible=false;
bool windowVisible=false;
LFSTK_toggleButtonClass *volumeButton;
char *iconH=NULL;
char *iconM=NULL;
char *iconL=NULL;
char *iconZ=NULL;
char *iconH=NULL;
char *iconM=NULL;
char *iconL=NULL;
char *iconZ=NULL;
int oldVolVal=-1;
char label[32];
bool isUp=false;
char label[32];
bool sliderIsUp=false;
void setLabel(void)
{
@ -48,11 +45,11 @@ void setLabel(void)
int getAlsaVolume(bool setvol,int volume)
{
long value=-1;
snd_mixer_t *handle;
snd_mixer_t *handle;
snd_mixer_selem_id_t *sid;
snd_mixer_elem_t *elem;
const char *card="default";
const char *selem_name="Master";
const char *card="default";
const char *selem_name="Master";
snd_mixer_open(&handle,0);
snd_mixer_attach(handle,card);
@ -123,7 +120,6 @@ bool sliderCB(void *p,void* ud)
scwindow->LFSTK_hideWindow();
apc->windows->at(apc->LFSTK_findWindow(scwindow)).showing=false;
}
//bc->LFSTK_clearWindow();
}
return(true);
}
@ -133,7 +129,7 @@ bool valChanged(void *p,void* ud)
LFSTK_scrollBarClass *sb=NULL;
char *command;
char *vol;
int volume=-1;
int volume=-1;
if(p!=NULL)
{
@ -147,7 +143,7 @@ bool valChanged(void *p,void* ud)
return(true);
}
void updateSlider(void)//TODO//when large icon
void updateSlider(void)
{
int volume;
@ -172,7 +168,7 @@ bool volExitCB(LFSTK_gadgetClass*p,void* ud)
adj=extraSpace*posMultiplier;
p->LFSTK_getGeom(&geom2);
p->LFSTK_moveGadget(geom2.x,geom2.y+adj);
isUp=false;
sliderIsUp=false;
return(true);
}
@ -181,36 +177,27 @@ bool volMoveCB(LFSTK_gadgetClass*p,void* ud)
geometryStruct geom;
int adj;
if(isUp==true)
if(sliderIsUp==true)
return(true);
adj=extraSpace*posMultiplier;
p->LFSTK_getGeom(&geom);
p->LFSTK_moveGadget(geom.x,geom.y-adj);
isUp=true;
sliderIsUp=true;
return(true);
}
int addSlider(int x,int y,int grav,bool fromleft)
int addSlider(int x,int y,int grav)
{
int xpos=x;
int ypos=y;
int width=0;
int height=0;
int thisgrav=grav;
int iconsize=16;
int adj;
char *label=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL);
if(posMultiplier==-1)
adj=0;
else
adj=extraSpace;
char *vol=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print $3}'");
char *label=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL);//TODO//
windowInitStruct *win=new windowInitStruct;;
int w,h;
bool direction=false;
getAlsaVolume(false,-1);
setSizes(&xpos,&ypos,&width,&height,&iconsize,&thisgrav,fromleft);
volumeButton=new LFSTK_toggleButtonClass(mainwind,label,xpos,ypos+adj,iconSize,iconSize,thisgrav);
volumeButton=new LFSTK_toggleButtonClass(mainwind,label,x,y,iconSize,iconSize);
volumeButton->LFSTK_setToggleStyle(TOGGLENORMAL);
volumeButton->LFSTK_setMouseCallBack(NULL,sliderCB,(void*)volumeButton->LFSTK_getLabel());
volumeButton->LFSTK_setMouseMoveCallBack(volMoveCB,volExitCB,USERDATA(0));
@ -235,20 +222,10 @@ int addSlider(int x,int y,int grav,bool fromleft)
iconL=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-low","");
iconZ=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"volume-zero","");
char *vol=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print $3}'");
windowInitStruct *win;
int w,h;
win=new windowInitStruct;
win->x=100;
win->y=100;
bool direction=false;
w=100;
h=16;
direction=false;
win->w=w;
win->h=h;
apc->LFSTK_addToolWindow(win);
@ -265,6 +242,6 @@ int addSlider(int x,int y,int grav,bool fromleft)
free(vol);
free(label);
return(width);
return(iconSize);
}

View File

@ -1,21 +1,21 @@
/*
*
* ©K. D. Hedger. Thu 3 Jan 12:10:58 GMT 2019 keithdhedger@gmail.com
* ©K. D. Hedger. Sun 19 Nov 19:10:07 GMT 2023 keithdhedger@gmail.com
* This file (slider.h) is part of LFSPanel.
* This file (slider.h) is part of LFSDock.
* LFSPanel is free software: you can redistribute it and/or modify
* LFSDock 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.
* (at your option) any later version.
* LFSPanel is distributed in the hope that it will be useful,
* LFSDock 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 LFSPanel. If not, see <http://www.gnu.org/licenses/>.
* along with LFSDock. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SLIDER_
@ -24,7 +24,7 @@
#define SLIDERWIDTH 100
#define SLIDERLABEL "Vol"
extern LFSTK_windowClass *scwindow;
extern LFSTK_windowClass *scwindow;
extern bool windowVisible;
extern LFSTK_toggleButtonClass *volumeButton;
extern LFSTK_scrollBarClass *vsb;
@ -34,7 +34,7 @@ extern char *iconL;
extern int oldVolVal;
void setIcon(void);
int addSlider(int x,int y,int grav,bool fromleft);
int addSlider(int x,int y,int grav);
void updateSlider(void);
int getAlsaVolume(bool setvol,int volume);