MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / timerCallback

Method timerCallback

Source/MainComponent.cpp:111–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109 }
110
111 void timerCallback() override
112 {
113 static int sRenderFrame = 0;
114 if (sRenderFrame == 0 && mDesiredInitialPosition.x != INT_MAX)
115 getTopLevelComponent()->setTopLeftPosition(mDesiredInitialPosition);
116
117 static bool sHasGrabbedFocus = false;
118 if (!sHasGrabbedFocus && !hasKeyboardFocus(true) && isVisible())
119 {
120 grabKeyboardFocus();
121 sHasGrabbedFocus = true;
122 }
123
124 mSynth.Poll();
125
126#if DEBUG
127 if (sRenderFrame % 2 == 0)
128#else
129 if (true)
130#endif
131 {
132 openGLContext.triggerRepaint();
133 }
134 ++sRenderFrame;
135
136 if (sRenderFrame % 30 == 0)
137 {
138 if (const auto* dpy = Desktop::getInstance().getDisplays().getDisplayForRect(getScreenBounds()))
139 {
140 mPixelRatio = dpy->scale; //adjust pixel ratio based on which screen has the majority of the window
141 TheSynth->SetPixelRatio(mPixelRatio);
142 }
143 }
144
145 mScreenPosition = getScreenPosition();
146
147 mSpaceMouseReader.Poll();
148 }
149
150 //==============================================================================
151 void audioDeviceAboutToStart(AudioIODevice* device) override

Callers

nothing calls this directly

Calls 2

SetPixelRatioMethod · 0.80
PollMethod · 0.45

Tested by

no test coverage detected