Skip to content

Commit

Permalink
Cleaned up code to work in Wayland as best as possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Apr 28, 2024
1 parent b277bea commit 018c2c6
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions mrv2/lib/mrvGL/mrvTimelineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@

#include "mrViewer.h"


namespace mrv
{
namespace
{
const double kTimeout = 0.005;
const double kTimeout = 0.0; // 05;
const char* kModule = "timelineui";
} // namespace

Expand All @@ -68,10 +67,12 @@ namespace mrv
}
return out;
}
} // namespace
/////
}

namespace
{
// These classes (TimelineWindow and Clipboard) are needed to act
// from FLTK to Darby's UI translations.
class TimelineWindow : public ui::IWindow
{
TLRENDER_NON_COPYABLE(TimelineWindow);
Expand Down Expand Up @@ -254,6 +255,8 @@ namespace mrv
setStopOnScrub(false);

_styleUpdate();

Fl::add_timeout(kTimeout, (Fl_Timeout_Handler)timerEvent_cb, this);
}

ThumbnailCreator* TimelineWidget::thumbnailCreator()
Expand Down Expand Up @@ -342,7 +345,11 @@ namespace mrv

if (!p.ui->uiPrefs->uiPrefsTimelineThumbnails->value())
{
hideThumbnail();
if (!Fl::has_timeout((Fl_Timeout_Handler)hideThumbnail_cb, this))
{
Fl::add_timeout(
0.005, (Fl_Timeout_Handler)hideThumbnail_cb, this);
}
return 0;
}

Expand Down Expand Up @@ -375,16 +382,15 @@ namespace mrv
p.thumbnailWindow->end();
p.thumbnailWindow->show();
}
#ifdef _WIN32
// Without this, the window would not show on Windows
if (fetch)
{
p.thumbnailWindow->resize(X, Y, W, H);
p.thumbnailWindow->show();
}
#else
p.thumbnailWindow->resize(X, Y, W, H);
#endif
else
{
p.thumbnailWindow->resize(X, Y, W, H);
}

file::Path path;
auto model = p.ui->app->filesModel();
Expand Down Expand Up @@ -1311,7 +1317,9 @@ namespace mrv
{
TLRENDER_P();

if (visible_r())
//! \bug This guard is needed since the timer event can be called during
//! destruction?
if (_p)
{
ui::TickEvent tickEvent(p.style, p.iconLibrary, p.fontSystem);
_tickEvent(p.timelineWindow, true, true, tickEvent);
Expand All @@ -1333,42 +1341,38 @@ namespace mrv
{
redraw();
}
Fl::repeat_timeout(
kTimeout, (Fl_Timeout_Handler)timerEvent_cb, this);
}
Fl::repeat_timeout(kTimeout, (Fl_Timeout_Handler)timerEvent_cb, this);
}

int TimelineWidget::handle(int event)
{
TLRENDER_P();
switch (event)
{
case FL_SHOW:
Fl::add_timeout(kTimeout, (Fl_Timeout_Handler)timerEvent_cb, this);
if (p.thumbnailWindow &&
p.ui->uiPrefs->uiPrefsTimelineThumbnails->value() &&
Fl::belowmouse() == this)
{
_requestThumbnail(true);
}
break;
case FL_FOCUS:
case FL_UNFOCUS:
return 1;
case FL_ENTER:
cursor(FL_CURSOR_DEFAULT);
if (p.thumbnailWindow &&
if (p.thumbnailWindow && p.player &&
p.ui->uiPrefs->uiPrefsTimelineThumbnails->value())
{
_requestThumbnail(true);
p.thumbnailWindow->show();
_requestThumbnail();
}
return enterEvent();
case FL_LEAVE:
if (p.ui->uiPrefs->uiPrefsTimelineThumbnails->value())
{
if (p.thumbnailCreator && p.thumbnailRequestId)
p.thumbnailCreator->cancelRequests(p.thumbnailRequestId);
hideThumbnail();
if (!Fl::has_timeout(
(Fl_Timeout_Handler)hideThumbnail_cb, this))
{
Fl::add_timeout(
0.005, (Fl_Timeout_Handler)hideThumbnail_cb, this);
}
}
return leaveEvent();
case FL_PUSH:
Expand All @@ -1387,18 +1391,24 @@ namespace mrv
return wheelEvent();
case FL_KEYDOWN:
{
// @todo: ask darby for a return code from key press
// int ret = p.ui->uiView->handle(event);
return keyPressEvent();
}
case FL_KEYUP:
return keyReleaseEvent();
case FL_HIDE:
{
Fl::remove_timeout((Fl_Timeout_Handler)timerEvent_cb, this);
if (p.ui->uiPrefs->uiPrefsTimelineThumbnails->value())
{
if (p.thumbnailCreator && p.thumbnailRequestId)
p.thumbnailCreator->cancelRequests(p.thumbnailRequestId);
hideThumbnail();
if (!Fl::has_timeout(
(Fl_Timeout_Handler)hideThumbnail_cb, this))
{
Fl::add_timeout(
0.005, (Fl_Timeout_Handler)hideThumbnail_cb, this);
}
}
refresh();
valid(0);
Expand Down

0 comments on commit 018c2c6

Please sign in to comment.