twitchapon-anim

Basic Twitchapon Receiver/Visuals
git clone git://bsandro.tech/twitchapon-anim
Log | Files | Refs | README | LICENSE

ui_unix.go (2024B)


      1 // Copyright 2016 Hajime Hoshi
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 // +build dragonfly freebsd linux netbsd openbsd solaris
     16 // +build !android
     17 
     18 package glfw
     19 
     20 import (
     21 	"math"
     22 
     23 	"github.com/hajimehoshi/ebiten/v2/internal/glfw"
     24 )
     25 
     26 // fromGLFWMonitorPixel must be called from the main thread.
     27 func (u *UserInterface) fromGLFWMonitorPixel(x float64) float64 {
     28 	return math.Ceil(x / u.deviceScaleFactor())
     29 }
     30 
     31 // fromGLFWPixel must be called from the main thread.
     32 func (u *UserInterface) fromGLFWPixel(x float64) float64 {
     33 	// deviceScaleFactor() is a scale by desktop environment (e.g., Cinnamon), while GetContentScale() is X's scale.
     34 	// They are different things and then need to be treated different ways (#1350).
     35 	s, _ := currentMonitor(u.window).GetContentScale()
     36 	return x / float64(s)
     37 }
     38 
     39 // toGLFWPixel must be called from the main thread.
     40 func (u *UserInterface) toGLFWPixel(x float64) float64 {
     41 	s, _ := currentMonitor(u.window).GetContentScale()
     42 	return x * float64(s)
     43 }
     44 
     45 // toFramebufferPixel must be called from the main thread.
     46 func (u *UserInterface) toFramebufferPixel(x float64) float64 {
     47 	s, _ := currentMonitor(u.window).GetContentScale()
     48 	return math.Ceil(x * float64(s) / u.deviceScaleFactor())
     49 }
     50 
     51 func (u *UserInterface) adjustWindowPosition(x, y int) (int, int) {
     52 	return x, y
     53 }
     54 
     55 func currentMonitorByOS(_ *glfw.Window) *glfw.Monitor {
     56 	// TODO: Implement this correctly. (#1119).
     57 	return nil
     58 }
     59 
     60 func (u *UserInterface) nativeWindow() uintptr {
     61 	// TODO: Implement this.
     62 	return 0
     63 }