[amiwm] Update to 0.22pl2

This notably includes full screen support!

Addresses Issue #12
This commit is contained in:
Adrian Chadd
2023-12-21 22:09:25 -08:00
parent 9b3846e15a
commit def62797f9
10 changed files with 265 additions and 60 deletions

View File

@@ -130,13 +130,10 @@ void checksizehints(Client *c)
long supplied;
XGetWMNormalHints(dpy, c->window, c->sizehints, &supplied);
if(!(c->sizehints->flags&PMinSize))
c->sizehints->min_width=c->sizehints->min_height=0;
if(!(c->sizehints->flags&PMaxSize)) {
if(!(c->sizehints->flags&PMaxSize))
c->sizehints->max_width=c->sizehints->max_height=1<<30;
}
if(!(c->sizehints->flags&PResizeInc))
c->sizehints->width_inc=c->sizehints->height_inc=1;
if(c->sizehints->flags&PBaseSize) {
@@ -150,6 +147,38 @@ void checksizehints(Client *c)
if(c->sizehints->flags&PWinGravity) c->gravity=c->sizehints->win_gravity;
}
void open_fscrn(Client *c)
{
XUnmapWindow(dpy, c->parent);
c->fsscr = scr = openscreen(NULL, scr->root);
c->reparenting = 1;
XReparentWindow(dpy, c->window, scr->back, 0, 0);
XResizeWindow(dpy, c->window, scr->width, scr->height);
realizescreens();
scr = c->fsscr;
#ifdef USE_FONTSETS
XStoreName(dpy, scr->back, c->title);
#else
XSetWMName(dpy, scr->back, &c->title);
#endif
screentoback();
}
void close_fscrn(Client *c, int state)
{
if (c->fsscr == NULL)
return;
XReparentWindow(dpy, c->window, c->parent, 4, c->scr->bh);
XResizeWindow(dpy, c->window, c->pwidth-c->framewidth, c->pheight-c->frameheight);
XLowerWindow(dpy, c->window);
scr = c->fsscr;
closescreen();
c->fsscr = NULL;
scr = c->scr;
if (state != IconicState)
XMapWindow(dpy, c->parent);
}
void setclientstate(Client *c, int state)
{
long data[2];
@@ -157,6 +186,13 @@ void setclientstate(Client *c, int state)
data[0] = (long) state;
data[1] = (long) None;
if (c->fullscreen) {
if (state != NormalState && c->state == NormalState) {
close_fscrn(c, state);
} else if (state == NormalState && c->state != NormalState) {
open_fscrn(c);
}
}
c->state = state;
XChangeProperty(dpy, c->window, wm_state, wm_state, 32,
PropModeReplace, (unsigned char *)data, 2);
@@ -188,6 +224,7 @@ Client *createclient(Window w)
c = (Client *)calloc(1, sizeof(Client));
c->sizehints = XAllocSizeHints();
c->scr = scr;
c->fsscr = NULL;
c->window = w;
c->parent = scr->root;
c->old_bw = attr.border_width;
@@ -195,6 +232,7 @@ Client *createclient(Window w)
c->state = WithdrawnState;
c->gravity = NorthWestGravity;
c->reparenting = 0;
c->fullscreen = 0;
XSelectInput(dpy, c->window, PropertyChangeMask);
#ifdef USE_FONTSETS
{
@@ -270,6 +308,9 @@ void rmclient(Client *c)
break;
}
if ((scr = c->fsscr))
closescreen();
scr = c->scr;
if(c->active) {
if(!menuactive)
setfocus(None);
@@ -394,3 +435,25 @@ reparent_client(Scrn *s, Client *client)
setstringprop(client->window, amiwm_screen, s->deftitle);
sendconfig(client);
}
void fullscreen(Client *c, int fs)
{
if (fs == c->fullscreen)
return;
if (c->state != NormalState) {
c->fullscreen = fs;
setwmstate(c);
return;
}
if (fs) {
open_fscrn(c);
c->fullscreen = 1;
} else {
close_fscrn(c, c->state);
c->fullscreen = 0;
setclientstate(c, NormalState);
}
setwmstate(c);
}

View File

@@ -16,7 +16,7 @@ struct _Scrn;
*/
typedef struct _Client {
struct _Client *next;
struct _Scrn *scr;
struct _Scrn *scr, *fsscr;
struct _Icon *icon;
struct module *module;
int wflags;
@@ -27,7 +27,7 @@ typedef struct _Client {
int x, y, pwidth, pheight, dragw, framewidth, frameheight;
int zoomx, zoomy, zoomw, zoomh;
int old_bw, proto, state, gravity, reparenting;
int active, shaped;
int active, shaped, fullscreen;
#ifdef USE_FONTSETS
char *title;
#else
@@ -52,6 +52,6 @@ extern void grav_map_frame_to_win(Client *, int, int, int *, int *);
extern void grav_map_win_to_frame(Client *, int, int, int *, int *);
extern void setclientstate(Client *, int);
extern void reparent_client(struct _Scrn *s, Client *client);
extern void fullscreen(Client *, int);
#endif

View File

@@ -1,10 +1,10 @@
AC_INIT(diskobject.c)
AC_INIT
AC_CONFIG_SRCDIR([diskobject.c])
AC_ENABLE(fontsets,
[use_fontsets="$enableval"], [use_fontsets=auto])
AC_ARG_ENABLE([fontsets],[ --enable-fontsets],[use_fontsets="$enableval"],[use_fontsets=auto])
AC_PROG_CC
AC_ISC_POSIX
AC_SEARCH_LIBS([strerror],[cposix])
AC_PROG_AWK
AC_PROG_YACC
AC_PROG_LEX
@@ -14,7 +14,15 @@ AC_PROG_RANLIB
AC_PATH_XTRA
AC_HEADER_STDC
m4_warn([obsolete],
[The preprocessor macro `STDC_HEADERS' is obsolete.
Except in unusual embedded environments, you can safely include all
ISO C90 headers unconditionally.])dnl
# Autoupdate added the next two lines to ensure that your configure
# script's behavior did not change. They are probably safe to remove.
AC_CHECK_INCLUDES_DEFAULT
AC_PROG_EGREP
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h sys/types.h unistd.h sys/select.h sys/resource.h sys/stat.h termio.h)
ac_save_CPPFLAGS="$CPPFLAGS"
@@ -29,7 +37,19 @@ AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_FUNC_ALLOCA
AC_TYPE_SIGNAL
m4_warn([obsolete],
[your code may safely assume C89 semantics that RETSIGTYPE is void.
Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl
AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <sys/types.h>
#include <signal.h>
],
[return *(signal (0, 0)) (0) == 1;])],
[ac_cv_type_signal=int],
[ac_cv_type_signal=void])])
AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers
(`int' or `void').])
AC_FUNC_WAIT3
AC_CHECK_FUNCS(select strdup waitpid)
@@ -41,13 +61,13 @@ dnl libXt too, so that's what we'll do.
AC_MSG_CHECKING([for broken libXmu])
old_LIBS="$LIBS"
LIBS="$X_LIBS $X_PRE_LIBS -lXext -lXmu -lX11 $X_EXTRA_LIBS $LIBS"
AC_TRY_LINK([],[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
extern void XmuCopyISOLatin1Lowered(char *,char *);
char foo[]="FOO";
XmuCopyISOLatin1Lowered (foo, foo);
], AC_MSG_RESULT([no])
XT_LIB_KLUDGE="", AC_MSG_RESULT([yes])
XT_LIB_KLUDGE="-lXt")
]])],[AC_MSG_RESULT(no)
XT_LIB_KLUDGE=""],[AC_MSG_RESULT(yes)
XT_LIB_KLUDGE="-lXt"])
LIBS="$old_LIBS"
AC_SUBST(XT_LIB_KLUDGE)
@@ -62,17 +82,17 @@ else
fi
AC_MSG_CHECKING([number of arguments to gettimeofday])
AC_TRY_LINK([
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdlib.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
],[
]], [[
struct timeval tp;
struct timezone tz;
gettimeofday(&tp, &tz);
], AC_DEFINE(BSD_STYLE_GETTIMEOFDAY,1,[Define this if gettimeofday() takes two arguments.])
AC_MSG_RESULT([2]), AC_MSG_RESULT([1]))
]])],[AC_DEFINE(BSD_STYLE_GETTIMEOFDAY,1,Define this if gettimeofday() takes two arguments.)
AC_MSG_RESULT(2)],[AC_MSG_RESULT(1)])
AC_CHECK_TYPE(caddr_t, char *)
AC_MSG_CHECKING([for XPointer])
@@ -97,7 +117,7 @@ else
fi
AC_MSG_CHECKING([byteorder])
AC_TRY_RUN([
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
int main()
{
@@ -107,9 +127,10 @@ int main()
if(v.i==1) exit(0); else exit(1);
return 0;
}
], AC_DEFINE([LAME_ENDIAN],1,[Define this is your achitecture stores integers backwards in memory])
AC_MSG_RESULT([backward]), AC_MSG_RESULT([normal]), AC_MSG_RESULT([no idea]))
]])],[AC_DEFINE(LAME_ENDIAN,1,Define this is your achitecture stores integers backwards in memory)
AC_MSG_RESULT(backward)],[AC_MSG_RESULT(normal)],[AC_MSG_RESULT(no idea)])
AC_SUBST(x_includes)
AC_SUBST(x_libraries)
AC_OUTPUT(Makefile libami/Makefile)
AC_CONFIG_FILES([Makefile libami/Makefile])
AC_OUTPUT

