Cambiato meccanismo di sincronizzazione tra le applicazioni

git-svn-id: svn://10.65.10.50/trunk@773 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-12-16 15:50:08 +00:00
parent 1b54d95ee2
commit 6127537a65
7 changed files with 67 additions and 112 deletions

View File

@ -149,72 +149,6 @@ void TBanner::handler(WINDOW win, EVENT* ep)
TWindow::handler(win, ep); TWindow::handler(win, ep);
} }
#if XVT_OS == XVT_OS_WIN
///////////////////////////////////////////////////////////
// Gestione dei processi per Windows(R)
///////////////////////////////////////////////////////////
#include <windows.h>
const word WM_WAKEUP = RegisterWindowMessage("WAKEUP");
DWORD waiting_for = 0;
HIDDEN BOOLEAN waiting_event_hook(HWND, WORD msg, WORD,
DWORD lparam, long far* ret)
{
if (msg == WM_WAKEUP)
{
if( lparam == waiting_for || lparam == 0)
{
waiting_for = 0L;
TTemp_window tw(TASK_WIN);
tw.maximize();
}
*ret = 0;
return TRUE;
}
return FALSE;
}
HIDDEN DWORD name2id(const char* name)
{
waiting_for = 0L;
for (int i = 0; i < 5 && name[i] > ' '; i++)
{
waiting_for <<= 6;
waiting_for |= toupper(name[i]) - '0';
}
return waiting_for;
}
void TApplication::wait_for(const char* command)
{
TTemp_window tw(TASK_WIN);
tw.iconize();
name2id(cmd2name(command));
const long old_hook = get_value(TASK_WIN, ATTR_EVENT_HOOK);
set_value(TASK_WIN, ATTR_EVENT_HOOK, (long)waiting_event_hook);
while (waiting_for) do_events();
// We need to restore these things
set_value(TASK_WIN, ATTR_EVENT_HOOK, old_hook);
xvt_statbar_refresh();
}
void TApplication::wake_up_caller() const
{
name2id(name());
SendMessage(-1, WM_WAKEUP, 0, waiting_for);
}
#endif
long TApplication::task_eh(WINDOW win, EVENT *ep) long TApplication::task_eh(WINDOW win, EVENT *ep)
{ {
switch (ep->type) switch (ep->type)
@ -358,10 +292,6 @@ bool TApplication::destroy()
void TApplication::terminate() void TApplication::terminate()
{ {
#if XVT_OS == XVT_OS_WIN
wake_up_caller(); // Manda il segnale di risveglio al chiamante
#endif
close_all_dialogs(); close_all_dialogs();
if (_create_ok) if (_create_ok)
@ -559,6 +489,9 @@ void TApplication::enable_menu_item(MENU_TAG item, bool on)
win_update_menu_bar(TASK_WIN); win_update_menu_bar(TASK_WIN);
} }
#if XVT_OS == XVT_OS_WIN
#include <windows.h>
#endif
void TApplication::dispatch_e_menu(MENU_TAG item) void TApplication::dispatch_e_menu(MENU_TAG item)
{ {

View File

@ -85,9 +85,6 @@ public:
void set_title(const char* t) { _title = t; } void set_title(const char* t) { _title = t; }
const TString& title() const { return _title; } const TString& title() const { return _title; }
void wait_for(const char* name);
void wake_up_caller() const;
TPrinter* set_printer(TPrinter* p); TPrinter* set_printer(TPrinter* p);
TPrinter& printer(); TPrinter& printer();

View File

@ -1,7 +1,6 @@
// fv 6/10/93 // fv 6/10/93
#include <stdio.h> #include <stdio.h>
#include <xvt.h> #include <xvt.h>
#if XVT_OS == XVT_OS_SCOUNIX #if XVT_OS == XVT_OS_SCOUNIX
@ -9,25 +8,20 @@
#include <sys/wait.h> #include <sys/wait.h>
#endif #endif
#include <applicat.h>
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
#include <windows.h> #include <windows.h>
#include <toolhelp.h>
#endif #endif
#if XVT_OS == XVT_OS_DOS #include <applicat.h>
#include <holdev.h>
#endif
#include <execp.h> #include <execp.h>
bool TExternal_app::can_run() const bool TExternal_app::can_run() const
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
const TFixed_string p(_path); const TFixed_string p(_path);
const bool clifo = p.find("cg0") == 0 && p.right(2) == "-1"; const bool big = p.find("cg0") == 0 && p.right(2) == "-1";
const int richieste = clifo ? 50 : 15; const int richieste = big ? 50 : 15;
const int libere = GetFreeSystemResources(GFSR_SYSTEMRESOURCES); const int libere = GetFreeSystemResources(GFSR_SYSTEMRESOURCES);
return libere >= richieste; return libere >= richieste;
#else #else
@ -36,22 +30,13 @@ bool TExternal_app::can_run() const
} }
// char _path[120]; // app name
// int _error; // last error
// int _exitcode; // last exit code
// int _count; // count of calls returning 0
// int error() { return _error};
// int exitcode() { return _exitcode};
// int count() { return _count; };
int TExternal_app::run(bool async, bool iconized) int TExternal_app::run(bool async, bool iconized)
{ {
TString256 path(_path); TString256 path(_path);
if (!async) if (!async)
{ {
if (iconized) if (iconized) path << " -icon";
path << " -icon";
path << " -u" << main_app().user(); path << " -u" << main_app().user();
} }
@ -70,15 +55,38 @@ int TExternal_app::run(bool async, bool iconized)
} }
if (_exitcode == 0) if (_exitcode == 0)
{ {
CURSOR oldcur = get_cursor(TASK_WIN);
set_cursor(TASK_WIN, CURSOR_WAIT); set_cursor(TASK_WIN, CURSOR_WAIT);
const UINT sh = iconized ? SW_SHOWMINIMIZED : SW_SHOW; const UINT sh = iconized ? SW_SHOWMINIMIZED : SW_SHOW;
_exitcode = WinExec((char*)(const char*)path, sh); _exitcode = WinExec((char*)(const char*)path, sh);
if (_exitcode >= 32) if (_exitcode >= 32)
{ {
if (!async) main_app().wait_for(_path); if (!async)
{
if (!iconized)
{
TTemp_window tw(TASK_WIN);
tw.iconize();
}
HTASK child = NULL;
TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
for (bool ok = TaskFirst(&te); ok; ok = TaskNext(&te))
if (te.hInst == (HINSTANCE)_exitcode) child = te.hTask;
CHECK(child, "Can't find child task");
while(TaskFindHandle(&te, child))
process_events();
if (!iconized)
{
TTemp_window tw(TASK_WIN);
tw.maximize();
xvt_statbar_refresh();
}
}
_exitcode = 0; _exitcode = 0;
} }
else else
@ -89,7 +97,7 @@ int TExternal_app::run(bool async, bool iconized)
error_box("Impossibile eseguire '%s':\nErrore %d", (const char*)_path, _exitcode); error_box("Impossibile eseguire '%s':\nErrore %d", (const char*)_path, _exitcode);
} }
set_cursor(TASK_WIN, CURSOR_ARROW); set_cursor(TASK_WIN, oldcur);
} }
#else #else

