mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-21 13:28:05 +01:00
added code to store lowered state of menus
compat code for XInternAtoms
This commit is contained in:
@@ -1389,7 +1389,12 @@ doWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
|
|||||||
}
|
}
|
||||||
UpdateSwitchMenu(scr, newFocused, ACTION_CHANGE_STATE);
|
UpdateSwitchMenu(scr, newFocused, ACTION_CHANGE_STATE);
|
||||||
|
|
||||||
} else if (wKeyBindings[WKBD_LOWER].keycode == ev.xkey.keycode
|
} else {
|
||||||
|
handleKeyPress(&ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
else if (wKeyBindings[WKBD_LOWER].keycode == ev.xkey.keycode
|
||||||
&& wKeyBindings[WKBD_LOWER].modifier == modifiers) {
|
&& wKeyBindings[WKBD_LOWER].modifier == modifiers) {
|
||||||
|
|
||||||
wLowerFrame(newFocused->frame->core);
|
wLowerFrame(newFocused->frame->core);
|
||||||
@@ -1398,7 +1403,7 @@ doWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
|
|||||||
&& wKeyBindings[WKBD_RAISE].modifier == modifiers) {
|
&& wKeyBindings[WKBD_RAISE].modifier == modifiers) {
|
||||||
|
|
||||||
wRaiseFrame(newFocused->frame->core);
|
wRaiseFrame(newFocused->frame->core);
|
||||||
}
|
}*/
|
||||||
} else if (ev.type == KeyRelease) {
|
} else if (ev.type == KeyRelease) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|||||||
94
src/menu.c
94
src/menu.c
@@ -2437,25 +2437,36 @@ menuCloseClick(WCoreWindow *sender, void *data, XEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
saveMenuInfo(proplist_t dict, WMenu *menu, proplist_t key)
|
||||||
|
{
|
||||||
|
proplist_t value, list;
|
||||||
|
char buffer[256];
|
||||||
|
|
||||||
|
sprintf(buffer, "%i,%i", menu->frame_x, menu->frame_y);
|
||||||
|
value = PLMakeString(buffer);
|
||||||
|
list = PLMakeArrayFromElements(value, NULL);
|
||||||
|
if (menu->flags.lowered)
|
||||||
|
PLAppendArrayElement(list, PLMakeString("lowered"));
|
||||||
|
PLInsertDictionaryEntry(dict, key, list);
|
||||||
|
PLRelease(value);
|
||||||
|
PLRelease(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wMenuSaveState(WScreen *scr)
|
wMenuSaveState(WScreen *scr)
|
||||||
{
|
{
|
||||||
proplist_t menus, key, value;
|
proplist_t menus, key;
|
||||||
int save_menus = 0;
|
int save_menus = 0;
|
||||||
|
|
||||||
char buffer[256];
|
|
||||||
|
|
||||||
menus = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
|
menus = PLMakeDictionaryFromEntries(NULL, NULL, NULL);
|
||||||
|
|
||||||
#ifndef LITE
|
#ifndef LITE
|
||||||
if (scr->switch_menu && scr->switch_menu->flags.buttoned) {
|
if (scr->switch_menu && scr->switch_menu->flags.buttoned) {
|
||||||
sprintf(buffer, "%i,%i", scr->switch_menu->frame_x,
|
|
||||||
scr->switch_menu->frame_y);
|
|
||||||
key = PLMakeString("SwitchMenu");
|
key = PLMakeString("SwitchMenu");
|
||||||
value = PLMakeString(buffer);
|
saveMenuInfo(menus, scr->switch_menu, key);
|
||||||
PLInsertDictionaryEntry(menus, key, value);
|
|
||||||
PLRelease(key);
|
PLRelease(key);
|
||||||
PLRelease(value);
|
|
||||||
save_menus = 1;
|
save_menus = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2464,13 +2475,9 @@ wMenuSaveState(WScreen *scr)
|
|||||||
|
|
||||||
#endif /* !LITE */
|
#endif /* !LITE */
|
||||||
if (scr->workspace_menu && scr->workspace_menu->flags.buttoned) {
|
if (scr->workspace_menu && scr->workspace_menu->flags.buttoned) {
|
||||||
sprintf(buffer, "%i,%i", scr->workspace_menu->frame_x,
|
|
||||||
scr->workspace_menu->frame_y);
|
|
||||||
key = PLMakeString("WorkspaceMenu");
|
key = PLMakeString("WorkspaceMenu");
|
||||||
value = PLMakeString(buffer);
|
saveMenuInfo(menus, scr->workspace_menu, key);
|
||||||
PLInsertDictionaryEntry(menus, key, value);
|
|
||||||
PLRelease(key);
|
PLRelease(key);
|
||||||
PLRelease(value);
|
|
||||||
save_menus = 1;
|
save_menus = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2510,10 +2517,11 @@ getMenuPath(WMenu *menu, char *buffer, int bufSize)
|
|||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
saveMenuRecurs(proplist_t menus, WScreen *scr, WMenu *menu)
|
saveMenuRecurs(proplist_t menus, WScreen *scr, WMenu *menu)
|
||||||
{
|
{
|
||||||
proplist_t key, value;
|
proplist_t key;
|
||||||
int save_menus = 0, i;
|
int save_menus = 0, i;
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
Bool ok = True;
|
Bool ok = True;
|
||||||
@@ -2524,17 +2532,13 @@ saveMenuRecurs(proplist_t menus, WScreen *scr, WMenu *menu)
|
|||||||
|
|
||||||
if (menu->flags.buttoned && menu != scr->switch_menu) {
|
if (menu->flags.buttoned && menu != scr->switch_menu) {
|
||||||
|
|
||||||
sprintf(buffer, "%i,%i", menu->frame_x, menu->frame_y);
|
|
||||||
value = PLMakeString(buffer);
|
|
||||||
|
|
||||||
buffer[0] = '\0';
|
buffer[0] = '\0';
|
||||||
ok = getMenuPath(menu, buffer, 510);
|
ok = getMenuPath(menu, buffer, 510);
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
key = PLMakeString(buffer);
|
key = PLMakeString(buffer);
|
||||||
PLInsertDictionaryEntry(menus, key, value);
|
saveMenuInfo(menus, menu, key);
|
||||||
PLRelease(key);
|
PLRelease(key);
|
||||||
PLRelease(value);
|
|
||||||
save_menus = 1;
|
save_menus = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2553,22 +2557,50 @@ saveMenuRecurs(proplist_t menus, WScreen *scr, WMenu *menu)
|
|||||||
#define COMPLAIN(key) wwarning(_("bad value in menus state info:%s"), key)
|
#define COMPLAIN(key) wwarning(_("bad value in menus state info:%s"), key)
|
||||||
|
|
||||||
|
|
||||||
|
static Bool
|
||||||
|
getMenuInfo(proplist_t info, int *x, int *y, Bool *lowered)
|
||||||
|
{
|
||||||
|
proplist_t pos;
|
||||||
|
|
||||||
|
*lowered = False;
|
||||||
|
|
||||||
|
if (PLIsArray(info)) {
|
||||||
|
proplist_t flags;
|
||||||
|
pos = PLGetArrayElement(info, 0);
|
||||||
|
flags = PLGetArrayElement(info, 1);
|
||||||
|
if (flags != NULL && PLIsString(flags) && PLGetString(flags) != NULL
|
||||||
|
&& strcmp(PLGetString(flags), "lowered") == 0) {
|
||||||
|
*lowered = True;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pos = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos != NULL && PLIsString(pos)) {
|
||||||
|
if (sscanf(PLGetString(pos), "%i,%i", x, y)!=2)
|
||||||
|
COMPLAIN("Position");
|
||||||
|
} else {
|
||||||
|
COMPLAIN("(position, flags...)");
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
restoreMenu(WScreen *scr, proplist_t menu, int which)
|
restoreMenu(WScreen *scr, proplist_t menu, int which)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
Bool lowered = False;
|
||||||
WMenu *pmenu = NULL;
|
WMenu *pmenu = NULL;
|
||||||
|
|
||||||
if (!menu)
|
if (!menu)
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
if (!PLIsString(menu)) {
|
if (!getMenuInfo(menu, &x, &y, &lowered))
|
||||||
COMPLAIN("Position");
|
|
||||||
return False;
|
return False;
|
||||||
}
|
|
||||||
|
|
||||||
if (sscanf(PLGetString(menu), "%i,%i", &x, &y)!=2)
|
|
||||||
COMPLAIN("Position");
|
|
||||||
|
|
||||||
#ifndef LITE
|
#ifndef LITE
|
||||||
if (which & WSS_SWITCHMENU) {
|
if (which & WSS_SWITCHMENU) {
|
||||||
@@ -2581,6 +2613,10 @@ restoreMenu(WScreen *scr, proplist_t menu, int which)
|
|||||||
int width = MENUW(pmenu);
|
int width = MENUW(pmenu);
|
||||||
int height = MENUH(pmenu);
|
int height = MENUH(pmenu);
|
||||||
|
|
||||||
|
if (lowered) {
|
||||||
|
changeMenuLevels(pmenu, True);
|
||||||
|
}
|
||||||
|
|
||||||
x = (x < -width) ? 0 : x;
|
x = (x < -width) ? 0 : x;
|
||||||
x = (x > scr->scr_width) ? scr->scr_width - width : x;
|
x = (x > scr->scr_width) ? scr->scr_width - width : x;
|
||||||
y = (y < 0) ? 0 : y;
|
y = (y < 0) ? 0 : y;
|
||||||
@@ -2601,6 +2637,7 @@ restoreMenuRecurs(WScreen *scr, proplist_t menus, WMenu *menu, char *path)
|
|||||||
proplist_t key, entry;
|
proplist_t key, entry;
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
int i, x, y, res;
|
int i, x, y, res;
|
||||||
|
Bool lowered;
|
||||||
|
|
||||||
if (strlen(path) + strlen(menu->frame->title) > 510)
|
if (strlen(path) + strlen(menu->frame->title) > 510)
|
||||||
return False;
|
return False;
|
||||||
@@ -2610,10 +2647,7 @@ restoreMenuRecurs(WScreen *scr, proplist_t menus, WMenu *menu, char *path)
|
|||||||
entry = PLGetDictionaryEntry(menus, key);
|
entry = PLGetDictionaryEntry(menus, key);
|
||||||
res = False;
|
res = False;
|
||||||
|
|
||||||
if (entry && PLIsString(entry)) {
|
if (entry && getMenuInfo(entry, &x, &y, &lowered)) {
|
||||||
|
|
||||||
if (sscanf(PLGetString(entry), "%i,%i", &x, &y) != 2)
|
|
||||||
COMPLAIN("Position");
|
|
||||||
|
|
||||||
if (!menu->flags.mapped) {
|
if (!menu->flags.mapped) {
|
||||||
int width = MENUW(menu);
|
int width = MENUW(menu);
|
||||||
@@ -2630,6 +2664,9 @@ restoreMenuRecurs(WScreen *scr, proplist_t menus, WMenu *menu, char *path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (lowered) {
|
||||||
|
changeMenuLevels(menu, True);
|
||||||
|
}
|
||||||
x = (x < -width) ? 0 : x;
|
x = (x < -width) ? 0 : x;
|
||||||
x = (x > scr->scr_width) ? scr->scr_width - width : x;
|
x = (x > scr->scr_width) ? scr->scr_width - width : x;
|
||||||
y = (y < 0) ? 0 : y;
|
y = (y < 0) ? 0 : y;
|
||||||
@@ -2669,6 +2706,7 @@ wMenuRestoreState(WScreen *scr)
|
|||||||
|
|
||||||
skey = PLMakeString("SwitchMenu");
|
skey = PLMakeString("SwitchMenu");
|
||||||
menu = PLGetDictionaryEntry(menus, skey);
|
menu = PLGetDictionaryEntry(menus, skey);
|
||||||
|
PLRelease(skey);
|
||||||
restoreMenu(scr, menu, WSS_SWITCHMENU);
|
restoreMenu(scr, menu, WSS_SWITCHMENU);
|
||||||
|
|
||||||
#ifndef LITE
|
#ifndef LITE
|
||||||
|
|||||||
@@ -691,8 +691,18 @@ StartUp(Bool defaultScreenOnly)
|
|||||||
|
|
||||||
/* _XA_VERSION = XInternAtom(dpy, "VERSION", False);*/
|
/* _XA_VERSION = XInternAtom(dpy, "VERSION", False);*/
|
||||||
|
|
||||||
|
#ifdef HAVE_XINTERNATOMS
|
||||||
XInternAtoms(dpy, atomNames, sizeof(atomNames)/sizeof(char*),
|
XInternAtoms(dpy, atomNames, sizeof(atomNames)/sizeof(char*),
|
||||||
False, atom);
|
False, atom);
|
||||||
|
#else
|
||||||
|
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < sizeof(atomNames)/sizeof(char*); i++) {
|
||||||
|
atom[i] = XInternAtom(dpy, atomNames[i], False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_XA_WM_STATE = atom[0];
|
_XA_WM_STATE = atom[0];
|
||||||
_XA_WM_CHANGE_STATE = atom[1];
|
_XA_WM_CHANGE_STATE = atom[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user