View File

@@ -102,6 +102,7 @@ void resizeclientwindow(Client *c, int width, int height)
spread_top_gadgets(c);
if(c->resize)
XMoveWindow(dpy, c->resize, c->pwidth-18, c->pheight-10);
if (!c->fullscreen)
XResizeWindow(dpy, c->window, c->pwidth-c->framewidth, c->pheight-c->frameheight);
if(c->shaped)
reshape_frame(c);
@@ -180,6 +181,7 @@ void reparent(Client *c)
int cargc;
int size_changed = 0;
getwmstate(c);
if(XGetTransientForHint(dpy, c->window, &leader) &&
!XFindContext(dpy, leader, client_context, (XPointer *)&lc))
c->scr = lc->scr;

58
icc.c
View File

@@ -18,6 +18,7 @@ extern void redraw(Client *, Window);
Atom wm_state, wm_change_state, wm_protocols, wm_delete, wm_take_focus;
Atom wm_colormaps, wm_name, wm_normal_hints, wm_hints, wm_icon_name, wm_class;
Atom net_supported, net_wm_state, net_wm_state_fullscreen;
Atom amiwm_screen, swm_vroot, amiwm_wflags, amiwm_appiconmsg, amiwm_appwindowmsg;
extern Display *dpy;
@@ -35,6 +36,9 @@ void init_atoms()
wm_hints = XInternAtom(dpy, "WM_HINTS", False);
wm_icon_name = XInternAtom(dpy, "WM_ICON_NAME", False);
wm_class = XInternAtom(dpy, "WM_CLASS", False);
net_supported = XInternAtom(dpy, "_NET_SUPPORTED", False);
net_wm_state = XInternAtom(dpy, "_NET_WM_STATE", False);
net_wm_state_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
amiwm_screen = XInternAtom(dpy, "AMIWM_SCREEN", False);
swm_vroot = XInternAtom(dpy, "__SWM_VROOT", False);
amiwm_wflags = XInternAtom(dpy, "AMIWM_WFLAGS", False);
@@ -42,6 +46,16 @@ void init_atoms()
amiwm_appwindowmsg = XInternAtom(dpy, "AMIWM_APPWINDOWMSG", False);
}
void setsupports(Window root)
{
Atom atoms[] = {
net_wm_state_fullscreen
};
XChangeProperty(dpy, root, net_supported, XA_ATOM, 32,
PropModeReplace, (unsigned char *)atoms,
sizeof(atoms)/sizeof(atoms[0]));
}
void setstringprop(Window w, Atom a, char *str)
{
XTextProperty txtp;
@@ -67,6 +81,39 @@ XEvent *mkcmessage(Window w, Atom a, long x)
return &ev;
}
void getwmstate(Client *c)
{
Atom *p;
int i;
long n;
Window w;
w = c->window;
if ((n = _getprop(w, net_wm_state, XA_ATOM, 20L, (char**)&p)) < 0)
return;
c->fullscreen = 0;
if (!n)
return;
for (i = 0; i < n; i++)
if (p[i] == net_wm_state_fullscreen)
c->fullscreen = 1;
XFree((char *) p);
}
void setwmstate(Client *c)
{
if (c->fullscreen) {
Atom data[] = {
net_wm_state_fullscreen
};
XChangeProperty(dpy, c->window, net_wm_state, XA_ATOM, 32, PropModeReplace,
(unsigned char *)data, 1);
} else
XDeleteProperty(dpy, c->window, net_wm_state);
}
void sendcmessage(Window w, Atom a, long x)
{
if(!(XSendEvent(dpy, w, False, 0L, mkcmessage(w, a, x))))
@@ -280,9 +327,18 @@ void handle_client_message(Client *c, XClientMessageEvent *xcme)
i->mapped=0;
deselecticon(i);
XMapWindow(dpy, c->window);
if(c->parent!=c->scr->root)
if(c->parent!=c->scr->root && !c->fullscreen)
XMapRaised(dpy, c->parent);
setclientstate(c, NormalState);
}
} else if (xcme->message_type == net_wm_state) {
int action=xcme->data.l[0];
Atom prop=xcme->data.l[1];
if (prop == net_wm_state_fullscreen)
switch (action) {
case 0: fullscreen(c, 0); break; /* _NET_WM_STATE_REMOVE */
case 1: fullscreen(c, 1); break; /* _NET_WM_STATE_ADD */
case 2: fullscreen(c, !c->fullscreen); break; /* _NET_WM_STATE_TOGGLE */
}
}
}