View File

@ -1211,9 +1211,8 @@ void TMask::send_key(KEY key, short to, TMask_field* from)
} }
else else
{ {
const int max = fields();
const int gr = -to; const int gr = -to;
for (int i = 0; i < max; i++) for (int i = 0; i < fields(); i++)
{ {
TMask_field& campo = fld(i); TMask_field& campo = fld(i);
if (campo.in_group(gr)) if (campo.in_group(gr))

View File

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.61 1994-12-15 18:06:23 guy Exp $ // $Id: maskfld.cpp,v 1.62 1994-12-16 15:49:54 guy Exp $
#include <xvt.h> #include <xvt.h>
#include <applicat.h> #include <applicat.h>
@ -452,7 +452,7 @@ void TMask_field::set_prompt(const char* p)
void TMask_field::set(const char* s) void TMask_field::set(const char* s)
{ {
if (mask().is_running()) if (mask().is_running())
{ {
set_window_data(s); set_window_data(s);

View File

@ -539,18 +539,25 @@ break;
break; break;
case XIE_SELECT: case XIE_SELECT:
if (xiev->v.xi_obj->type == XIT_ROW) if (xiev->v.xi_obj->type == XIT_ROW)
{ {
_check_enabled = FALSE;
const int oldrec = _cur_rec; const int oldrec = _cur_rec;
set_pos(xiev->v.select.xi_obj->v.row, xiev->v.select.column); set_pos(xiev->v.select.xi_obj->v.row, xiev->v.select.column);
if (oldrec != _cur_rec) if (oldrec != _cur_rec)
{ {
str2mask(_cur_rec); str2mask(_cur_rec);
_row_dirty = FALSE; _row_dirty = FALSE;
} }
_edit_field = col2field(_cur_col);
update(_cur_rec);
TMask_field* button = col2field(_cur_col);
notify_change(); notify_change();
_edit_field->on_hit(); button->on_hit();
mask2str(_cur_rec); mask2str(_cur_rec);
_check_enabled = TRUE;
} }
xiev->refused = TRUE; xiev->refused = TRUE;
break; break;
@ -714,7 +721,7 @@ break;
case K_F8: case K_F8:
case K_F9: case K_F9:
case K_F11: case K_F11:
if (_check_enabled) if (_check_enabled && active())
{ {
_check_enabled = FALSE; // Disable checks _check_enabled = FALSE; // Disable checks
notify_change(); notify_change();
@ -788,15 +795,27 @@ void TSpreadsheet::activate(bool on)
XI_OBJ** columns = xi_get_member_list(_list, &num); XI_OBJ** columns = xi_get_member_list(_list, &num);
xi_move_focus(_itf); // Set focus to interface xi_move_focus(_itf); // Set focus to interface
att = on ? (att | XI_ATR_TABWRAP) : (att & ~XI_ATR_TABWRAP); if (on)
att |= XI_ATR_TABWRAP;
else
att &= ~XI_ATR_TABWRAP;
xi_set_attrib(_list, att); xi_set_attrib(_list, att);
for (int col = 1; col < num; col++) for (int col = 1; col < num; col++)
{ {
XI_OBJ* column = columns[col]; XI_OBJ* column = columns[col];
att = xi_get_attrib(column); att = xi_get_attrib(column);
if (on) att &= ~XI_ATR_READONLY; if (on)
else att |= XI_ATR_READONLY; {
att &= ~XI_ATR_READONLY;
att |= XI_ATR_AUTOSELECT;
}
else
{
att |= XI_ATR_READONLY;
att &= ~XI_ATR_AUTOSELECT;
}
xi_set_attrib(column, att); // Set new attributes xi_set_attrib(column, att); // Set new attributes
} }
} }

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.39 1994-12-07 18:03:46 guy Exp $ // $Id: relapp.cpp,v 1.40 1994-12-16 15:50:08 guy Exp $
#include <mailbox.h> #include <mailbox.h>
#include <sheet.h> #include <sheet.h>
#include <urldefid.h> #include <urldefid.h>
@ -18,9 +18,8 @@ HIDDEN bool can_change_firm()
if (can == 2) if (can == 2)
{ {
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
TASKENTRY te; te.dwSize = sizeof(TASKENTRY);
HTASK ct = GetCurrentTask(); HTASK ct = GetCurrentTask();
TASKENTRY te;
te.dwSize = sizeof(TASKENTRY);
TaskFindHandle(&te, ct); TaskFindHandle(&te, ct);
TaskFindHandle(&te, te.hTaskParent); TaskFindHandle(&te, te.hTaskParent);
can = strcmp(te.szModule, "BA0") == 0; can = strcmp(te.szModule, "BA0") == 0;