mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-23 10:35:50 +01:00
- updated code to use the new runmodal loop where necessary.
- made the WMRunModalLoop() reentrant (a modal panel can have its own modal panel and so on) by saving the modal related information when entering the modal loop and restoring it after.
This commit is contained in:
@@ -601,7 +601,7 @@ WMHandleEvent(XEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (view->screen->modal && toplevel!=view->screen->modalView
|
if (view->screen->modalLoop && toplevel!=view->screen->modalView
|
||||||
&& !toplevel->flags.worksWhenModal) {
|
&& !toplevel->flags.worksWhenModal) {
|
||||||
if (event->type == KeyPress || event->type == KeyRelease
|
if (event->type == KeyPress || event->type == KeyRelease
|
||||||
|| event->type == MotionNotify || event->type == ButtonPress
|
|| event->type == MotionNotify || event->type == ButtonPress
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ typedef struct W_FilePanel {
|
|||||||
struct {
|
struct {
|
||||||
unsigned int canExit:1;
|
unsigned int canExit:1;
|
||||||
unsigned int canceled:1; /* clicked on cancel */
|
unsigned int canceled:1; /* clicked on cancel */
|
||||||
unsigned int done:1;
|
|
||||||
unsigned int filtered:1;
|
unsigned int filtered:1;
|
||||||
unsigned int canChooseFiles:1;
|
unsigned int canChooseFiles:1;
|
||||||
unsigned int canChooseDirectories:1;
|
unsigned int canChooseDirectories:1;
|
||||||
@@ -381,7 +380,6 @@ WMRunModalFilePanelForDirectory(WMFilePanel *panel, WMWindow *owner,
|
|||||||
|
|
||||||
WMSetFilePanelDirectory(panel, path);
|
WMSetFilePanelDirectory(panel, path);
|
||||||
|
|
||||||
panel->flags.done = 0;
|
|
||||||
switch(panel->flags.panelType) {
|
switch(panel->flags.panelType) {
|
||||||
case WP_OPEN:
|
case WP_OPEN:
|
||||||
if (fileTypes)
|
if (fileTypes)
|
||||||
@@ -402,15 +400,9 @@ WMRunModalFilePanelForDirectory(WMFilePanel *panel, WMWindow *owner,
|
|||||||
|
|
||||||
WMSetLabelText(panel->titleLabel, name);
|
WMSetLabelText(panel->titleLabel, name);
|
||||||
|
|
||||||
scr->modalView = W_VIEW(panel->win);
|
|
||||||
WMMapWidget(panel->win);
|
WMMapWidget(panel->win);
|
||||||
|
|
||||||
scr->modal = 1;
|
WMRunModalLoop(scr, W_VIEW(panel->win));
|
||||||
while (!panel->flags.done) {
|
|
||||||
WMNextEvent(scr->display, &event);
|
|
||||||
WMHandleEvent(&event);
|
|
||||||
}
|
|
||||||
scr->modal = 0;
|
|
||||||
|
|
||||||
/* Must withdraw window because the next time we map
|
/* Must withdraw window because the next time we map
|
||||||
* it, it might have a different transient owner.
|
* it, it might have a different transient owner.
|
||||||
@@ -653,41 +645,19 @@ showError(WMScreen *scr, WMWindow *owner, char *s, char *file)
|
|||||||
static void
|
static void
|
||||||
createDir(WMButton *bPre, WMFilePanel *panel)
|
createDir(WMButton *bPre, WMFilePanel *panel)
|
||||||
{
|
{
|
||||||
char *directory_name;
|
char *dirName, *directory, *file, *s;
|
||||||
char *directory;
|
|
||||||
char *file;
|
|
||||||
char *s;
|
|
||||||
WMScreen *scr = WMWidgetScreen(panel->win);
|
WMScreen *scr = WMWidgetScreen(panel->win);
|
||||||
WMInputPanel *_panel;
|
|
||||||
|
|
||||||
_panel = WMCreateInputPanel(scr, panel->win,
|
dirName = WMRunInputPanel(scr, panel->win, "Create Directory",
|
||||||
"Create Directory", "Enter directory name", "", "OK", "Cancel");
|
"Enter directory name", "", "OK", "Cancel");
|
||||||
scr->modalView = W_VIEW(_panel->win);
|
if (!dirName)
|
||||||
WMMapWidget(_panel->win);
|
|
||||||
scr->modal = 1;
|
|
||||||
while (!_panel->done || WMScreenPending(scr)) {
|
|
||||||
XEvent event;
|
|
||||||
WMNextEvent(scr->display, &event);
|
|
||||||
WMHandleEvent(&event);
|
|
||||||
}
|
|
||||||
scr->modal = 0;
|
|
||||||
|
|
||||||
if (_panel->result == WAPRDefault)
|
|
||||||
directory_name = WMGetTextFieldText(_panel->text);
|
|
||||||
else {
|
|
||||||
WMDestroyInputPanel(_panel);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
WMDestroyInputPanel(_panel);
|
|
||||||
|
|
||||||
directory = getCurrentFileName(panel);
|
directory = getCurrentFileName(panel);
|
||||||
{
|
s = strrchr(directory,'/');
|
||||||
char *s = strrchr(directory,'/');
|
if (s) s[1] = 0;
|
||||||
if (s) s[1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (directory_name[0] == '/') {
|
if (dirName[0] == '/') {
|
||||||
directory[0] = 0;
|
directory[0] = 0;
|
||||||
} else {
|
} else {
|
||||||
while ((s = strstr(directory,"//"))) {
|
while ((s = strstr(directory,"//"))) {
|
||||||
@@ -697,15 +667,15 @@ createDir(WMButton *bPre, WMFilePanel *panel)
|
|||||||
}
|
}
|
||||||
if ((s = strrchr(directory, '/')) && !s[1]) s[0] = 0;
|
if ((s = strrchr(directory, '/')) && !s[1]) s[0] = 0;
|
||||||
}
|
}
|
||||||
while ((s = strstr(directory_name,"//"))) {
|
while ((s = strstr(dirName,"//"))) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 2;s[i] == '/';i++);
|
for (i = 2;s[i] == '/';i++);
|
||||||
strcpy(s, &s[i-1]);
|
strcpy(s, &s[i-1]);
|
||||||
}
|
}
|
||||||
if ((s = strrchr(directory_name, '/')) && !s[1]) s[0] = 0;
|
if ((s = strrchr(dirName, '/')) && !s[1]) s[0] = 0;
|
||||||
|
|
||||||
file = wmalloc(strlen(directory_name)+strlen(directory)+1);
|
file = wmalloc(strlen(dirName)+strlen(directory)+1);
|
||||||
sprintf(file, "%s/%s", directory, directory_name);
|
sprintf(file, "%s/%s", directory, dirName);
|
||||||
while ((s = strstr(file,"//"))) {
|
while ((s = strstr(file,"//"))) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 2;s[i] == '/';i++);
|
for (i = 2;s[i] == '/';i++);
|
||||||
@@ -726,10 +696,9 @@ createDir(WMButton *bPre, WMFilePanel *panel)
|
|||||||
}
|
}
|
||||||
else WMSetFilePanelDirectory(panel, file);
|
else WMSetFilePanelDirectory(panel, file);
|
||||||
|
|
||||||
wfree(directory_name);
|
wfree(dirName);
|
||||||
wfree(directory);
|
wfree(directory);
|
||||||
wfree(file);
|
wfree(file);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1002,7 +971,7 @@ buttonClick(WMButton *bPtr, WMFilePanel *panel)
|
|||||||
|
|
||||||
range.count = range.position = 0;
|
range.count = range.position = 0;
|
||||||
WMSelectTextFieldRange(panel->fileField, range);
|
WMSelectTextFieldRange(panel->fileField, range);
|
||||||
panel->flags.done = 1;
|
WMBreakModalLoop(WMWidgetScreen(bPtr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1048,8 +1048,11 @@ WMBreakModalLoop(WMScreen *scr)
|
|||||||
void
|
void
|
||||||
WMRunModalLoop(WMScreen *scr, WMView *view)
|
WMRunModalLoop(WMScreen *scr, WMView *view)
|
||||||
{
|
{
|
||||||
WMScreen *scr = view->screen;
|
/* why is scr passed if is determined from the view? */
|
||||||
|
/*WMScreen *scr = view->screen;*/
|
||||||
|
int oldModalLoop = scr->modalLoop;
|
||||||
|
WMView *oldModalView = scr->modalView;
|
||||||
|
|
||||||
scr->modalView = view;
|
scr->modalView = view;
|
||||||
|
|
||||||
scr->modalLoop = 1;
|
scr->modalLoop = 1;
|
||||||
@@ -1059,7 +1062,10 @@ WMRunModalLoop(WMScreen *scr, WMView *view)
|
|||||||
WMNextEvent(scr->display, &event);
|
WMNextEvent(scr->display, &event);
|
||||||
WMHandleEvent(&event);
|
WMHandleEvent(&event);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
scr->modalView = oldModalView;
|
||||||
|
scr->modalLoop = oldModalLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Display*
|
Display*
|
||||||
|
|||||||
@@ -130,14 +130,14 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
WMMapWidget(panel->vbox);
|
WMMapWidget(panel->vbox);
|
||||||
|
|
||||||
hbox = WMCreateBox(panel->vbox);
|
hbox = WMCreateBox(panel->vbox);
|
||||||
WSetBoxHorizontal(hbox, True);
|
WMSetBoxHorizontal(hbox, True);
|
||||||
WMMapWidget(hbox);
|
WMMapWidget(hbox);
|
||||||
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 80, 0, 0, 5);
|
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 80, 0, 5);
|
||||||
|
|
||||||
panel->iLbl = WMCreateLabel(hbox);
|
panel->iLbl = WMCreateLabel(hbox);
|
||||||
WMSetLabelImagePosition(panel->iLbl, WIPImageOnly);
|
WMSetLabelImagePosition(panel->iLbl, WIPImageOnly);
|
||||||
WMMapWidget(panel->iLbl);
|
WMMapWidget(panel->iLbl);
|
||||||
WMAddBoxSubview(hbox, WMWidgetView(panel->iLbl), False, True, 64, 0, 0, 10);
|
WMAddBoxSubview(hbox, WMWidgetView(panel->iLbl), False, True, 64, 0, 10);
|
||||||
|
|
||||||
if (scrPtr->applicationIcon) {
|
if (scrPtr->applicationIcon) {
|
||||||
WMSetLabelImage(panel->iLbl, scrPtr->applicationIcon);
|
WMSetLabelImage(panel->iLbl, scrPtr->applicationIcon);
|
||||||
@@ -151,7 +151,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
panel->tLbl = WMCreateLabel(hbox);
|
panel->tLbl = WMCreateLabel(hbox);
|
||||||
WMMapWidget(panel->tLbl);
|
WMMapWidget(panel->tLbl);
|
||||||
WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True,
|
WMAddBoxSubview(hbox, WMWidgetView(panel->tLbl), True, True,
|
||||||
64, 0, 0, 0);
|
64, 0, 0);
|
||||||
WMSetLabelText(panel->tLbl, title);
|
WMSetLabelText(panel->tLbl, title);
|
||||||
WMSetLabelTextAlignment(panel->tLbl, WALeft);
|
WMSetLabelTextAlignment(panel->tLbl, WALeft);
|
||||||
WMSetLabelFont(panel->tLbl, largeFont);
|
WMSetLabelFont(panel->tLbl, largeFont);
|
||||||
@@ -172,7 +172,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
panel->mLbl = WMCreateLabel(panel->win);
|
panel->mLbl = WMCreateLabel(panel->win);
|
||||||
WMMapWidget(panel->mLbl);
|
WMMapWidget(panel->mLbl);
|
||||||
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->mLbl), True, True,
|
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->mLbl), True, True,
|
||||||
WMFontHeight(scrPtr->normalFont)*4, 0, 0, 5);
|
WMFontHeight(scrPtr->normalFont)*4, 0, 5);
|
||||||
WMSetLabelText(panel->mLbl, msg);
|
WMSetLabelText(panel->mLbl, msg);
|
||||||
WMSetLabelTextAlignment(panel->mLbl, WACenter);
|
WMSetLabelTextAlignment(panel->mLbl, WACenter);
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
hbox = WMCreateBox(panel->vbox);
|
hbox = WMCreateBox(panel->vbox);
|
||||||
WMSetBoxHorizontal(hbox, True);
|
WMSetBoxHorizontal(hbox, True);
|
||||||
WMMapWidget(hbox);
|
WMMapWidget(hbox);
|
||||||
WMAddBoxSubview(panel->vbox, hbox, False, True, 24, 0, 0, 0);
|
WMAddBoxSubview(panel->vbox, WMWidgetView(hbox), False, True, 24, 0, 0);
|
||||||
|
|
||||||
/* create buttons */
|
/* create buttons */
|
||||||
if (otherButton)
|
if (otherButton)
|
||||||
|
|||||||
Reference in New Issue
Block a user