class_docstr: Glfw backend for Canvas abstract class.
class_docstr_tok: ["Glfw","backend","for","Canvas","abstract","class","."]
code: def __init__(self, vispy_canvas, **kwargs):
      BaseCanvasBackend.__init__(self, vispy_canvas)
      p = self._process_backend_kwargs(kwargs)
      self._initialized = False
  
      # Deal with config
      _set_config(p.context.config)
      # Deal with context
      p.context.shared.add_ref("glfw", self)
      if p.context.shared.ref is self:
          share = None
      else:
          share = p.context.shared.ref._id
  
      glfw.window_hint(glfw.REFRESH_RATE, 0)  # highest possible
      glfw.window_hint(glfw.RESIZABLE, int(p.resizable))
      glfw.window_hint(glfw.DECORATED, int(p.decorate))
      glfw.window_hint(glfw.VISIBLE, 0)  # start out hidden
      glfw.window_hint(glfw.FLOATING, int(p.always_on_top))
      if p.fullscreen is not False:
          self._fullscreen = True
          if p.fullscreen is True:
              monitor = glfw.get_primary_monitor()
          else:
              monitor = glfw.get_monitors()
              if p.fullscreen >= len(monitor):
                  raise ValueError(
                      "fullscreen must be <= %s" % len(monitor)
                  )
              monitor = monitor[p.fullscreen]
          use_size = glfw.get_video_mode(monitor)[0][:2]
          if use_size != tuple(p.size):
              logger.debug(
                  "Requested size %s, will be ignored to "
                  "use fullscreen mode %s" % (p.size, use_size)
              )
          size = use_size
      else:
          self._fullscreen = False
          monitor = None
          size = p.size
  
      self._id = glfw.create_window(
          width=size[0],
          height=size[1],
          title=p.title,
          monitor=monitor,
          share=share,
      )
      if not self._id:
          raise RuntimeError("Could not create window")
  
      glfw.make_context_current(self._id)
      glfw.swap_interval(1 if p.vsync else 0)  # needs a valid context
  
      _VP_GLFW_ALL_WINDOWS.append(self)
      self._mod = list()
  
      # Register callbacks
      glfw.set_window_refresh_callback(self._id, self._on_draw)
      glfw.set_window_size_callback(self._id, self._on_resize)
      glfw.set_key_callback(self._id, self._on_key_press)
      glfw.set_char_callback(self._id, self._on_key_char)
      glfw.set_mouse_button_callback(self._id, self._on_mouse_button)
      glfw.set_scroll_callback(self._id, self._on_mouse_scroll)
      glfw.set_cursor_pos_callback(self._id, self._on_mouse_motion)
      glfw.set_window_close_callback(self._id, self._on_close)
      self._vispy_canvas_ = None
      self._needs_draw = False
      self._vispy_canvas.set_current()
      if p.position is not None:
          self._vispy_set_position(*p.position)
      if p.show:
          glfw.show_window(self._id)
  
      # Init
      self._initialized = True
      self._next_key_events = []
      self._next_key_text = {}
      self._vispy_canvas.set_current()
      self._vispy_canvas.events.initialize()
      self._on_resize(self._id, size[0], size[1])
  
imports: from __future__ import division
  import atexit
  from time import sleep
  import gc
  import os
  from ..base import BaseApplicationBackend, BaseCanvasBackend, BaseTimerBackend
  from ...util import keys, logger
  from ...util.ptime import time
  from ...None import config
label_desc: Use image node_id 1 to create a new CanvasBackend object from inherited base classes: BaseCanvasBackend with example: obj = CanvasBackend(vispy_canvas)