2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fapplication.cpp - Manages the application events *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-01-02 20:38:45 +01:00
|
|
|
* Copyright 2013-2018 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The Final Cut is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* The Final Cut is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
#include <string>
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fapplication.h"
|
|
|
|
#include "final/fmenu.h"
|
2017-10-30 20:56:00 +01:00
|
|
|
#include "final/fmessagebox.h"
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fstatusbar.h"
|
|
|
|
#include "final/fwindow.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
namespace finalcut
|
|
|
|
{
|
|
|
|
|
2018-10-21 21:06:52 +02:00
|
|
|
// Global application object
|
2018-12-10 01:48:26 +01:00
|
|
|
static FApplication* app_object = nullptr;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-10-21 21:06:52 +02:00
|
|
|
// Flag to exit the local event loop
|
2015-05-23 13:35:12 +02:00
|
|
|
static bool app_exit_loop = false;
|
|
|
|
|
2018-10-21 21:06:52 +02:00
|
|
|
// Static attributes
|
2018-12-10 01:48:26 +01:00
|
|
|
FWidget* FWidget::main_widget = nullptr; // main application widget
|
|
|
|
FWidget* FWidget::active_window = nullptr; // the active window
|
|
|
|
FWidget* FWidget::focus_widget = nullptr; // has keyboard input focus
|
|
|
|
FWidget* FWidget::clicked_widget = nullptr; // is focused by click
|
|
|
|
FWidget* FWidget::open_menu = nullptr; // currently open menu
|
|
|
|
FWidget* FWidget::move_size_widget = nullptr; // move/size by keyboard
|
|
|
|
FWidget* FApplication::keyboard_widget = nullptr; // has the keyboard focus
|
|
|
|
FKeyboard* FApplication::keyboard = nullptr; // keyboard access
|
|
|
|
FMouseControl* FApplication::mouse = nullptr; // mouse control
|
2018-10-21 21:06:52 +02:00
|
|
|
int FApplication::loop_level = 0; // event loop level
|
|
|
|
int FApplication::quit_code = 0;
|
|
|
|
bool FApplication::quit_now = false;
|
2018-01-28 19:54:52 +01:00
|
|
|
|
2018-12-17 02:06:22 +01:00
|
|
|
FApplication::eventQueuePtr FApplication::event_queue = nullptr;
|
2018-01-28 19:54:52 +01:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FApplication
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// constructors and destructor
|
|
|
|
//----------------------------------------------------------------------
|
2017-09-11 03:06:02 +02:00
|
|
|
FApplication::FApplication ( const int& _argc
|
2017-03-26 20:40:04 +02:00
|
|
|
, char* _argv[]
|
|
|
|
, bool disable_alt_screen )
|
2018-10-24 00:16:45 +02:00
|
|
|
: FWidget(processParameters(_argc, _argv), disable_alt_screen)
|
2018-12-03 03:22:36 +01:00
|
|
|
, app_argc{_argc}
|
|
|
|
, app_argv{_argv}
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
assert ( ! app_object
|
2017-11-26 22:37:18 +01:00
|
|
|
&& "FApplication: There should be only one application object" );
|
2018-10-21 21:06:52 +02:00
|
|
|
app_object = this;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-08-21 21:27:44 +02:00
|
|
|
if ( ! (_argc && _argv) )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-12-17 01:06:53 +01:00
|
|
|
static char* empty = C_STR("");
|
2016-11-20 18:26:15 +01:00
|
|
|
app_argc = 0;
|
|
|
|
app_argv = static_cast<char**>(&empty);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2018-01-28 19:54:52 +01:00
|
|
|
init (key_timeout, dblclick_interval);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-09-11 03:06:02 +02:00
|
|
|
FApplication::~FApplication() // destructor
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-12-10 01:48:26 +01:00
|
|
|
app_object = nullptr;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
// public methods of FApplication
|
|
|
|
//----------------------------------------------------------------------
|
2018-10-21 21:06:52 +02:00
|
|
|
FWidget* FApplication::getApplicationObject()
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
return static_cast<FWidget*>(app_object);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FApplication::isQuit()
|
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
return ( app_object ) ? quit_now : true;
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FApplication::exec() // run
|
|
|
|
{
|
|
|
|
if ( quit_now )
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
quit_now = false;
|
|
|
|
quit_code = 0;
|
|
|
|
|
|
|
|
enter_loop();
|
|
|
|
return quit_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int FApplication::enter_loop() // event loop
|
|
|
|
{
|
|
|
|
bool old_app_exit_loop;
|
|
|
|
loop_level++;
|
|
|
|
quit_now = false;
|
|
|
|
|
|
|
|
old_app_exit_loop = app_exit_loop;
|
|
|
|
app_exit_loop = false;
|
|
|
|
|
|
|
|
while ( ! (quit_now || app_exit_loop) )
|
|
|
|
processNextEvent();
|
|
|
|
|
|
|
|
app_exit_loop = old_app_exit_loop;
|
|
|
|
loop_level--;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::exit_loop()
|
|
|
|
{
|
|
|
|
app_exit_loop = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::exit (int retcode)
|
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
if ( ! app_object ) // no global app object
|
2016-11-02 00:37:58 +01:00
|
|
|
return;
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
if ( quit_now ) // don't overwrite quit code
|
2016-11-02 00:37:58 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
quit_now = true;
|
|
|
|
quit_code = retcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::quit()
|
|
|
|
{
|
|
|
|
FApplication::exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-08-12 20:10:27 +02:00
|
|
|
bool FApplication::sendEvent ( const FObject* receiver
|
|
|
|
, const FEvent* event )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
if ( quit_now || app_exit_loop )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( ! receiver )
|
|
|
|
return false;
|
|
|
|
|
2017-06-11 17:47:50 +02:00
|
|
|
if ( ! receiver->isWidget() )
|
|
|
|
return false;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
const auto r_widget = static_cast<const FWidget*>(receiver);
|
|
|
|
auto widget = const_cast<FWidget*>(r_widget);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
if ( modal_dialogs > 0 )
|
|
|
|
{
|
2017-08-12 20:10:27 +02:00
|
|
|
const FWidget* window;
|
2018-12-15 00:50:09 +01:00
|
|
|
|
2016-11-02 00:37:58 +01:00
|
|
|
if ( widget->isWindowWidget() )
|
|
|
|
window = widget;
|
|
|
|
else
|
|
|
|
window = FWindow::getWindowWidget(widget);
|
|
|
|
|
|
|
|
// block events for widgets in non modal windows
|
|
|
|
if ( window
|
2018-11-04 23:00:06 +01:00
|
|
|
&& ! window->getFlags().modal
|
2017-11-26 22:37:18 +01:00
|
|
|
&& ! window->isMenuWidget() )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
switch ( event->type() )
|
|
|
|
{
|
|
|
|
case fc::KeyPress_Event:
|
|
|
|
case fc::KeyUp_Event:
|
|
|
|
case fc::KeyDown_Event:
|
|
|
|
case fc::MouseDown_Event:
|
|
|
|
case fc::MouseUp_Event:
|
|
|
|
case fc::MouseDoubleClick_Event:
|
|
|
|
case fc::MouseWheel_Event:
|
|
|
|
case fc::MouseMove_Event:
|
|
|
|
case fc::FocusIn_Event:
|
|
|
|
case fc::FocusOut_Event:
|
|
|
|
case fc::Accelerator_Event:
|
|
|
|
return false;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-12 20:10:27 +02:00
|
|
|
// Throw away mouse events for disabled widgets
|
2016-12-18 23:34:11 +01:00
|
|
|
if ( event->type() >= fc::MouseDown_Event
|
2017-11-26 22:37:18 +01:00
|
|
|
&& event->type() <= fc::MouseMove_Event
|
|
|
|
&& ! widget->isEnabled() )
|
2016-11-02 00:37:58 +01:00
|
|
|
return false;
|
|
|
|
|
2017-08-12 20:10:27 +02:00
|
|
|
// For access to a protected base class member
|
2018-12-15 00:50:09 +01:00
|
|
|
auto const_w = static_cast<const FApplication*>(widget);
|
|
|
|
auto w = const_cast<FApplication*>(const_w);
|
2017-09-11 03:06:02 +02:00
|
|
|
|
2017-08-12 20:10:27 +02:00
|
|
|
// Sends event event directly to receiver
|
|
|
|
return w->event(const_cast<FEvent*>(event));
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-08-12 20:10:27 +02:00
|
|
|
void FApplication::queueEvent ( const FObject* receiver
|
|
|
|
, const FEvent* event )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
if ( ! receiver )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// queue this event
|
2018-12-17 02:06:22 +01:00
|
|
|
eventPair send_event (receiver, std::make_shared<const FEvent>(*event));
|
|
|
|
event_queue->push_back(send_event);
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::sendQueuedEvents()
|
|
|
|
{
|
2018-12-17 02:06:22 +01:00
|
|
|
while ( eventInQueue() )
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2018-12-17 02:06:22 +01:00
|
|
|
sendEvent( event_queue->front().first,
|
|
|
|
event_queue->front().second.get() );
|
|
|
|
event_queue->pop_front();
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FApplication::eventInQueue()
|
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
if ( app_object )
|
2016-11-02 00:37:58 +01:00
|
|
|
return ( ! event_queue->empty() );
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-08-12 20:10:27 +02:00
|
|
|
bool FApplication::removeQueuedEvent (const FObject* receiver)
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
|
|
|
bool retval;
|
|
|
|
|
|
|
|
if ( ! eventInQueue() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( ! receiver )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
retval = false;
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = event_queue->begin();
|
2016-11-02 00:37:58 +01:00
|
|
|
|
|
|
|
while ( iter != event_queue->end() )
|
|
|
|
{
|
|
|
|
if ( iter->first == receiver )
|
|
|
|
{
|
|
|
|
iter = event_queue->erase(iter);
|
|
|
|
retval = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-11-18 02:34:41 +01:00
|
|
|
FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
2016-11-02 00:37:58 +01:00
|
|
|
{
|
2017-09-19 06:18:03 +02:00
|
|
|
if ( argc > 0 && argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
2017-11-26 22:37:18 +01:00
|
|
|
|| std::strcmp(argv[1], "-h") == 0 ) )
|
2017-09-19 06:18:03 +02:00
|
|
|
{
|
2017-11-18 02:34:41 +01:00
|
|
|
showParameterUsage();
|
2017-09-19 06:18:03 +02:00
|
|
|
}
|
|
|
|
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().setDefault();
|
2017-11-18 02:34:41 +01:00
|
|
|
cmd_options (argc, argv);
|
2017-09-19 06:18:03 +02:00
|
|
|
return 0;
|
2016-11-02 00:37:58 +01:00
|
|
|
}
|
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::showParameterUsage()
|
|
|
|
{
|
|
|
|
std::cout \
|
2018-10-09 20:21:43 +02:00
|
|
|
<< "Generic options:\n"
|
2017-11-18 02:34:41 +01:00
|
|
|
<< " -h, --help "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Display this help and exit\n"
|
|
|
|
<< "\n"
|
|
|
|
<< "The Final Cut options:\n"
|
2017-11-18 02:34:41 +01:00
|
|
|
<< " --encoding <name> "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Sets the character encoding mode\n"
|
2017-11-18 02:34:41 +01:00
|
|
|
<< " "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " {utf8, vt100, pc, ascii}\n"
|
2018-06-17 23:25:32 +02:00
|
|
|
<< " --no-mouse "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Disable mouse support\n"
|
2017-11-18 02:34:41 +01:00
|
|
|
<< " --no-optimized-cursor "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Disable cursor optimization\n"
|
2017-11-18 02:34:41 +01:00
|
|
|
<< " --no-terminal-detection"
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Disable terminal detection\n"
|
2017-11-18 02:34:41 +01:00
|
|
|
<< " --no-color-change "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Do not redefine the color palette\n"
|
2017-11-18 02:34:41 +01:00
|
|
|
<< " --vgafont "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Set the standard vga 8x16 font\n"
|
2017-11-18 02:34:41 +01:00
|
|
|
<< " --newfont "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Enables the graphical font\n"
|
2018-06-17 23:25:32 +02:00
|
|
|
|
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
2018-10-09 20:21:43 +02:00
|
|
|
<< "\n"
|
|
|
|
<< "FreeBSD console options:\n"
|
2018-06-17 23:25:32 +02:00
|
|
|
<< " --no-esc-for-alt-meta "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Do not send a ESC prefix for the alt/meta key\n"
|
2018-06-17 23:25:32 +02:00
|
|
|
<< " --no-cursorstyle-change"
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Do not change the current cursor style\n"
|
2018-10-08 04:14:20 +02:00
|
|
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
2018-10-09 20:21:43 +02:00
|
|
|
<< "\n"
|
|
|
|
<< "NetBSD/OpenBSD console options:\n"
|
2018-06-17 23:25:32 +02:00
|
|
|
<< " --no-esc-for-alt-meta "
|
2018-10-09 20:21:43 +02:00
|
|
|
<< " Do not send a ESC prefix for the alt/meta key\n"
|
2018-06-17 23:25:32 +02:00
|
|
|
#endif
|
|
|
|
|
2018-10-11 03:46:37 +02:00
|
|
|
<< std::endl; // newline character + flushes the output stream
|
2017-11-18 02:34:41 +01:00
|
|
|
std::exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:56:00 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
|
|
|
{
|
|
|
|
int ret = FMessageBox::info ( w, "Quit"
|
|
|
|
, "Do you really want\n"
|
|
|
|
"to quit the program ?"
|
|
|
|
, FMessageBox::Yes
|
|
|
|
, FMessageBox::No );
|
|
|
|
if ( ret == FMessageBox::Yes )
|
|
|
|
ev->accept();
|
|
|
|
else
|
|
|
|
ev->ignore();
|
|
|
|
}
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
// private methods of FApplication
|
|
|
|
//----------------------------------------------------------------------
|
2018-02-18 21:49:58 +01:00
|
|
|
void FApplication::init (long key_time, long dblclick_time)
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
// Initialize keyboard
|
|
|
|
keyboard = getKeyboard();
|
2016-10-11 04:57:36 +02:00
|
|
|
|
2018-01-28 19:54:52 +01:00
|
|
|
// Set the keyboard keypress timeout
|
2018-07-15 19:52:59 +02:00
|
|
|
if ( keyboard )
|
|
|
|
{
|
|
|
|
FKeyboardCommand key_cmd1 (this, &FApplication::keyPressed);
|
|
|
|
FKeyboardCommand key_cmd2 (this, &FApplication::keyReleased);
|
|
|
|
FKeyboardCommand key_cmd3 (this, &FApplication::escapeKeyPressed);
|
|
|
|
keyboard->setPressCommand (key_cmd1);
|
|
|
|
keyboard->setReleaseCommand (key_cmd2);
|
|
|
|
keyboard->setEscPressedCommand (key_cmd3);
|
|
|
|
keyboard->setKeypressTimeout (key_time);
|
|
|
|
}
|
2018-01-28 19:54:52 +01:00
|
|
|
|
|
|
|
// Initialize mouse control
|
|
|
|
mouse = getMouseControl();
|
|
|
|
|
|
|
|
// Set stdin number for a gpm-mouse
|
|
|
|
if ( mouse )
|
2018-05-02 12:31:21 +02:00
|
|
|
mouse->setStdinNo (FTermios::getStdIn());
|
2018-01-14 21:21:08 +01:00
|
|
|
|
2018-01-28 19:54:52 +01:00
|
|
|
// Set the default double click interval
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse )
|
2018-02-18 21:49:58 +01:00
|
|
|
mouse->setDblclickInterval (dblclick_time);
|
2016-10-11 04:57:36 +02:00
|
|
|
|
2017-08-12 22:55:29 +02:00
|
|
|
try
|
|
|
|
{
|
2018-12-17 02:06:22 +01:00
|
|
|
event_queue = std::make_shared<eventQueue>();
|
2017-08-12 22:55:29 +02:00
|
|
|
}
|
|
|
|
catch (const std::bad_alloc& ex)
|
|
|
|
{
|
2018-11-22 21:51:32 +01:00
|
|
|
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
2017-08-12 22:55:29 +02:00
|
|
|
std::abort();
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-28 22:43:14 +02:00
|
|
|
//----------------------------------------------------------------------
|
2017-11-18 02:34:41 +01:00
|
|
|
void FApplication::cmd_options (const int& argc, char* argv[])
|
2016-08-28 22:43:14 +02:00
|
|
|
{
|
2018-01-28 19:54:52 +01:00
|
|
|
// Interpret the command line options
|
2016-08-28 22:43:14 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
while ( true )
|
|
|
|
{
|
|
|
|
int c, idx = 0;
|
2017-10-02 07:32:33 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
2017-12-17 01:06:53 +01:00
|
|
|
{C_STR("encoding"), required_argument, 0, 0 },
|
2018-06-17 23:25:32 +02:00
|
|
|
{C_STR("no-mouse"), no_argument, 0, 0 },
|
2017-12-17 01:06:53 +01:00
|
|
|
{C_STR("no-optimized-cursor"), no_argument, 0, 0 },
|
|
|
|
{C_STR("no-terminal-detection"), no_argument, 0, 0 },
|
|
|
|
{C_STR("no-color-change"), no_argument, 0, 0 },
|
|
|
|
{C_STR("vgafont"), no_argument, 0, 0 },
|
|
|
|
{C_STR("newfont"), no_argument, 0, 0 },
|
2018-06-17 23:25:32 +02:00
|
|
|
|
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
|
|
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
|
|
|
|
{C_STR("no-cursorstyle-change"), no_argument, 0, 0 },
|
2018-10-08 04:14:20 +02:00
|
|
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
2018-06-17 23:25:32 +02:00
|
|
|
{C_STR("no-esc-for-alt-meta"), no_argument, 0, 0 },
|
|
|
|
#endif
|
|
|
|
|
2017-12-17 01:06:53 +01:00
|
|
|
{0, 0, 0, 0 }
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
2017-10-02 07:32:33 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
opterr = 0;
|
2018-06-17 23:25:32 +02:00
|
|
|
c = getopt_long (argc, argv, "", long_options, &idx);
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( c == -1 )
|
|
|
|
break;
|
2015-09-24 00:41:43 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( c == 0 )
|
|
|
|
{
|
2016-10-06 23:15:09 +02:00
|
|
|
if ( std::strcmp(long_options[idx].name, "encoding") == 0 )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
|
|
|
FString encoding(optarg);
|
2018-01-02 20:38:45 +01:00
|
|
|
encoding = encoding.toLower();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-01-02 20:38:45 +01:00
|
|
|
if ( encoding.includes("utf8") )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().encoding = fc::UTF8;
|
2018-01-02 20:38:45 +01:00
|
|
|
else if ( encoding.includes("vt100") )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().encoding = fc::VT100;
|
2018-01-02 20:38:45 +01:00
|
|
|
else if ( encoding.includes("pc") )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().encoding = fc::PC;
|
2018-01-02 20:38:45 +01:00
|
|
|
else if ( encoding.includes("ascii") )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().encoding = fc::ASCII;
|
2018-01-02 20:38:45 +01:00
|
|
|
else if ( encoding.includes("help") )
|
2017-11-18 02:34:41 +01:00
|
|
|
showParameterUsage();
|
2016-08-28 22:43:14 +02:00
|
|
|
else
|
2017-11-18 02:34:41 +01:00
|
|
|
exitWithMessage ( "Unknown encoding "
|
|
|
|
+ std::string(encoding.c_str()) );
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2015-12-21 18:37:20 +01:00
|
|
|
|
2018-06-17 23:25:32 +02:00
|
|
|
if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().mouse_support = false;
|
2018-06-17 23:25:32 +02:00
|
|
|
|
2016-11-27 00:41:34 +01:00
|
|
|
if ( std::strcmp(long_options[idx].name, "no-optimized-cursor") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().cursor_optimisation = false;
|
2015-12-21 18:37:20 +01:00
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
if ( std::strcmp(long_options[idx].name, "no-terminal-detection") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().terminal_detection = false;
|
2016-08-28 22:43:14 +02:00
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
if ( std::strcmp(long_options[idx].name, "no-color-change") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().color_change = false;
|
2015-12-21 18:37:20 +01:00
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
if ( std::strcmp(long_options[idx].name, "vgafont") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().vgafont = true;
|
2016-08-28 22:43:14 +02:00
|
|
|
|
2017-11-18 02:34:41 +01:00
|
|
|
if ( std::strcmp(long_options[idx].name, "newfont") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().newfont = true;
|
2018-06-17 23:25:32 +02:00
|
|
|
|
|
|
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
|
|
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().meta_sends_escape = false;
|
2018-06-17 23:25:32 +02:00
|
|
|
|
|
|
|
if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().change_cursorstyle = false;
|
2018-10-08 04:14:20 +02:00
|
|
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
2018-06-17 23:25:32 +02:00
|
|
|
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
2018-10-29 00:45:45 +01:00
|
|
|
getInitValues().meta_sends_escape = false;
|
2018-06-17 23:25:32 +02:00
|
|
|
#endif
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-07-15 19:52:59 +02:00
|
|
|
inline void FApplication::findKeyboardWidget()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
// Find the widget that has the keyboard focus
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-12-10 01:48:26 +01:00
|
|
|
FWidget* widget = nullptr;
|
2018-12-15 00:50:09 +01:00
|
|
|
auto focus = getFocusWidget();
|
|
|
|
auto move_size = getMoveSizeWidget();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( focus )
|
2016-09-30 04:55:28 +02:00
|
|
|
{
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( move_size )
|
|
|
|
widget = move_size;
|
2016-09-30 04:55:28 +02:00
|
|
|
else
|
2018-12-01 21:28:25 +01:00
|
|
|
widget = focus;
|
2016-09-30 04:55:28 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
else
|
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
widget = getMainWidget();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-11-26 15:18:44 +01:00
|
|
|
if ( widget && widget->numOfChildren() >= 1 )
|
2015-05-23 13:35:12 +02:00
|
|
|
widget->focusFirstChild();
|
|
|
|
}
|
|
|
|
|
2018-07-15 19:52:59 +02:00
|
|
|
keyboard_widget = widget;
|
2017-12-05 23:55:12 +01:00
|
|
|
}
|
|
|
|
|
2018-01-28 19:54:52 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-07-15 19:52:59 +02:00
|
|
|
inline bool FApplication::isKeyPressed()
|
2018-01-28 19:54:52 +01:00
|
|
|
{
|
|
|
|
if ( mouse && mouse->isGpmMouseEnabled() )
|
2018-07-15 19:52:59 +02:00
|
|
|
return mouse->getGpmKeyPressed(keyboard->unprocessedInput());
|
2018-01-28 19:54:52 +01:00
|
|
|
|
2018-07-15 19:52:59 +02:00
|
|
|
return keyboard->isKeyPressed();
|
2018-01-28 19:54:52 +01:00
|
|
|
}
|
|
|
|
|
2017-12-05 23:55:12 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-07-15 19:52:59 +02:00
|
|
|
void FApplication::keyPressed()
|
2017-12-05 23:55:12 +01:00
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
performKeyboardAction();
|
2017-12-05 23:55:12 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-05 23:55:12 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-07-15 19:52:59 +02:00
|
|
|
void FApplication::keyReleased()
|
2017-12-05 23:55:12 +01:00
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
sendKeyUpEvent (keyboard_widget);
|
|
|
|
}
|
2018-01-28 19:54:52 +01:00
|
|
|
|
2018-07-15 19:52:59 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::escapeKeyPressed()
|
|
|
|
{
|
|
|
|
sendEscapeKeyPressEvent();
|
2018-01-28 19:54:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-07-15 19:52:59 +02:00
|
|
|
inline void FApplication::performKeyboardAction()
|
2018-01-28 19:54:52 +01:00
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
switch ( keyboard->getKey() )
|
2018-01-28 19:54:52 +01:00
|
|
|
{
|
|
|
|
case fc::Fckey_l: // Ctrl-L (redraw the screen)
|
|
|
|
redraw();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_mouse:
|
|
|
|
if ( mouse )
|
|
|
|
{
|
2018-10-11 03:46:37 +02:00
|
|
|
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
|
|
|
|
mouse->setRawData (FMouse::x11, buffer);
|
2018-07-15 19:52:59 +02:00
|
|
|
keyboard->unprocessedInput() = mouse->isInputDataPending();
|
2018-01-28 19:54:52 +01:00
|
|
|
processMouseEvent();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_extended_mouse:
|
|
|
|
if ( mouse )
|
|
|
|
{
|
2018-10-11 03:46:37 +02:00
|
|
|
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
|
|
|
|
mouse->setRawData (FMouse::sgr, buffer);
|
2018-07-15 19:52:59 +02:00
|
|
|
keyboard->unprocessedInput() = mouse->isInputDataPending();
|
2018-01-28 19:54:52 +01:00
|
|
|
processMouseEvent();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case fc::Fkey_urxvt_mouse:
|
|
|
|
if ( mouse )
|
|
|
|
{
|
2018-10-11 03:46:37 +02:00
|
|
|
FKeyboard::keybuffer& buffer = keyboard->getKeyBuffer();
|
|
|
|
mouse->setRawData (FMouse::urxvt, buffer);
|
2018-07-15 19:52:59 +02:00
|
|
|
keyboard->unprocessedInput() = mouse->isInputDataPending();
|
2018-01-28 19:54:52 +01:00
|
|
|
processMouseEvent();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-07-15 19:52:59 +02:00
|
|
|
bool acceptKeyDown = sendKeyDownEvent (keyboard_widget);
|
|
|
|
bool acceptKeyPress = sendKeyPressEvent (keyboard_widget);
|
2018-01-28 19:54:52 +01:00
|
|
|
|
|
|
|
if ( ! (acceptKeyDown || acceptKeyPress) )
|
|
|
|
sendKeyboardAccelerator();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2017-12-05 23:55:12 +01:00
|
|
|
}
|
2016-10-11 04:57:36 +02:00
|
|
|
|
2017-12-05 23:55:12 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-07-15 19:52:59 +02:00
|
|
|
inline void FApplication::sendEscapeKeyPressEvent()
|
2017-12-05 23:55:12 +01:00
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
// Send an escape key press event
|
|
|
|
FKeyEvent k_press_ev (fc::KeyPress_Event, fc::Fkey_escape);
|
|
|
|
sendEvent (keyboard_widget, &k_press_ev);
|
2017-12-05 23:55:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FApplication::sendKeyDownEvent (FWidget* widget)
|
|
|
|
{
|
|
|
|
// Send key down event
|
2018-07-15 19:52:59 +02:00
|
|
|
FKeyEvent k_down_ev (fc::KeyDown_Event, keyboard->getKey());
|
2017-12-05 23:55:12 +01:00
|
|
|
sendEvent (widget, &k_down_ev);
|
|
|
|
return k_down_ev.isAccepted();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FApplication::sendKeyPressEvent (FWidget* widget)
|
|
|
|
{
|
|
|
|
// Send key press event
|
2018-07-15 19:52:59 +02:00
|
|
|
FKeyEvent k_press_ev (fc::KeyPress_Event, keyboard->getKey());
|
2017-12-05 23:55:12 +01:00
|
|
|
sendEvent (widget, &k_press_ev);
|
|
|
|
return k_press_ev.isAccepted();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline bool FApplication::sendKeyUpEvent (FWidget* widget)
|
|
|
|
{
|
|
|
|
// Send key up event
|
2018-07-15 19:52:59 +02:00
|
|
|
FKeyEvent k_up_ev (fc::KeyUp_Event, keyboard->getKey());
|
2017-12-05 23:55:12 +01:00
|
|
|
sendEvent (widget, &k_up_ev);
|
|
|
|
return k_up_ev.isAccepted();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline void FApplication::sendKeyboardAccelerator()
|
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
if ( getOpenMenu() )
|
2017-12-05 23:55:12 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Switch to a specific dialog with Meta + 1..9
|
|
|
|
bool accpt = processDialogSwitchAccelerator();
|
|
|
|
|
|
|
|
// Windows keyboard accelerator
|
|
|
|
if ( ! accpt )
|
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto window = static_cast<const FWidget*>(getActiveWindow());
|
2017-12-05 23:55:12 +01:00
|
|
|
|
|
|
|
if ( window )
|
|
|
|
accpt = processAccelerator (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Global keyboard accelerator
|
|
|
|
if ( ! accpt )
|
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto root_widget = static_cast<const FWidget*>(getRootWidget());
|
2017-12-05 23:55:12 +01:00
|
|
|
|
|
|
|
if ( root_widget )
|
|
|
|
processAccelerator (root_widget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::processKeyboardEvent()
|
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
if ( quit_now || app_exit_loop )
|
|
|
|
return;
|
|
|
|
|
|
|
|
findKeyboardWidget();
|
2017-12-05 23:55:12 +01:00
|
|
|
flush_out();
|
2018-07-22 23:07:49 +02:00
|
|
|
keyboard->clearKeyBufferOnTimeout();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-07-15 19:52:59 +02:00
|
|
|
if ( isKeyPressed() )
|
|
|
|
keyboard->fetchKeyCode();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
// special case: Esc key
|
2018-07-15 19:52:59 +02:00
|
|
|
keyboard->escapeKeyHandling();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
2016-07-16 20:39:38 +02:00
|
|
|
//----------------------------------------------------------------------
|
2016-07-24 20:18:23 +02:00
|
|
|
bool FApplication::processDialogSwitchAccelerator()
|
2016-07-16 20:39:38 +02:00
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
if ( keyboard->getKey() >= fc::Fmkey_1
|
|
|
|
&& keyboard->getKey() <= fc::Fmkey_9 )
|
2016-07-16 20:39:38 +02:00
|
|
|
{
|
2018-11-21 20:07:08 +01:00
|
|
|
FKey key = keyboard->getKey();
|
|
|
|
std::size_t n = key - fc::Fmkey_0;
|
|
|
|
std::size_t s = dialog_list->size();
|
2016-07-16 20:39:38 +02:00
|
|
|
|
|
|
|
if ( s > 0 && s >= n )
|
|
|
|
{
|
2016-09-30 04:55:28 +02:00
|
|
|
// unset the move/size mode
|
2018-12-15 00:50:09 +01:00
|
|
|
auto move_size = getMoveSizeWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( move_size )
|
2016-10-02 21:26:25 +02:00
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto w = move_size;
|
2018-10-21 21:06:52 +02:00
|
|
|
setMoveSizeWidget(0);
|
2016-10-02 21:26:25 +02:00
|
|
|
w->redraw();
|
|
|
|
}
|
|
|
|
|
2018-10-21 21:06:52 +02:00
|
|
|
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
2017-08-27 09:50:30 +02:00
|
|
|
sendEvent (dialog_list->at(n - 1), &a_ev);
|
2016-07-24 20:18:23 +02:00
|
|
|
return true;
|
2016-07-16 20:39:38 +02:00
|
|
|
}
|
|
|
|
}
|
2016-07-24 20:18:23 +02:00
|
|
|
|
|
|
|
return false;
|
2016-07-16 20:39:38 +02:00
|
|
|
}
|
|
|
|
|
2016-07-12 23:35:33 +02:00
|
|
|
//----------------------------------------------------------------------
|
2017-08-12 20:10:27 +02:00
|
|
|
bool FApplication::processAccelerator (const FWidget*& widget)
|
2016-07-12 23:35:33 +02:00
|
|
|
{
|
2016-07-24 20:18:23 +02:00
|
|
|
bool accpt = false;
|
|
|
|
|
2016-07-12 23:35:33 +02:00
|
|
|
if ( widget
|
2017-11-26 22:37:18 +01:00
|
|
|
&& widget->accelerator_list
|
|
|
|
&& ! widget->accelerator_list->empty() )
|
2016-07-12 23:35:33 +02:00
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = widget->accelerator_list->begin();
|
|
|
|
auto last = widget->accelerator_list->end();
|
2016-07-12 23:35:33 +02:00
|
|
|
|
2017-09-17 01:50:41 +02:00
|
|
|
while ( iter != last )
|
2016-07-12 23:35:33 +02:00
|
|
|
{
|
|
|
|
if ( quit_now || app_exit_loop )
|
|
|
|
break;
|
|
|
|
|
2018-07-15 19:52:59 +02:00
|
|
|
if ( iter->key == keyboard->getKey() )
|
2016-07-12 23:35:33 +02:00
|
|
|
{
|
2016-09-30 04:55:28 +02:00
|
|
|
// unset the move/size mode
|
2018-12-15 00:50:09 +01:00
|
|
|
auto move_size = getMoveSizeWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( move_size )
|
2016-10-02 21:26:25 +02:00
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto w = move_size;
|
2018-10-21 21:06:52 +02:00
|
|
|
setMoveSizeWidget(0);
|
2016-10-02 21:26:25 +02:00
|
|
|
w->redraw();
|
|
|
|
}
|
|
|
|
|
2018-10-21 21:06:52 +02:00
|
|
|
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
2016-07-12 23:35:33 +02:00
|
|
|
sendEvent (iter->object, &a_ev);
|
2016-07-24 20:18:23 +02:00
|
|
|
accpt = a_ev.isAccepted();
|
2016-07-12 23:35:33 +02:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
2016-07-24 20:18:23 +02:00
|
|
|
|
|
|
|
return accpt;
|
2016-07-12 23:35:33 +02:00
|
|
|
}
|
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
2017-12-05 01:03:59 +01:00
|
|
|
bool FApplication::getMouseEvent()
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-01-14 21:21:08 +01:00
|
|
|
bool mouse_event_occurred = false;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse && mouse->hasData() )
|
2015-08-10 00:16:26 +02:00
|
|
|
{
|
2018-07-15 19:52:59 +02:00
|
|
|
struct timeval* time_keypressed = keyboard->getKeyPressedTime();
|
|
|
|
mouse->processEvent (time_keypressed);
|
|
|
|
keyboard->unprocessedInput() = mouse->isInputDataPending();
|
2018-01-14 21:21:08 +01:00
|
|
|
mouse_event_occurred = mouse->hasEvent();
|
2015-08-10 00:16:26 +02:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
return mouse_event_occurred;
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FWidget*& FApplication::determineClickedWidget()
|
|
|
|
{
|
2018-12-01 21:28:25 +01:00
|
|
|
FWidget*& clicked = getClickedWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( clicked )
|
|
|
|
return clicked;
|
2017-12-05 01:03:59 +01:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse )
|
2018-12-01 21:28:25 +01:00
|
|
|
return clicked;
|
2018-01-14 21:21:08 +01:00
|
|
|
|
|
|
|
if ( ! mouse->isLeftButtonPressed()
|
|
|
|
&& ! mouse->isLeftButtonDoubleClick()
|
|
|
|
&& ! mouse->isRightButtonPressed()
|
|
|
|
&& ! mouse->isMiddleButtonPressed()
|
|
|
|
&& ! mouse->isWheelUp()
|
|
|
|
&& ! mouse->isWheelDown() )
|
2018-12-01 21:28:25 +01:00
|
|
|
return clicked;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
const FPoint& mouse_position = mouse->getPos();
|
2016-10-13 02:16:51 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
// Determine the window object on the current click position
|
2018-12-15 00:50:09 +01:00
|
|
|
auto window = FWindow::getWindowWidgetAt (mouse_position);
|
2017-12-05 01:03:59 +01:00
|
|
|
|
|
|
|
if ( window )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-12-05 01:03:59 +01:00
|
|
|
// Determine the widget at the current click position
|
2018-12-15 00:50:09 +01:00
|
|
|
auto child = childWidgetAt (window, mouse_position);
|
2018-12-01 21:28:25 +01:00
|
|
|
clicked = ( child != 0 ) ? child : window;
|
|
|
|
setClickedWidget (clicked);
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
return clicked;
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::unsetMoveSizeMode()
|
|
|
|
{
|
|
|
|
// Unset the move/size mode
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto move_size = getMoveSizeWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( move_size )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto w = move_size;
|
2018-10-21 21:06:52 +02:00
|
|
|
setMoveSizeWidget(0);
|
2017-12-05 01:03:59 +01:00
|
|
|
w->redraw();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
2015-10-10 03:14:14 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::closeOpenMenu()
|
|
|
|
{
|
|
|
|
// Close the open menu
|
2015-10-23 00:24:20 +02:00
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto openmenu = getOpenMenu();
|
|
|
|
auto menu = static_cast<FMenu*>(openmenu);
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( ! openmenu || ( mouse && mouse->isMoved()) )
|
2017-12-05 01:03:59 +01:00
|
|
|
return;
|
2016-08-20 22:27:23 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse )
|
|
|
|
{
|
|
|
|
const FPoint& mouse_position = mouse->getPos();
|
|
|
|
|
|
|
|
if ( menu->containsMenuStructure(mouse_position) )
|
|
|
|
return;
|
|
|
|
}
|
2015-11-08 21:50:41 +01:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
bool is_window_menu;
|
2018-12-15 00:50:09 +01:00
|
|
|
auto super = menu->getSuperMenu();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
if ( super && menu->isWindowsMenu(super) )
|
|
|
|
is_window_menu = true;
|
|
|
|
else
|
|
|
|
is_window_menu = false;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
menu->unselectItem();
|
|
|
|
menu->hide();
|
|
|
|
menu->hideSubMenus();
|
|
|
|
menu->hideSuperMenus();
|
2015-10-23 00:24:20 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
// No widget was been clicked and the menu is no dialog menu
|
2018-10-21 21:06:52 +02:00
|
|
|
if ( ! (getClickedWidget() || is_window_menu) )
|
2018-10-29 00:45:45 +01:00
|
|
|
FWindow::switchToPrevWindow(this);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
if ( getStatusBar() )
|
|
|
|
getStatusBar()->drawMessage();
|
2016-06-19 20:32:03 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::unselectMenubarItems()
|
|
|
|
{
|
|
|
|
// Unselect the menu bar items
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto openmenu = getOpenMenu();
|
|
|
|
auto menu_bar = getMenuBar();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( openmenu || (mouse && mouse->isMoved()) )
|
2017-12-05 01:03:59 +01:00
|
|
|
return;
|
2015-11-05 23:25:21 +01:00
|
|
|
|
2018-09-02 03:57:57 +02:00
|
|
|
if ( ! menu_bar )
|
2017-12-05 01:03:59 +01:00
|
|
|
return;
|
|
|
|
|
2018-09-02 03:57:57 +02:00
|
|
|
if ( ! menu_bar->hasSelectedItem() )
|
2017-12-05 01:03:59 +01:00
|
|
|
return;
|
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse )
|
|
|
|
return;
|
|
|
|
|
|
|
|
const FPoint& mouse_position = mouse->getPos();
|
2017-12-05 01:03:59 +01:00
|
|
|
|
|
|
|
if ( ! getMenuBar()->getTermGeometry().contains(mouse_position) )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2017-12-05 01:03:59 +01:00
|
|
|
if ( getStatusBar() )
|
|
|
|
getStatusBar()->clearMessage();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
getMenuBar()->resetMenu();
|
|
|
|
getMenuBar()->redraw();
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
// No widget was been clicked
|
2018-10-21 21:06:52 +02:00
|
|
|
if ( ! getClickedWidget() )
|
2018-10-29 00:45:45 +01:00
|
|
|
FWindow::switchToPrevWindow(this);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
if ( getStatusBar() )
|
|
|
|
getStatusBar()->drawMessage();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
updateTerminal();
|
|
|
|
flush_out();
|
|
|
|
}
|
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::sendMouseEvent()
|
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto clicked = getClickedWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
if ( ! clicked )
|
2017-12-05 01:03:59 +01:00
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse )
|
|
|
|
return;
|
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
FPoint widgetMousePos;
|
2018-01-14 21:21:08 +01:00
|
|
|
const FPoint& mouse_position = mouse->getPos();
|
2017-12-05 01:03:59 +01:00
|
|
|
int key_state = 0;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isShiftKeyPressed() )
|
2017-12-05 01:03:59 +01:00
|
|
|
key_state |= fc::ShiftButton;
|
2016-07-25 23:50:57 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isControlKeyPressed() )
|
2017-12-05 01:03:59 +01:00
|
|
|
key_state |= fc::ControlButton;
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isMetaKeyPressed() )
|
|
|
|
key_state |= fc::MetaButton;
|
|
|
|
|
2018-12-01 21:28:25 +01:00
|
|
|
widgetMousePos = clicked->termToWidgetPos(mouse_position);
|
2016-07-25 23:50:57 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isMoved() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
sendMouseMoveEvent (widgetMousePos, mouse_position, key_state);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sendMouseLeftClickEvent (widgetMousePos, mouse_position, key_state);
|
|
|
|
sendMouseRightClickEvent (widgetMousePos, mouse_position, key_state);
|
|
|
|
sendMouseMiddleClickEvent (widgetMousePos, mouse_position, key_state);
|
|
|
|
}
|
2016-07-25 23:50:57 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
sendWheelEvent (widgetMousePos, mouse_position);
|
2018-01-14 21:21:08 +01:00
|
|
|
mouse->clearEvent();
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::sendMouseMoveEvent ( const FPoint& widgetMousePos
|
|
|
|
, const FPoint& mouse_position
|
|
|
|
, int key_state )
|
|
|
|
{
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse )
|
|
|
|
return;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto clicked = getClickedWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isLeftButtonPressed() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_down_ev ( fc::MouseMove_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::LeftButton | key_state );
|
2018-12-01 21:28:25 +01:00
|
|
|
sendEvent (clicked, &m_down_ev);
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isRightButtonPressed() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_down_ev ( fc::MouseMove_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::RightButton | key_state );
|
2018-12-01 21:28:25 +01:00
|
|
|
sendEvent (clicked, &m_down_ev);
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isMiddleButtonPressed() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_down_ev ( fc::MouseMove_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::MiddleButton | key_state );
|
2018-12-01 21:28:25 +01:00
|
|
|
sendEvent (clicked, &m_down_ev);
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::sendMouseLeftClickEvent ( const FPoint& widgetMousePos
|
|
|
|
, const FPoint& mouse_position
|
|
|
|
, int key_state )
|
|
|
|
{
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse )
|
|
|
|
return;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto clicked = getClickedWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isLeftButtonDoubleClick() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_dblclick_ev ( fc::MouseDoubleClick_Event
|
2016-09-25 23:53:48 +02:00
|
|
|
, widgetMousePos
|
2016-10-13 02:16:51 +02:00
|
|
|
, mouse_position
|
2017-12-05 01:03:59 +01:00
|
|
|
, fc::LeftButton | key_state );
|
2018-12-01 21:28:25 +01:00
|
|
|
sendEvent (clicked, &m_dblclick_ev);
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
2018-01-14 21:21:08 +01:00
|
|
|
else if ( mouse->isLeftButtonPressed() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_down_ev ( fc::MouseDown_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::LeftButton | key_state );
|
2018-12-01 21:28:25 +01:00
|
|
|
sendEvent (clicked, &m_down_ev);
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
2018-01-14 21:21:08 +01:00
|
|
|
else if ( mouse->isLeftButtonReleased() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_up_ev ( fc::MouseUp_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::LeftButton | key_state );
|
2018-12-15 00:50:09 +01:00
|
|
|
auto released_widget = clicked;
|
2017-12-05 01:03:59 +01:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse->isRightButtonPressed()
|
|
|
|
&& ! mouse->isMiddleButtonPressed() )
|
2018-10-21 21:06:52 +02:00
|
|
|
setClickedWidget(0);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
sendEvent (released_widget, &m_up_ev);
|
|
|
|
}
|
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::sendMouseRightClickEvent ( const FPoint& widgetMousePos
|
|
|
|
, const FPoint& mouse_position
|
|
|
|
, int key_state )
|
|
|
|
{
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse )
|
|
|
|
return;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto clicked = getClickedWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isRightButtonPressed() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_down_ev ( fc::MouseDown_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::RightButton | key_state );
|
2018-12-01 21:28:25 +01:00
|
|
|
sendEvent (clicked, &m_down_ev);
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
2018-01-14 21:21:08 +01:00
|
|
|
else if ( mouse->isRightButtonReleased() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_up_ev ( fc::MouseUp_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::RightButton | key_state );
|
2018-12-15 00:50:09 +01:00
|
|
|
auto released_widget = clicked;
|
2017-12-05 01:03:59 +01:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse->isLeftButtonPressed()
|
|
|
|
&& ! mouse->isMiddleButtonPressed() )
|
2018-10-21 21:06:52 +02:00
|
|
|
setClickedWidget(0);
|
2016-01-17 02:57:08 +01:00
|
|
|
|
2017-12-05 01:03:59 +01:00
|
|
|
sendEvent (released_widget, &m_up_ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
|
|
|
|
, const FPoint& mouse_position
|
|
|
|
, int key_state )
|
|
|
|
{
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse )
|
|
|
|
return;
|
2017-12-05 01:03:59 +01:00
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto clicked = getClickedWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isMiddleButtonPressed() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_down_ev ( fc::MouseDown_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::MiddleButton | key_state );
|
2018-12-01 21:28:25 +01:00
|
|
|
sendEvent (clicked, &m_down_ev);
|
2017-12-05 01:03:59 +01:00
|
|
|
|
|
|
|
// gnome-terminal sends no released on middle click
|
|
|
|
if ( isGnomeTerminal() )
|
2018-10-21 21:06:52 +02:00
|
|
|
setClickedWidget(0);
|
2017-12-05 01:03:59 +01:00
|
|
|
}
|
2018-01-14 21:21:08 +01:00
|
|
|
else if ( mouse->isMiddleButtonReleased() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FMouseEvent m_up_ev ( fc::MouseUp_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::MiddleButton | key_state );
|
2018-12-15 00:50:09 +01:00
|
|
|
auto released_widget = clicked;
|
2017-12-05 01:03:59 +01:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse->isLeftButtonPressed()
|
|
|
|
&& ! mouse->isRightButtonPressed() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2018-10-21 21:06:52 +02:00
|
|
|
setClickedWidget(0);
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2017-12-05 01:03:59 +01:00
|
|
|
|
|
|
|
sendEvent (released_widget, &m_up_ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
|
|
|
|
, const FPoint& mouse_position )
|
|
|
|
{
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( ! mouse )
|
|
|
|
return;
|
|
|
|
|
2018-12-15 00:50:09 +01:00
|
|
|
auto clicked = getClickedWidget();
|
2018-10-21 21:06:52 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isWheelUp() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FWheelEvent wheel_ev ( fc::MouseWheel_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::WheelUp );
|
2018-12-15 00:50:09 +01:00
|
|
|
auto scroll_over_widget = clicked;
|
2018-10-21 21:06:52 +02:00
|
|
|
setClickedWidget(0);
|
2017-12-05 01:03:59 +01:00
|
|
|
sendEvent(scroll_over_widget, &wheel_ev);
|
|
|
|
}
|
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse->isWheelDown() )
|
2017-12-05 01:03:59 +01:00
|
|
|
{
|
|
|
|
FWheelEvent wheel_ev ( fc::MouseWheel_Event
|
|
|
|
, widgetMousePos
|
|
|
|
, mouse_position
|
|
|
|
, fc::WheelDown );
|
2018-12-15 00:50:09 +01:00
|
|
|
auto scroll_over_widget = clicked;
|
2018-10-21 21:06:52 +02:00
|
|
|
setClickedWidget(0);
|
2017-12-05 01:03:59 +01:00
|
|
|
sendEvent (scroll_over_widget, &wheel_ev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::processMouseEvent()
|
|
|
|
{
|
|
|
|
if ( ! getMouseEvent() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
determineClickedWidget();
|
|
|
|
unsetMoveSizeMode();
|
|
|
|
closeOpenMenu();
|
|
|
|
unselectMenubarItems();
|
|
|
|
sendMouseEvent();
|
2015-08-11 00:11:07 +02:00
|
|
|
|
2018-01-14 21:21:08 +01:00
|
|
|
if ( mouse )
|
|
|
|
mouse->drawGpmPointer();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::processResizeEvent()
|
|
|
|
{
|
2016-10-13 02:16:51 +02:00
|
|
|
if ( hasChangedTermSize() )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2016-01-17 02:57:08 +01:00
|
|
|
FResizeEvent r_ev(fc::Resize_Event);
|
2018-10-21 21:06:52 +02:00
|
|
|
sendEvent(app_object, &r_ev);
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
if ( r_ev.isAccepted() )
|
2016-10-13 02:16:51 +02:00
|
|
|
changeTermSizeFinished();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-25 14:33:43 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::processCloseWidget()
|
|
|
|
{
|
2018-02-03 00:04:24 +01:00
|
|
|
updateTerminal (FVTerm::stop_refresh);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
if ( close_widget && ! close_widget->empty() )
|
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto iter = close_widget->begin();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2016-07-16 20:39:38 +02:00
|
|
|
while ( iter != close_widget->end() && *iter )
|
2015-05-23 13:35:12 +02:00
|
|
|
{
|
2015-10-06 05:09:18 +02:00
|
|
|
delete *iter;
|
|
|
|
++iter;
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2015-10-06 05:09:18 +02:00
|
|
|
close_widget->clear();
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2016-07-10 00:23:39 +02:00
|
|
|
|
2018-02-03 00:04:24 +01:00
|
|
|
updateTerminal (FVTerm::start_refresh);
|
2016-06-25 14:33:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
bool FApplication::processNextEvent()
|
|
|
|
{
|
2018-09-24 04:02:35 +02:00
|
|
|
uInt num_events = 0;
|
2016-06-25 14:33:43 +02:00
|
|
|
|
|
|
|
processKeyboardEvent();
|
|
|
|
processMouseEvent();
|
|
|
|
processResizeEvent();
|
|
|
|
processTerminalUpdate();
|
|
|
|
processCloseWidget();
|
2015-05-23 13:35:12 +02:00
|
|
|
|
|
|
|
sendQueuedEvents();
|
|
|
|
num_events += processTimerEvent();
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
return ( num_events > 0 );
|
2015-05-23 13:35:12 +02:00
|
|
|
}
|
2018-09-20 23:59:01 +02:00
|
|
|
|
2018-09-27 03:02:07 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FApplication::performTimerAction ( const FObject* receiver
|
|
|
|
, const FEvent* event )
|
|
|
|
{
|
|
|
|
sendEvent(receiver, event);
|
|
|
|
}
|
|
|
|
|
2018-09-20 23:59:01 +02:00
|
|
|
} // namespace finalcut
|