3
icc.h
View File

@@ -6,8 +6,11 @@
#include "client.h"
extern void init_atoms(void);
extern void setsupports(Window);
extern void sendcmessage(Window, Atom, long);
extern void getproto(Client *c);
extern void getwmstate(Client *c);
extern void setwmstate(Client *c);
extern void setstringprop(Window, Atom, char *);
extern void propertychange(Client *, Atom);
extern long _getprop(Window, Atom, Atom, long, char **);

28
main.c
View File

@@ -45,6 +45,23 @@
#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 {
@@ -550,6 +567,11 @@ void endicondragging(XEvent *e)
}
}
if (!scr->deftitle) {
badicondrop();
return;
}
if(XTranslateCoordinates(dpy, scr->root, scr->back,
e->xbutton.x_root, e->xbutton.y_root,
&wx, &wy, &ch) && ch!=None) {
@@ -723,7 +745,7 @@ void do_icon_double_click(Scrn *scr)
deselecticon(i);
if((c=(i->client))) {
XMapWindow(dpy, c->window);
if(c->parent!=c->scr->root)
if(c->parent!=c->scr->root && !c->fullscreen)
XMapRaised(dpy, c->parent);
setclientstate(c, NormalState);
}
@@ -1044,7 +1066,8 @@ int main(int argc, char *argv[])
XDeleteContext(dpy, event.xdestroywindow.window, screen_context);
break;
case UnmapNotify:
if(c && c->active && (event.xunmap.window==c->parent)) {
if(c && c->active && (event.xunmap.window==c->parent) &&
!(c->fullscreen && c->state == NormalState)) {
c->active=False;
activeclient = NULL;
redrawclient(c);
@@ -1198,6 +1221,7 @@ int main(int argc, char *argv[])
reparent(c);
case NormalState:
XMapWindow(dpy, c->window);
if (!c->fullscreen)
XMapRaised(dpy, c->parent);
setclientstate(c, NormalState);
break;

31
menu.c
View File

@@ -372,23 +372,39 @@ void createmenubar()
scr->firstmenu = NULL;
attr.override_redirect=True;
if (scr->deftitle) {
attr.background_pixel=scr->dri.dri_Pens[BARBLOCKPEN];
scr->menubar=XCreateWindow(dpy, scr->back, 0, 0, scr->width, scr->bh, 0,
CopyFromParent,
InputOutput, CopyFromParent,
CWOverrideRedirect|CWBackPixel,
&attr);
XSaveContext(dpy, scr->menubar, screen_context, (XPointer)scr);
scr->menubarparent=XCreateWindow(dpy, scr->menubar, 0, 0, scr->width,
scr->bh-1, 0,
CopyFromParent, InputOutput, CopyFromParent,
CWOverrideRedirect|CWBackPixel, &attr);
XSaveContext(dpy, scr->menubarparent, screen_context, (XPointer)scr);
attr.background_pixel=scr->dri.dri_Pens[BACKGROUNDPEN];
scr->menubardepth=XCreateWindow(dpy, scr->menubar, scr->width-23,
0, 23, scr->bh, 0,
CopyFromParent, InputOutput, CopyFromParent,
CWOverrideRedirect|CWBackPixel, &attr);
} else {
scr->menubar=XCreateWindow(dpy, scr->back, 0, 0, scr->width, scr->bh, 0, 0,
InputOnly, CopyFromParent,
CWOverrideRedirect, &attr);
scr->menubarparent=None;
scr->menubardepth=XCreateWindow(dpy, scr->menubar, scr->width-23,
0, 23, scr->bh, 0, 0,
InputOnly, CopyFromParent,
CWOverrideRedirect, &attr);
}
XSaveContext(dpy, scr->menubar, screen_context, (XPointer)scr);
if (scr->menubarparent)
XSaveContext(dpy, scr->menubarparent, screen_context, (XPointer)scr);
XSaveContext(dpy, scr->menubardepth, screen_context, (XPointer)scr);
scr->disabled_stipple=XCreatePixmap(dpy, scr->back, 6, 2, 1);
gc=XCreateGC(dpy, scr->disabled_stipple, 0, NULL);
@@ -398,11 +414,16 @@ void createmenubar()
XDrawPoint(dpy, scr->disabled_stipple, gc, 0, 0);
XDrawPoint(dpy, scr->disabled_stipple, gc, 3, 1);
XFreeGC(dpy, gc);
if (scr->deftitle) {
scr->menubargc=XCreateGC(dpy, scr->menubar, 0, NULL);
#ifndef USE_FONTSETS
XSetFont(dpy, scr->menubargc, scr->dri.dri_Font->fid);
#endif
XSetBackground(dpy, scr->menubargc, scr->dri.dri_Pens[BARBLOCKPEN]);
} else {
scr->menubargc = NULL;
}
XSelectInput(dpy, scr->menubar, ExposureMask|ButtonPressMask|ButtonReleaseMask);
XSelectInput(dpy, scr->menubardepth, ExposureMask|ButtonPressMask|
ButtonReleaseMask|EnterWindowMask|LeaveWindowMask);
@@ -413,6 +434,10 @@ void createmenubar()
scr->checkmarkspace=4+scr->dri.dri_Ascent;
scr->subspace=scr->hotkeyspace-scr->dri.dri_Ascent;
scr->menuleft=4;
if (!scr->menubarparent)
return;
m=add_menu("Workbench", 0);
//add_item(m,"Backdrop",'B',CHECKIT|CHECKED|DISABLED);
add_item(m,"Execute Command...",'E',0);
@@ -502,7 +527,7 @@ void redrawmenubar(Scrn *scr, Window w)
struct Menu *m;
struct Item *item;
if(!w)
if(!w || !scr->menubargc)
return;
if(w==scr->menubar) {
/* Menubar itself */

View File

@@ -68,7 +68,7 @@ void setvirtualroot(Scrn *s)
}
}
Scrn *getscreenbyroot(Window w);
Scrn *getscreenbyrootext(Window w, int include_fs);
void screentoback(void)
{
@@ -77,7 +77,7 @@ void screentoback(void)
if(scr == get_front_scr()) {
XLowerWindow(dpy, scr->back);
set_front_scr(scr->behind);
} else if(scr==getscreenbyroot(scr->root)) {
} else if(scr==getscreenbyrootext(scr->root, 1)) {
XLowerWindow(dpy, scr->back);
scr->upfront->behind=scr->behind;
scr->behind->upfront=scr->upfront;
@@ -98,7 +98,7 @@ void screentoback(void)
get_front_scr()->upfront=scr;
set_front_scr(scr);
}
if((f = getscreenbyroot(scr->root))) {
if((f = getscreenbyrootext(scr->root, 0))) {
init_dri(&f->dri, dpy, f->root, f->cmap, True);
setvirtualroot(f);
}
@@ -179,8 +179,10 @@ void closescreen(void)
XDeleteContext(dpy,scr->menubardepth,screen_context);
XDestroyWindow(dpy,scr->menubardepth);
if (scr->menubarparent != None) {
XDeleteContext(dpy,scr->menubarparent,screen_context);
XDestroyWindow(dpy,scr->menubarparent);
}
XDeleteContext(dpy,scr->menubar,screen_context);
XDestroyWindow(dpy,scr->menubar);
if(scr->inputbox != None) {
@@ -348,6 +350,7 @@ void realizescreens(void)
XMapWindow(dpy, scr->inputbox);
}
setsupports(scr->root);
XSelectInput(dpy, scr->root,
SubstructureNotifyMask|SubstructureRedirectMask|
KeyPressMask|KeyReleaseMask|
@@ -358,9 +361,12 @@ void realizescreens(void)
KeyPressMask|KeyReleaseMask|
ButtonPressMask|ButtonReleaseMask);
if (scr->title)
XStoreName(dpy, scr->back, scr->title);
XLowerWindow(dpy, scr->back);
XMapWindow(dpy, scr->back);
if (!scr->deftitle)
scr->realized = 1;
}
scr=scr->behind;
} while(scr != get_front_scr());
@@ -389,14 +395,19 @@ Scrn *getscreen(Window w)
return get_front_scr();
}
Scrn *getscreenbyroot(Window w)
Scrn *getscreenbyrootext(Window w, int include_fs)
{
Scrn *s = get_front_scr();
if(s)
do {
if(s->root == w)
if(s->root == w && (include_fs || s->deftitle))
return s;
s=s->behind;
} while(s != get_front_scr());
return NULL;
}
Scrn *getscreenbyroot(Window w)
{
return getscreenbyrootext(w, 0);
}

View File

@@ -1 +1 @@
#define VERSION "0.22_01"
#define VERSION "0.22pl2+github"