Skip to content

Commit

Permalink
Fixed cursor on X11.
Browse files Browse the repository at this point in the history
Added Desktop to Status bar.
  • Loading branch information
ggarra13 committed May 12, 2024
1 parent 5e79a05 commit d1fc0b2
Show file tree
Hide file tree
Showing 11 changed files with 10,597 additions and 12,370 deletions.
2 changes: 2 additions & 0 deletions mrv2/docs/HISTORY.md
Expand Up @@ -56,6 +56,8 @@ This is a release full of goodies and bug fixes.
when it can be dragged.
- Made Panel divider highlight in a grayish color when it can be dragged.
- Fixed cursor when dragging on the Panel divider bar.
- Fixed cursor sometimes switching to the Arrow instead of the Cross cursor.
This was maily a Linux issue.



Expand Down
32 changes: 25 additions & 7 deletions mrv2/lib/mrvCore/mrvOS.cpp
Expand Up @@ -16,27 +16,45 @@

#include "mrvCore/mrvI8N.h"

#include "mrvUI/mrvDesktop.h"

namespace mrv
{
namespace os
{
std::string getDesktop()
{
std::string out = "Unknown";
const char* env = fl_getenv("XDG_SESSION_DESKTOP");
if (env && strlen(env) > 0)
std::string out = _("Desktop: ");

#ifdef __linux__
if (desktop::XWayland())
{
out = env;
out += "XWayland";
}
else
{
env = fl_getenv("DESKTOP_SESSION");
const char* env = fl_getenv("XDG_SESSION_DESKTOP");
if (env && strlen(env) > 0)
{
out = env;
out += env;
}
else
{
env = fl_getenv("DESKTOP_SESSION");
if (env && strlen(env) > 0)
{
out += env;
}
}
}
out = _("Desktop: ") + out;
#elif _WIN32
out += "Windows (GDI+)";
#elif __APPLE__
out += "macOS (Cocoa)";
#else
out += _("Unknown");
#endif

return out;
}

Expand Down
59 changes: 54 additions & 5 deletions mrv2/lib/mrvGL/mrvGLViewport.cpp
Expand Up @@ -25,6 +25,8 @@
#include "mrvFl/mrvIO.h"
#include "mrvFl/mrvTimelinePlayer.h"

#include "mrvUI/mrvDesktop.h"

#include "mrvGL/mrvGLViewportPrivate.h"
#include "mrvGL/mrvGLDefines.h"
#include "mrvGL/mrvGLErrors.h"
Expand Down Expand Up @@ -361,19 +363,66 @@ namespace mrv

if (!p.presentation)
{
Fl_Color c = p.ui->uiPrefs->uiPrefsViewBG->color();

uint8_t ur, ug, ub;
Fl::get_color(p.ui->uiPrefs->uiPrefsViewBG->color(), ur, ug, ub);
Fl::get_color(c, ur, ug, ub);
r = ur / 255.0f;
g = ug / 255.0f;
b = ub / 255.0f;

#ifdef FLTK_USE_WAYLAND
if (fl_wl_display())
p.ui->uiViewGroup->color(fl_rgb_color(ur, ug, ub));
p.ui->uiViewGroup->redraw();

#if 0
static bool print = true;

if (print)
{

std::cerr << "Set color index "
<< std::hex
<< (int)c
<< std::dec
<< " float = "
<< r
<< " "
<< g
<< " "
<< b << std::endl;

std::cerr << "Set color index "
<< std::hex
<< (int)c
<< std::dec
<< " bytes = "
<< (int)ur
<< " "
<< (int)ug
<< " "
<< (int)ub << std::endl;
}


c = p.ui->uiViewGroup->color();
Fl::get_color(c, ur, ug, ub);

if (print)
{
p.ui->uiViewGroup->color(fl_rgb_color(ur, ug, ub));
p.ui->uiViewGroup->redraw();
std::cerr << "Fl::get_color index "
<< std::hex
<< (int)c
<< std::dec
<< " bytes = "
<< (int)ur
<< " "
<< (int)ug
<< " "
<< (int)ub << std::endl;
print = false;
}
#endif

}
else
{
Expand Down
14 changes: 1 addition & 13 deletions mrv2/lib/mrvGL/mrvTimelineViewport.cpp
Expand Up @@ -988,14 +988,6 @@ namespace mrv
{
TLRENDER_P();

#ifdef DEBUG_VIDEO_CALLBACK
if (!p.videoData.empty() && !values.empty() &&
values[0].time != p.videoData[0].time)
{
std::cerr << values[0].time << std::endl;
}
#endif

p.videoData = values;

if (p.resizeWindow)
Expand Down Expand Up @@ -1320,8 +1312,6 @@ namespace mrv

int minX, minY, maxW, maxH, posX, posY;
Fl::screen_work_area(minX, minY, maxW, maxH, screen);
// std::cerr << "work area=" << minX << " " << minY << " "
// << maxW << "x" << maxH << std::endl;

PreferencesUI* uiPrefs = p.ui->uiPrefs;
if (!desktop::Wayland() && uiPrefs->uiWindowFixedPosition->value())
Expand Down Expand Up @@ -1432,7 +1422,6 @@ namespace mrv
if (posX + W + dW > minX + maxW)
{
p.frameView = true;
// posX = minX + dW;
W = minX + maxW + dW - posX;
p.frameView = true;
}
Expand All @@ -1442,8 +1431,7 @@ namespace mrv
H = minY + maxH + dH - posY;
p.frameView = true;
}
// std::cerr << "mw resize=" << posX << " " << posY << " "
// << W << "x" << H << std::endl;

mw->resize(posX, posY, W, H);

p.ui->uiRegion->layout();
Expand Down
16 changes: 8 additions & 8 deletions mrv2/lib/mrvWidgets/mrViewer.fl
Expand Up @@ -107,7 +107,7 @@ decl {class AboutUI;} {public global
}

widget_class PixelToolBarClass {
xywh {1 65 682 31} resizable
xywh {135 199 682 31} resizable
class Fl_Double_Window visible
} {
Fl_Group {} {open
Expand Down Expand Up @@ -413,7 +413,7 @@ where Yn is the white reference (usually 1).} xywh {5 5 100 20}
}

widget_class TimelineClass {
xywh {29 82 690 47} box NO_BOX resizable
xywh {180 244 690 47} box NO_BOX resizable
class Fl_Double_Window visible
} {
Fl_Group {} {
Expand Down Expand Up @@ -805,7 +805,7 @@ uiSecondary = nullptr;} {}
callback {int reason = Fl::callback_reason();
if (reason == FL_REASON_CLOSED)
exit_cb( o, v );} open
xywh {58 111 690 602} type Double align 80 resizable
xywh {225 289 690 602} type Double align 80 resizable
class {mrv::MainWindow} size_range {690 602 0 0} visible
} {
Fl_Pack uiRegion {open
Expand Down Expand Up @@ -1058,7 +1058,7 @@ Value is: pow( 2, 1/x );} xywh {651 26 39 25} type {Horz Knob} labelsize 10 max
Fl_Box uiTimelineLimit {
xywh {0 80 690 408} labeltype NO_LABEL hide resizable
}
Fl_Pack uiViewGroup {
Fl_Pack uiViewGroup {open
xywh {0 53 690 435} type HORIZONTAL box FLAT_BOX
code0 {o->fixed( uiToolsGroup, uiToolsGroup->w() );}
code1 {uiMain->workspace = uiViewGroup;}
Expand Down Expand Up @@ -1227,7 +1227,7 @@ settings->setValue( mrv::kPenColorA, a);}
xywh {0 488 690 30} box FLAT_BOX color 51
class {mrv::TimelineGroup}
} {
Fl_Group uiTimeline {open selected
Fl_Group uiTimeline {open
xywh {0 496 690 22} labeltype NO_LABEL resizable
class {mrv::TimelineWidget}
} {}
Expand All @@ -1252,13 +1252,13 @@ settings->setValue( mrv::kPenColorA, a);}
class PixelToolBarClass
} {}
}
Fl_Group uiStatusGroup {
Fl_Group uiStatusGroup {open
xywh {0 577 690 25} color 0
} {
Fl_Group uiStatusBar {
label {Everything OK. } open
Fl_Group uiStatusBar {open selected
xywh {0 577 690 25} box FLAT_BOX labelsize 10 align 84
code0 {o->save_colors();}
code1 {o->default_message();}
class {mrv::StatusBar}
} {
Fl_Box uiStatus {
Expand Down
7 changes: 4 additions & 3 deletions mrv2/lib/mrvWidgets/mrvPanelGroup.cpp
Expand Up @@ -436,9 +436,10 @@ namespace mrv
int PanelGroup::handle(int e)
{
int ret = Fl_Group::handle(e);
auto win = window();
if (win && ret == 0)
win->cursor(FL_CURSOR_DEFAULT);
if (e == FL_ENTER)
{
window()->cursor(FL_CURSOR_DEFAULT);
}
return ret;
}

Expand Down
10 changes: 9 additions & 1 deletion mrv2/lib/mrvWidgets/mrvStatusBar.cpp
Expand Up @@ -3,6 +3,7 @@
// Copyright Contributors to the mrv2 Project. All rights reserved.

#include "mrvCore/mrvI8N.h"
#include "mrvCore/mrvOS.h"

#include "mrvWidgets/mrvStatusBar.h"

Expand All @@ -15,7 +16,7 @@ namespace mrv

void StatusBar::all_ok_cb(StatusBar* o)
{
o->copy_label(_("Everything OK."));
o->default_message();
}

StatusBar::StatusBar(int X, int Y, int W, int H, const char* L) :
Expand All @@ -29,6 +30,13 @@ namespace mrv
seconds_ = seconds;
}

void StatusBar::default_message()
{
std::string label = _("Everything OK. ");
label += os::getDesktop();
copy_label(label.c_str());
}

void StatusBar::save_colors()
{
color_ = color();
Expand Down
3 changes: 3 additions & 0 deletions mrv2/lib/mrvWidgets/mrvStatusBar.h
Expand Up @@ -35,6 +35,9 @@ namespace mrv
//! Clear the status bar and restore the colors
void clear();

//! Set up the default status message.
void default_message();

//! Store a message in the status bar (a FLTK label)
void error(const char* msg);

Expand Down

0 comments on commit d1fc0b2

Please sign in to comment.