Added something that will be a config util later, removed some unusable options from menus(you'll be later able to re-enable them), changed module dir to /lib/amiwm

This commit is contained in:
reddsik
2017-07-14 13:06:22 +02:00
parent 03aaf742af
commit 5e6ed1191b
12 changed files with 782 additions and 541 deletions

View File

@@ -22,9 +22,9 @@ LIBAMI = libami/libami.a
DT_DIR = /etc/dt
STRIPFLAG = -s
PROGS = amiwm requestchoice executecmd ppmtoinfo
PROGS = amiwm requestchoice executecmd ppmtoinfo config_util
MODULES = $(srcdir)/Background Keyboard Launcher
MODULES = $(srcdir)/Background Keyboard
OBJS = main.o screen.o client.o frame.o icc.o \
icon.o menu.o diskobject.o gram.o lex.o rc.o \
@@ -34,7 +34,7 @@ SRCS = main.c screen.c client.c frame.c icc.c \
icon.c menu.c diskobject.c gram.c lex.c rc.c \
module.c \
requestchoice.c executecmd.c kbdmodule.c kbdlexer.c \
launchermodule.c
config_util.c
DISTFILES = README README.modules INSTALL LICENSE amiwm.1 \
configure configure.in Makefile.in install-sh smakefile scoptions \
@@ -45,6 +45,7 @@ DISTFILES = README README.modules INSTALL LICENSE amiwm.1 \
PACKAGENAME = amiwm
AMIWM_HOME = $(libdir)/amiwm
AMIWM_LIBS = /lib/amiwm
all : lib_all
@$(MAKE) local_all
@@ -90,13 +91,15 @@ kbdlexer.c : kbdlexer.l
install : $(PROGS) $(MODULES) Xsession Xsession2 Xinitrc amiwm-init
-mkdir -p $(AMIWM_HOME)
-mkdir -p $(AMIWM_LIBS)
$(INSTALL) $(STRIPFLAG) requestchoice $(AMIWM_HOME)/requestchoice
$(INSTALL) $(STRIPFLAG) config_util $(AMIWM_HOME)/config_util
$(INSTALL) $(STRIPFLAG) executecmd $(AMIWM_HOME)/executecmd
for module in $(MODULES); do \
if [ "$$module" = "$(srcdir)/Background" ]; then \
$(INSTALL) $$module $(AMIWM_HOME)/Background; \
$(INSTALL) $$module $(AMIWM_LIBS)/Background; \
else \
$(INSTALL) $(STRIPFLAG) $$module $(AMIWM_HOME)/$$module; \
$(INSTALL) $(STRIPFLAG) $$module $(AMIWM_LIBS)/$$module; \
fi; \
done
$(INSTALL) -m 644 $(srcdir)/system.amiwmrc $(AMIWM_HOME)/system.amiwmrc
@@ -135,6 +138,9 @@ amiwm : $(OBJS) $(LIBAMI)
requestchoice : requestchoice.o $(LIBAMI)
$(CC) -o requestchoice requestchoice.o $(LIBS)
config_util : config_util.o $(LIBAMI)
$(CC) -o config_util config_util.o $(LIBS)
executecmd : executecmd.o $(LIBAMI)
$(CC) -o executecmd executecmd.o $(LIBS)
@@ -144,9 +150,6 @@ Filesystem : filesystem.o $(LIBAMI)
Keyboard : kbdmodule.o kbdlexer.o $(LIBAMI)
$(CC) -o Keyboard kbdmodule.o kbdlexer.o $(LIBS)
Launcher : launchermodule.o $(LIBAMI)
$(CC) -o Launcher launchermodule.o $(LIBS)
ppmtoinfo : ppmtoinfo.o
$(CC) -o ppmtoinfo ppmtoinfo.o -lm
@@ -154,7 +157,7 @@ localetest : localetest.o $(LIBAMI)
$(CC) -o localetest localetest.o $(LIBS)
clean :
$(RM) core $(PROGS) $(LIBAMI) Keyboard Launcher *.o libami/*.o
$(RM) core $(PROGS) $(LIBAMI) Keyboard *.o libami/*.o
$(RM) lex.yy.c lex.c y.tab.c y.tab.h gram.h gram.c
$(RM) kbdlexer.c kbdmodule.h kbdmodule.c
$(RM) config.log

21
amiwm.1
View File

@@ -1,12 +1,11 @@
.\" @(#)amiwm.1
'\"macro stdmacro
.nr X
.TH amiwm 1 "26 Mar 2017"
.TH amiwm 1 "19 Jul 2010"
.SH NAME
amiwm \- Amiga Workbench-like X Window Manager
.SH SYNOPSIS
amiwm
\f4amiwm
.SH DESCRIPTION
.I amiwm
@@ -160,7 +159,7 @@ sure that either 'make install' runs successfully (in which case
amiwm will know where its icon is), or that the file .amiwmrc
contains a correct specification of the icon's location.
.SH CONFIGURATION FILES
.SH FILES
.nf
$HOME/.amiwmrc
$AMIWM_HOME/system.amiwmrc
@@ -168,20 +167,10 @@ $AMIWM_HOME/system.amiwmrc
.SH COPYRIGHT NOTICES
This program is distributed as freeware. The copyright remains with
the author. See the file LICENSE for more information.
the author. See the file LICENSE for more information.
Amiga and Workbench are registered trademarks of AMIGA International Inc.
.SH ORIGINAL AUTHOR
.SH AUTHOR
Marcus Comstedt,
.I marcus@mc.pp.se
.SH CONTRIBUTORS
Scott Lawrence,
.I amiwm10@umlautllama.com
Nicolas Sipieter,
.I freeeaks@gmail.com
redsPL,
.I reds@desu.gq

335
config_util.c Normal file
View File

@@ -0,0 +1,335 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "drawinfo.h"
#include "libami.h"
#ifdef AMIGAOS
#include <pragmas/xlib_pragmas.h>
extern struct Library *XLibBase;
#endif
#define BUT_BUTSPACE (2*(2+5))
#define BUT_INTSPACE 12
#define BUT_EXTSPACE 4
#define BUT_VSPACE 6
#define TXT_HSPACE 48
#define TXT_TOPSPACE 4
#define TXT_MIDSPACE 3
#define TXT_BOTSPACE 4
struct choice {
struct choice *next;
const char *text;
int l, w;
Window win;
} *firstchoice=NULL, *lastchoice=NULL;
struct line {
struct line *next;
const char *text;
int l, w, h;
} *firstline=NULL, *lastline=NULL;
Display *dpy;
Window root, mainwin, textwin;
char *progname;
GC gc;
Pixmap stipple;
int totw=0, maxw=0, toth=0, nchoices=0;
int depressed=0;
struct choice *selected=NULL;
struct DrawInfo dri;
struct RDArgs *ra=NULL;
void selection(int n)
{
printf("%d\n", n);
XDestroyWindow(dpy, mainwin);
XCloseDisplay(dpy);
FreeArgs(ra);
exit(0);
}
void *myalloc(size_t s)
{
void *p=calloc(s,1);
if(p)
return p;
fprintf(stderr, "%s: out of memory!\n", progname);
FreeArgs(ra);
exit(1);
}
void addchoice(const char *txt)
{
struct choice *c=myalloc(sizeof(struct choice));
if(lastchoice)
lastchoice->next=c;
else
firstchoice=c;
lastchoice=c;
c->l=strlen(c->text=txt);
#ifdef USE_FONTSETS
totw+=(c->w=XmbTextEscapement(dri.dri_FontSet, c->text, c->l))+BUT_BUTSPACE;
#else
totw+=(c->w=XTextWidth(dri.dri_Font, c->text, c->l))+BUT_BUTSPACE;
#endif
nchoices++;
}
void addline(const char *txt)
{
struct line *l=myalloc(sizeof(struct line));
if(lastline)
lastline->next=l;
else
firstline=l;
lastline=l;
l->l=strlen(l->text=txt);
#ifdef USE_FONTSETS
l->w=XmbTextEscapement(dri.dri_FontSet, l->text, l->l);
#else
l->w=XTextWidth(dri.dri_Font, l->text, l->l);
#endif
toth+=l->h=dri.dri_Ascent+dri.dri_Descent;
if(l->w>maxw)
maxw=l->w;
}
void refresh_text()
{
int w=totw-BUT_EXTSPACE-BUT_EXTSPACE;
int h=toth-TXT_TOPSPACE-TXT_MIDSPACE-TXT_BOTSPACE-BUT_VSPACE-
(dri.dri_Ascent+dri.dri_Descent);
int x=(totw-maxw+TXT_HSPACE)>>1;
int y=((dri.dri_Ascent+dri.dri_Descent)>>1)+dri.dri_Ascent;
struct line *l;
XSetForeground(dpy, gc, dri.dri_Pens[SHADOWPEN]);
XDrawLine(dpy, textwin, gc, 0, 0, w-2, 0);
XDrawLine(dpy, textwin, gc, 0, 0, 0, h-2);
XSetForeground(dpy, gc, dri.dri_Pens[SHINEPEN]);
XDrawLine(dpy, textwin, gc, 0, h-1, w-1, h-1);
XDrawLine(dpy, textwin, gc, w-1, 0, w-1, h-1);
XSetForeground(dpy, gc, dri.dri_Pens[TEXTPEN]);
for(l=firstline; l; l=l->next) {
#ifdef USE_FONTSETS
XmbDrawString(dpy, textwin, dri.dri_FontSet, gc, x, y, l->text, l->l);
#else
XDrawString(dpy, textwin, gc, x, y, l->text, l->l);
#endif
y+=dri.dri_Ascent+dri.dri_Descent;
}
}
void refresh_choice(struct choice *c)
{
int w=c->w+BUT_BUTSPACE;
int h=dri.dri_Ascent+dri.dri_Descent+BUT_VSPACE;
XSetForeground(dpy, gc, dri.dri_Pens[TEXTPEN]);
#ifdef USE_FONTSETS
XmbDrawString(dpy, c->win, dri.dri_FontSet, gc, BUT_BUTSPACE/2,
dri.dri_Ascent+BUT_VSPACE/2, c->text, c->l);
#else
XDrawString(dpy, c->win, gc, BUT_BUTSPACE/2,
dri.dri_Ascent+BUT_VSPACE/2, c->text, c->l);
#endif
XSetForeground(dpy, gc, dri.dri_Pens[(c==selected && depressed)?
SHADOWPEN:SHINEPEN]);
XDrawLine(dpy, c->win, gc, 0, 0, w-2, 0);
XDrawLine(dpy, c->win, gc, 0, 0, 0, h-2);
XSetForeground(dpy, gc, dri.dri_Pens[(c==selected && depressed)?
SHINEPEN:SHADOWPEN]);
XDrawLine(dpy, c->win, gc, 1, h-1, w-1, h-1);
XDrawLine(dpy, c->win, gc, w-1, 1, w-1, h-1);
XSetForeground(dpy, gc, dri.dri_Pens[BACKGROUNDPEN]);
XDrawPoint(dpy, c->win, gc, w-1, 0);
XDrawPoint(dpy, c->win, gc, 0, h-1);
}
void split(char *str, const char *delim, void (*func)(const char *))
{
char *p;
if((p=strtok(str, delim)))
do {
(*func)(p);
} while((p=strtok(NULL, delim)));
}
struct choice *getchoice(Window w)
{
struct choice *c;
for(c=firstchoice; c; c=c->next)
if(w == c->win)
return c;
return NULL;
}
void toggle(struct choice *c)
{
XSetWindowBackground(dpy, c->win, dri.dri_Pens[(depressed&&c==selected)?
FILLPEN:BACKGROUNDPEN]);
XClearWindow(dpy, c->win);
refresh_choice(c);
}
void abortchoice()
{
if(depressed) {
depressed=0;
toggle(selected);
}
selected=NULL;
}
void endchoice()
{
struct choice *c=selected, *c2=firstchoice;
int n;
abortchoice();
if(c==lastchoice)
selection(0);
for(n=1; c2; n++, c2=c2->next)
if(c2==c)
selection(n);
selection(0);
}
int main(int argc, char *argv[])
{
XWindowAttributes attr;
static XSizeHints size_hints;
static XTextProperty txtprop1, txtprop2;
int x, y, extra=0, n=0;
struct choice *c;
Argtype array[3], *atp;
progname="Configuration Utility"; //argv[0];
// initargs(argc, argv);
// if(!(ra=ReadArgs((STRPTR)"TITLE/A,BODY/A,GADGETS/M", (LONG *)array, NULL))) {
// PrintFault(IoErr(), (UBYTE *)progname);
// exit(1);
// }
if(!(dpy = XOpenDisplay(NULL))) {
fprintf(stderr, "%s: cannot connect to X server %s\n", progname,
XDisplayName(NULL));
FreeArgs(ra);
exit(1);
}
root = RootWindow(dpy, DefaultScreen(dpy));
XGetWindowAttributes(dpy, root, &attr);
init_dri(&dri, dpy, root, attr.colormap, False);
addline("Welcome to Configration Utility for AmiWM");
addline("");
addline("that's just a test");
addchoice("OK");
addchoice("cya");
totw+=BUT_EXTSPACE+BUT_EXTSPACE+BUT_INTSPACE*(nchoices-1);
toth+=2*(dri.dri_Ascent+dri.dri_Descent)+TXT_TOPSPACE+
TXT_MIDSPACE+TXT_BOTSPACE+BUT_VSPACE;
maxw+=TXT_HSPACE+BUT_EXTSPACE+BUT_EXTSPACE;
if(maxw>totw) {
extra=maxw-totw;
totw=maxw;
}
mainwin=XCreateSimpleWindow(dpy, root, 0, 0, totw, toth, 1,
dri.dri_Pens[SHADOWPEN],
dri.dri_Pens[BACKGROUNDPEN]);
gc=XCreateGC(dpy, mainwin, 0, NULL);
XSetBackground(dpy, gc, dri.dri_Pens[BACKGROUNDPEN]);
#ifndef USE_FONTSETS
XSetFont(dpy, gc, dri.dri_Font->fid);
#endif
stipple=XCreatePixmap(dpy, mainwin, 2, 3, attr.depth); // 2, 2
XSetForeground(dpy, gc, dri.dri_Pens[BACKGROUNDPEN]);
XFillRectangle(dpy, stipple, gc, 0, 0, 1, 1); // 0, 0, 2, 2
XSetForeground(dpy, gc, dri.dri_Pens[SHINEPEN]);
XDrawPoint(dpy, stipple, gc, 0, 1);
XDrawPoint(dpy, stipple, gc, 1, 0);
XSetWindowBackgroundPixmap(dpy, mainwin, stipple);
textwin=XCreateSimpleWindow(dpy, mainwin, BUT_EXTSPACE, TXT_TOPSPACE, totw-
BUT_EXTSPACE-BUT_EXTSPACE, toth-TXT_TOPSPACE-
TXT_MIDSPACE-TXT_BOTSPACE-BUT_VSPACE-
(dri.dri_Ascent+dri.dri_Descent),
0, dri.dri_Pens[SHADOWPEN],
dri.dri_Pens[BACKGROUNDPEN]);
XSelectInput(dpy, textwin, ExposureMask);
x=BUT_EXTSPACE;
y=toth-TXT_BOTSPACE-(dri.dri_Ascent+dri.dri_Descent)-BUT_VSPACE;
for(c=firstchoice; c; c=c->next) {
c->win=XCreateSimpleWindow(dpy, mainwin,
x+(nchoices==1? (extra>>1):
n++*extra/(nchoices-1)),
y, c->w+BUT_BUTSPACE,
dri.dri_Ascent+dri.dri_Descent+
BUT_VSPACE, 0,
dri.dri_Pens[SHADOWPEN],
dri.dri_Pens[BACKGROUNDPEN]);
XSelectInput(dpy, c->win, ExposureMask|ButtonPressMask|ButtonReleaseMask|
EnterWindowMask|LeaveWindowMask);
x+=c->w+BUT_BUTSPACE+BUT_INTSPACE;
}
size_hints.flags = PResizeInc;
txtprop1.value=(unsigned char *)"ConfigurationUtility";
txtprop2.value=(unsigned char *)"ConfigurationUtility";
txtprop2.encoding=txtprop1.encoding=XA_STRING;
txtprop2.format=txtprop1.format=8;
txtprop1.nitems=strlen((char *)txtprop1.value);
txtprop2.nitems=strlen((char *)txtprop2.value);
XSetWMProperties(dpy, mainwin, &txtprop1, &txtprop2, argv, argc,
&size_hints, NULL, NULL);
XMapSubwindows(dpy, mainwin);
XMapRaised(dpy, mainwin);
for(;;) {
XEvent event;
XNextEvent(dpy, &event);
switch(event.type) {
case Expose:
if(!event.xexpose.count)
if(event.xexpose.window == textwin)
refresh_text();
else if((c=getchoice(event.xexpose.window)))
refresh_choice(c);
break;
case LeaveNotify:
if(depressed && event.xcrossing.window==selected->win) {
depressed=0;
toggle(selected);
}
break;
case EnterNotify:
if((!depressed) && selected && event.xcrossing.window==selected->win) {
depressed=1;
toggle(selected);
}
break;
case ButtonPress:
if(event.xbutton.button==Button1 &&
(c=getchoice(event.xbutton.window))) {
abortchoice();
depressed=1;
toggle(selected=c);
}
break;
case ButtonRelease:
if(event.xbutton.button==Button1 && selected)
if(depressed)
endchoice();
else
abortchoice();
break;
}
}
FreeArgs(ra);
}

882
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
int yywrap() { return 1; }
#line 2 "<stdout>"
#define YY_INT_ALIGNED short int

Binary file not shown.

19
main.c
View File

@@ -44,23 +44,6 @@
#include "icc.h"
#include "libami.h"
#ifdef AMIGAOS
#include <pragmas/xlib_pragmas.h>
extern struct Library *XLibBase;
struct timeval {
long tv_sec;
long tv_usec;
};
#define fd_set XTransFdset
#undef FD_ZERO
#undef FD_SET
#define FD_ZERO XTransFdZero
#define FD_SET XTransFdSet
#define select XTransSelect
#endif
#define HYSTERESIS 5
typedef struct _DragIcon {
@@ -547,7 +530,7 @@ void aborticondragging()
void badicondrop()
{
wberror(dragiconlist[0].icon->scr,
"Icons cannot be moved into this window");
"Icon can't be moved into this window");
aborticondragging();
}

37
menu.c
View File

@@ -19,7 +19,8 @@
" " LF "version "VERSION LF "by Marcus Comstedt" LF \
"<marcus@lysator.liu.se>" LF " " LF \
"Contributions by Scott Lawrence" LF "<amiwm10@umlautllama.com>" LF \
"and Nicolas Sipieter " LF "<freeeaks@gmail.com>" LF " " LF
"and Nicolas Sipieter " LF "<freeeaks@gmail.com>" LF " " LF \
"Some small contributions by redsPL" LF "<reds@sakamoto.pl>" LF " " LF
#ifdef AMIGAOS
#include <pragmas/xlib_pragmas.h>
@@ -408,15 +409,17 @@ void createmenubar()
scr->subspace=scr->hotkeyspace-scr->dri.dri_Ascent;
scr->menuleft=4;
m=add_menu("Workbench", 0);
add_item(m,"Backdrop",'B',CHECKIT|CHECKED|DISABLED);
//add_item(m,"Backdrop",'B',CHECKIT|CHECKED|DISABLED);
add_item(m,"Execute Command...",'E',0);
add_item(m,"Configuration",'C',0);
add_item(m,"Redraw All",0,0);
add_item(m,"Update All",0,DISABLED);
add_item(m,"Last Message",0,DISABLED);
//add_item(m,"Update All",0,DISABLED);
//add_item(m,"Last Message",0,DISABLED);
add_item(m,NULL,0,DISABLED);
add_item(m,"About...",'?',0);
add_item(m,"Quit...",'Q',0);
menu_layout(m);
m=add_menu("Window", 0);
/*m=add_menu("Window", 0);
add_item(m,"New Drawer",'N',DISABLED);
add_item(m,"Open Parent",0,DISABLED);
add_item(m,"Close",'K',DISABLED);
@@ -437,8 +440,8 @@ void createmenubar()
menu_layout(m);
menu_layout(sm1);
menu_layout(sm2);
menu_layout(sm3);
m=add_menu("Icons", DISABLED);
menu_layout(sm3);*/
/*m=add_menu("Icons", DISABLED);
add_item(m,"Open",'O',DISABLED);
add_item(m,"Copy",'C',DISABLED);
add_item(m,"Rename...",'R',DISABLED);
@@ -451,7 +454,7 @@ void createmenubar()
add_item(m,"Delete...",'D',DISABLED);
add_item(m,"Format Disk...",0,DISABLED);
add_item(m,"Empty Trash",0,DISABLED);
menu_layout(m);
menu_layout(m);*/
m=add_menu("Tools", 0);
#ifdef AMIGAOS
add_item(m,"ResetWB",0,DISABLED);
@@ -711,9 +714,11 @@ void menuaction(struct Item *i, struct Item *si)
switch(menu) {
case 0: /* Workbench */
switch(item) {
case 1:
case 0:
spawn(BIN_PREFIX"executecmd");
break;
case 1:
spawn(BIN_PREFIX"config_util");
case 2:
{
XSetWindowAttributes xswa;
@@ -731,7 +736,7 @@ void menuaction(struct Item *i, struct Item *si)
XDestroyWindow(dpy, win);
}
break;
case 5:
case 4:
#ifdef AMIGAOS
spawn(BIN_PREFIX"requestchoice >NIL: amiwm \""
ABOUT_STRING("*N") "\" Ok");
@@ -740,7 +745,7 @@ void menuaction(struct Item *i, struct Item *si)
ABOUT_STRING("\n") "' Ok");
#endif
break;
case 6:
case 5:
#ifndef AMIGAOS
if(prefs.fastquit) {
#endif
@@ -761,7 +766,7 @@ void menuaction(struct Item *i, struct Item *si)
break;
}
break;
case 1: /* Window */
/* case 1: // Window
switch(item) {
case 4:
select_all_icons(scr);
@@ -770,10 +775,10 @@ void menuaction(struct Item *i, struct Item *si)
cleanupicons();
break;
}
break;
case 2: /* Icons */
break;
case 3: /* Tools */
break; */
// case 2: /* Icons */
// break;
case 1: /* Tools */
#ifndef AMIGAOS
if(item==0)
restart_amiwm();

View File

@@ -326,8 +326,8 @@ static void incoming_event(struct module *m, struct mcmd_event *me)
void mod_menuselect(struct module *m, int menu, int item, int subitem)
{
fprintf(stderr, "Nu valde någon minsann menyitem %d:%d:%d.\n"
"Man kanske skulle berätta detta för modul %d\n?",
fprintf(stderr, "No value assigned for menu item %d:%d:%d.\n"
"Read manual for module %d\n?",
menu, item, subitem, (int)m->pid);
}

View File

@@ -16,6 +16,7 @@ extern struct prefs_struct {
int titlebarclock; /* display titlebar clock? */
char *titleclockformat; /* format to use for the clock */
int titleclockinterval; /* how often do we update the clock?*/
int icontray; // if true then icons will be shown in a tray on top of each screen (besides clock and screen name)
struct _Style *firststyle, *laststyle;
} prefs;

1
rc.c
View File

@@ -45,6 +45,7 @@ void read_rc_file(char *filename, int manage_all)
prefs.screenmenu=False;
prefs.firststyle=NULL;
prefs.laststyle=NULL;
prefs.icontray=TRUE;
set_sys_palette();
if(filename!=NULL && (rcfile=fopen(filename, "r"))) {

View File

@@ -1,6 +1,7 @@
FastQuit Off
SizeBorder Right
IconPalette MagicWB
IconDir "/usr/lib/amiwm/"
DefaultIcon "def_tool.info"
CustomIconsOnly Off
ShortLabelIcons Off