Skip to content

Commit f5ad546

Browse files
committed
rebased on current OSG 3.7.0, support OSG_WINDOWING_SYSTEM environment variable to select specific system, default to working windowing system, update to wl_output v4 protocol for current sway/weston
1 parent 36b4e17 commit f5ad546

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

src/osg/GraphicsContext.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,44 @@ GraphicsContext::WindowingSystemInterface* GraphicsContext::WindowingSystemInter
7575
OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no interfaces available."<<std::endl;
7676
return 0;
7777
}
78+
std::string search = name;
79+
if (getenv("OSG_WINDOWING_SYSTEM") != NULL)
80+
{
81+
search = getenv("OSG_WINDOWING_SYSTEM");
82+
}
7883

79-
if (!name.empty())
84+
if (!search.empty())
8085
{
8186
for(Interfaces::iterator itr = _interfaces.begin();
8287
itr != _interfaces.end();
8388
++itr)
8489
{
85-
if ((*itr)->getName()==name)
90+
if ((*itr)->getName()==search)
8691
{
92+
OSG_INFO<<"found WindowingSystemInterface : "<<search<<std::endl;
8793
return itr->get();
8894
}
89-
90-
OSG_NOTICE<<" tried interface "<<typeid(*itr).name()<<", name= "<<(*itr)->getName()<<std::endl;
9195
}
9296

93-
OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no interfaces matches name : "<<name<<std::endl;
97+
OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no interfaces matches name : "<<search<<std::endl;
9498
return 0;
9599
}
96100
else
97101
{
98-
// no preference provided so just take the first available interface
99-
return _interfaces.front().get();
102+
// no preference provided so just take the first available interface that works
103+
for (Interfaces::iterator itr = _interfaces.begin();
104+
itr != _interfaces.end();
105+
++itr)
106+
{
107+
if ((*itr)->getNumScreens() > 0)
108+
{
109+
OSG_INFO<<"using default WindowingSystemInterface : "<<(*itr)->getName()<<std::endl;
110+
return itr->get();
111+
}
112+
}
113+
114+
OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no working interfaces"<<std::endl;
115+
return 0;
100116
}
101117
}
102118

src/osgViewer/GraphicsWindowWayland.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,16 @@ class WLWindowingSystemInterface : public osg::GraphicsContext::WindowingSystemI
482482
WLGWlog(0) << "<output(" << o << ") scale: " << factor << ">" << std::endl;
483483
}
484484
static void output_done(void *data, wl_output *wl_output) {}
485+
static void output_name(void *data, wl_output *wl_output, const char *name) {
486+
WLWindowingSystemInterface* obj = (WLWindowingSystemInterface*) data;
487+
int o = obj->find_output(wl_output);
488+
WLGWlog(0) << "<output(" << o << ") name: " << name << ">" << std::endl;
489+
}
490+
static void output_desc(void *data, wl_output *wl_output, const char *desc) {
491+
WLWindowingSystemInterface* obj = (WLWindowingSystemInterface*) data;
492+
int o = obj->find_output(wl_output);
493+
WLGWlog(0) << "<output(" << o << ") desc: " << desc << ">" << std::endl;
494+
}
485495
// Input handling
486496
WLGraphicsWindow* get_window(struct wl_surface* surface) {
487497
if (surface) {
@@ -733,7 +743,7 @@ class WLWindowingSystemInterface : public osg::GraphicsContext::WindowingSystemI
733743
wl_registry_add_listener(_gc.registry, &_wl_registry_listener, this);
734744
wl_display_roundtrip(_gc.display);
735745
// ensure we got all required shared objects
736-
if (!_gc.compositor || !_gc.shm || !_gc.output || !_gc.xdg_wm_base || !_gc.zxdg_decoration_manager_v1) {
746+
if (!_gc.compositor || !_gc.shm || _gc.n_outputs < 1 || !_gc.xdg_wm_base || !_gc.zxdg_decoration_manager_v1) {
737747
WLGWlog(0) << "WLwsi::checkInit: missing one of compositor/shm/output/xdg_wm_base/zxdg_decoration_manager_v1" << std::endl;
738748
break;
739749
}
@@ -776,6 +786,8 @@ class WLWindowingSystemInterface : public osg::GraphicsContext::WindowingSystemI
776786
_wl_output_listener.mode = output_mode;
777787
_wl_output_listener.scale = output_scale;
778788
_wl_output_listener.done = output_done;
789+
_wl_output_listener.name = output_name;
790+
_wl_output_listener.description = output_desc;
779791
for (size_t o=0; o<_gc.n_outputs; o++)
780792
wl_output_add_listener(_gc.output[o], &_wl_output_listener, this);
781793
// attach ping responder

0 commit comments

Comments
 (0)