@@ -200,6 +200,7 @@ var BaseConnection = module.exports = function(opts) {
200200 port : this . getPort ( ) ,
201201 background : false ,
202202 optimizeHMD : false ,
203+ optimizeScreentop : false ,
203204 requestProtocolVersion : BaseConnection . defaultProtocolVersion
204205 } , opts || { } ) ;
205206 this . host = this . opts . host ;
@@ -208,12 +209,16 @@ var BaseConnection = module.exports = function(opts) {
208209 this . protocolVersionVerified = false ;
209210 this . background = null ;
210211 this . optimizeHMD = null ;
212+ this . optimizeScreentop = null ;
211213 this . on ( 'ready' , function ( ) {
212214 this . setBackground ( this . opts . background ) ;
213215 this . setOptimizeHMD ( this . opts . optimizeHMD ) ;
216+ this . setOptimizeScreentop ( this . opts . optimizeScreentop ) ;
214217
215218 if ( this . opts . optimizeHMD ) {
216219 console . log ( "Optimized for head mounted display usage." ) ;
220+ } else if ( this . opts . optimizeScreentop ) {
221+ console . log ( "Optimized for screentop usage." ) ;
217222 } else {
218223 console . log ( "Optimized for desktop usage." ) ;
219224 }
@@ -249,11 +254,21 @@ BaseConnection.prototype.setBackground = function(state) {
249254BaseConnection . prototype . setOptimizeHMD = function ( state ) {
250255 this . opts . optimizeHMD = state ;
251256 if ( this . protocol && this . protocol . sendOptimizeHMD && this . optimizeHMD !== this . opts . optimizeHMD ) {
257+ if ( state === true ) this . optimizeScreentop = false ;
252258 this . optimizeHMD = this . opts . optimizeHMD ;
253259 this . protocol . sendOptimizeHMD ( this , this . opts . optimizeHMD ) ;
254260 }
255261}
256262
263+ BaseConnection . prototype . setOptimizeScreentop = function ( state ) {
264+ this . opts . optimizeScreentop = state ;
265+ if ( this . protocol && this . protocol . sendOptimizeScreentop && this . optimizeScreentop !== this . opts . optimizeScreentop ) {
266+ if ( state === true ) this . optimizeHMD = false ;
267+ this . optimizeScreentop = this . opts . optimizeScreentop ;
268+ this . protocol . sendOptimizeScreentop ( this , this . opts . optimizeScreentop ) ;
269+ }
270+ }
271+
257272BaseConnection . prototype . handleOpen = function ( ) {
258273 if ( ! this . connected ) {
259274 this . connected = true ;
@@ -298,6 +313,7 @@ BaseConnection.prototype.disconnect = function(allowReconnect) {
298313 delete this . protocol ;
299314 delete this . background ; // This is not persisted when reconnecting to the web socket server
300315 delete this . optimizeHMD ;
316+ delete this . optimizeScreentop ;
301317 delete this . focusedState ;
302318 if ( this . connected ) {
303319 this . connected = false ;
@@ -590,6 +606,11 @@ Controller.prototype.setOptimizeHMD = function(state) {
590606 return this ;
591607}
592608
609+ Controller . prototype . setOptimizeScreentop = function ( state ) {
610+ this . connection . setOptimizeScreentop ( state ) ;
611+ return this ;
612+ }
613+
593614Controller . prototype . inBrowser = function ( ) {
594615 return ! this . inNode ;
595616}
@@ -2954,6 +2975,9 @@ exports.chooseProtocol = function(header) {
29542975 protocol . sendOptimizeHMD = function ( connection , state ) {
29552976 connection . send ( protocol . encode ( { optimizeHMD : state } ) ) ;
29562977 }
2978+ protocol . sendOptimizeScreentop = function ( connection , state ) {
2979+ connection . send ( protocol . encode ( { optimizeScreentop : state } ) ) ;
2980+ }
29572981 break ;
29582982 default :
29592983 throw "unrecognized version" ;
0 commit comments