JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_Windowing_linux.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
32{
33public:
36 isAlwaysOnTop (comp.isAlwaysOnTop())
37 {
38 // it's dangerous to create a window on a thread other than the message thread.
40
41 const auto* instance = XWindowSystem::getInstance();
42
43 if (! instance->isX11Available())
44 return;
45
46 if (isAlwaysOnTop)
47 ++WindowUtilsInternal::numAlwaysOnTopPeers;
48
49 repainter = std::make_unique<LinuxRepaintManager> (*this);
50
51 windowH = instance->createWindow (parentToAddTo, this);
52 parentWindow = parentToAddTo;
53
54 setTitle (component.getName());
55
56 if (auto* xSettings = instance->getXSettings())
57 xSettings->addListener (this);
58
59 getNativeRealtimeModifiers = []() -> ModifierKeys { return XWindowSystem::getInstance()->getNativeRealtimeModifiers(); };
60
61 updateVBlankTimer();
62 }
63
64 ~LinuxComponentPeer() override
65 {
66 // it's dangerous to delete a window on a thread other than the message thread.
68
69 auto* instance = XWindowSystem::getInstance();
70
71 repainter = nullptr;
72 instance->destroyWindow (windowH);
73
74 if (auto* xSettings = instance->getXSettings())
75 xSettings->removeListener (this);
76
77 if (isAlwaysOnTop)
78 --WindowUtilsInternal::numAlwaysOnTopPeers;
79 }
80
81 ::Window getWindowHandle() const noexcept
82 {
83 return windowH;
84 }
85
86 //==============================================================================
87 void* getNativeHandle() const override
88 {
89 return reinterpret_cast<void*> (getWindowHandle());
90 }
91
92 //==============================================================================
93 void forceSetBounds (const Rectangle<int>& correctedNewBounds, bool isNowFullScreen)
94 {
95 bounds = correctedNewBounds;
96
97 updateScaleFactorFromNewBounds (bounds, false);
98
99 auto physicalBounds = parentWindow == 0 ? Desktop::getInstance().getDisplays().logicalToPhysical (bounds)
100 : bounds * currentScaleFactor;
101
103
104 XWindowSystem::getInstance()->setBounds (windowH, physicalBounds, isNowFullScreen);
105
106 fullScreen = isNowFullScreen;
107
108 if (deletionChecker != nullptr)
109 {
110 updateBorderSize();
112 }
113 }
114
116 {
117 const auto correctedNewBounds = newBounds.withSize (jmax (1, newBounds.getWidth()),
118 jmax (1, newBounds.getHeight()));
119
120 if (bounds != correctedNewBounds || fullScreen != isNowFullScreen)
121 forceSetBounds (correctedNewBounds, isNowFullScreen);
122 }
123
124 Point<int> getScreenPosition (bool physical) const
125 {
126 auto physicalParentPosition = XWindowSystem::getInstance()->getPhysicalParentScreenPosition();
128 : physicalParentPosition / currentScaleFactor;
129
130 auto screenBounds = parentWindow == 0 ? bounds
132
133 if (physical)
134 return parentWindow == 0 ? Desktop::getInstance().getDisplays().logicalToPhysical (screenBounds.getTopLeft())
135 : screenBounds.getTopLeft() * currentScaleFactor;
136
137 return screenBounds.getTopLeft();
138 }
139
140 Rectangle<int> getBounds() const override
141 {
142 return bounds;
143 }
144
146 {
147 return windowBorder;
148 }
149
151 {
153 return optionalBorderSize ? (*optionalBorderSize) : BorderSize<int>();
154 }
155
160
165
168
169 //==============================================================================
170 StringArray getAvailableRenderingEngines() override
171 {
172 return { "Software Renderer" };
173 }
174
175 void setVisible (bool shouldBeVisible) override
176 {
177 XWindowSystem::getInstance()->setVisible (windowH, shouldBeVisible);
178 }
179
180 void setTitle (const String& title) override
181 {
182 XWindowSystem::getInstance()->setTitle (windowH, title);
183 }
184
185 void setMinimised (bool shouldBeMinimised) override
186 {
188 XWindowSystem::getInstance()->setMinimised (windowH, shouldBeMinimised);
189 else
190 setVisible (true);
191 }
192
193 bool isMinimised() const override
194 {
195 return XWindowSystem::getInstance()->isMinimised (windowH);
196 }
197
199 {
200 auto r = lastNonFullscreenBounds; // (get a copy of this before de-minimising)
201
202 setMinimised (false);
203
204 if (fullScreen != shouldBeFullScreen)
205 {
206 const auto usingNativeTitleBar = ((styleFlags & windowHasTitleBar) != 0);
207
209 XWindowSystem::getInstance()->setMaximised (windowH, shouldBeFullScreen);
210
212 r = usingNativeTitleBar ? XWindowSystem::getInstance()->getWindowBounds (windowH, parentWindow)
214
215 if (! r.isEmpty())
216 setBounds (detail::ScalingHelpers::scaledScreenPosToUnscaled (component, r), shouldBeFullScreen);
217
218 component.repaint();
219 }
220 }
221
222 bool isFullScreen() const override
223 {
224 return fullScreen;
225 }
226
228 {
229 if (! bounds.withZeroOrigin().contains (localPos))
230 return false;
231
232 for (int i = Desktop::getInstance().getNumComponents(); --i >= 0;)
233 {
234 auto* c = Desktop::getInstance().getComponent (i);
235
236 if (c == &component)
237 break;
238
239 if (! c->isVisible())
240 continue;
241
242 auto* otherPeer = c->getPeer();
243 jassert (otherPeer == nullptr || dynamic_cast<LinuxComponentPeer*> (c->getPeer()) != nullptr);
244
245 if (auto* peer = static_cast<LinuxComponentPeer*> (otherPeer))
246 if (peer->contains (globalToLocal (*peer, localToGlobal (*this, localPos.toFloat())).roundToInt(), true))
247 return false;
248 }
249
251 return true;
252
253 return XWindowSystem::getInstance()->contains (windowH, localPos * currentScaleFactor);
254 }
255
256 void toFront (bool makeActive) override
257 {
258 if (makeActive)
259 {
260 setVisible (true);
261 grabFocus();
262 }
263
264 XWindowSystem::getInstance()->toFront (windowH, makeActive);
266 }
267
268 void toBehind (ComponentPeer* other) override
269 {
270 if (auto* otherPeer = dynamic_cast<LinuxComponentPeer*> (other))
271 {
272 if (otherPeer->styleFlags & windowIsTemporary)
273 return;
274
275 setMinimised (false);
276 XWindowSystem::getInstance()->toBehind (windowH, otherPeer->windowH);
277 }
278 else
279 {
280 jassertfalse; // wrong type of window?
281 }
282 }
283
284 bool isFocused() const override
285 {
286 return XWindowSystem::getInstance()->isFocused (windowH);
287 }
288
289 void grabFocus() override
290 {
291 if (XWindowSystem::getInstance()->grabFocus (windowH))
292 isActiveApplication = true;
293 }
294
295 //==============================================================================
296 void repaint (const Rectangle<int>& area) override
297 {
298 if (repainter != nullptr)
299 repainter->repaint (area.getIntersection (bounds.withZeroOrigin()));
300 }
301
303 {
304 if (repainter != nullptr)
305 repainter->performAnyPendingRepaintsNow();
306 }
307
308 void setIcon (const Image& newIcon) override
309 {
310 XWindowSystem::getInstance()->setIcon (windowH, newIcon);
311 }
312
313 double getPlatformScaleFactor() const noexcept override
314 {
315 return currentScaleFactor;
316 }
317
318 void setAlpha (float) override {}
319 bool setAlwaysOnTop (bool) override { return false; }
321
322 //==============================================================================
323 void addOpenGLRepaintListener (Component* dummy)
324 {
325 if (dummy != nullptr)
326 glRepaintListeners.addIfNotAlreadyThere (dummy);
327 }
328
329 void removeOpenGLRepaintListener (Component* dummy)
330 {
331 if (dummy != nullptr)
332 glRepaintListeners.removeAllInstancesOf (dummy);
333 }
334
335 void repaintOpenGLContexts()
336 {
337 for (auto* c : glRepaintListeners)
338 c->handleCommandMessage (0);
339 }
340
341 //==============================================================================
342 ::Window getParentWindow() { return parentWindow; }
343 void setParentWindow (::Window newParent) { parentWindow = newParent; }
344
345 //==============================================================================
346 bool isConstrainedNativeWindow() const
347 {
348 return constrainer != nullptr
350 && ! isKioskMode();
351 }
352
353 void updateWindowBounds()
354 {
355 if (windowH == 0)
356 {
358 return;
359 }
360
361 if (isConstrainedNativeWindow())
362 XWindowSystem::getInstance()->updateConstraints (windowH);
363
364 auto physicalBounds = XWindowSystem::getInstance()->getWindowBounds (windowH, parentWindow);
365
366 updateScaleFactorFromNewBounds (physicalBounds, true);
367
368 bounds = parentWindow == 0 ? Desktop::getInstance().getDisplays().physicalToLogical (physicalBounds)
369 : physicalBounds / currentScaleFactor;
370
371 updateVBlankTimer();
372 }
373
374 void updateBorderSize()
375 {
376 if ((styleFlags & windowHasTitleBar) == 0)
377 {
378 windowBorder = ComponentPeer::OptionalBorderSize { BorderSize<int>() };
379 }
380 else if (! windowBorder
381 || ((*windowBorder).getTopAndBottom() == 0 && (*windowBorder).getLeftAndRight() == 0))
382 {
383 windowBorder = [&]()
384 {
385 if (auto unscaledBorderSize = XWindowSystem::getInstance()->getBorderSize (windowH))
386 return OptionalBorderSize { (*unscaledBorderSize).multipliedBy (1.0 / currentScaleFactor) };
387
388 return OptionalBorderSize {};
389 }();
390 }
391 }
392
393 bool setWindowAssociation (::Window windowIn)
394 {
395 clearWindowAssociation();
396 association = { this, windowIn };
397 return association.isValid();
398 }
399
400 void clearWindowAssociation() { association = {}; }
401
403 {
404 XWindowSystem::getInstance()->startHostManagedResize (windowH, zone);
405 }
406
407 //==============================================================================
408 static bool isActiveApplication;
409 bool focused = false;
410
411private:
412 //==============================================================================
413 class LinuxRepaintManager
414 {
415 public:
416 LinuxRepaintManager (LinuxComponentPeer& p)
417 : peer (p),
418 isSemiTransparentWindow ((peer.getStyleFlags() & ComponentPeer::windowIsSemiTransparent) != 0)
419 {
420 }
421
422 void dispatchDeferredRepaints()
423 {
424 XWindowSystem::getInstance()->processPendingPaintsForWindow (peer.windowH);
425
426 if (XWindowSystem::getInstance()->getNumPaintsPendingForWindow (peer.windowH) > 0)
427 return;
428
429 if (! regionsNeedingRepaint.isEmpty())
430 performAnyPendingRepaintsNow();
431 else if (Time::getApproximateMillisecondCounter() > lastTimeImageUsed + 3000)
432 image = Image();
433 }
434
435 void repaint (Rectangle<int> area)
436 {
437 regionsNeedingRepaint.add (area * peer.currentScaleFactor);
438 }
439
440 void performAnyPendingRepaintsNow()
441 {
442 if (XWindowSystem::getInstance()->getNumPaintsPendingForWindow (peer.windowH) > 0)
443 return;
444
445 auto originalRepaintRegion = regionsNeedingRepaint;
446 regionsNeedingRepaint.clear();
447 auto totalArea = originalRepaintRegion.getBounds();
448
449 if (! totalArea.isEmpty())
450 {
451 const auto wasImageNull = image.isNull();
452
453 if (wasImageNull || image.getWidth() < totalArea.getWidth()
454 || image.getHeight() < totalArea.getHeight())
455 {
456 image = XWindowSystem::getInstance()->createImage (isSemiTransparentWindow,
457 totalArea.getWidth(), totalArea.getHeight(),
458 useARGBImagesForRendering);
459 if (wasImageNull)
460 {
461 // After calling createImage() XWindowSystem::getWindowBounds() will return
462 // changed coordinates that look like the result of some position
463 // defaulting mechanism. If we handle a configureNotifyEvent after
464 // createImage() and before we would issue new, valid coordinates, we will
465 // apply these default, unwanted coordinates to our window. To avoid that
466 // we immediately send another positioning message to guarantee that the
467 // next configureNotifyEvent will read valid values.
468 //
469 // This issue only occurs right after peer creation, when the image is
470 // null. Updating when only the width or height is changed would lead to
471 // incorrect behaviour.
472 peer.forceSetBounds (detail::ScalingHelpers::scaledScreenPosToUnscaled (peer.component, peer.component.getBoundsInParent()),
473 peer.isFullScreen());
474 }
475 }
476
477 RectangleList<int> adjustedList (originalRepaintRegion);
478 adjustedList.offsetAll (-totalArea.getX(), -totalArea.getY());
479
480 if (XWindowSystem::getInstance()->canUseARGBImages())
481 for (auto& i : originalRepaintRegion)
482 image.clear (i - totalArea.getPosition());
483
484 {
485 auto context = peer.getComponent().getLookAndFeel()
486 .createGraphicsContext (image, -totalArea.getPosition(), adjustedList);
487
488 context->addTransform (AffineTransform::scale ((float) peer.currentScaleFactor));
489 peer.handlePaint (*context);
490 }
491
492 for (auto& i : originalRepaintRegion)
493 XWindowSystem::getInstance()->blitToWindow (peer.windowH, image, i, totalArea);
494 }
495
496 lastTimeImageUsed = Time::getApproximateMillisecondCounter();
497 }
498
499 private:
500 LinuxComponentPeer& peer;
501 const bool isSemiTransparentWindow;
502 Image image;
503 uint32 lastTimeImageUsed = 0;
504 RectangleList<int> regionsNeedingRepaint;
505
506 bool useARGBImagesForRendering = XWindowSystem::getInstance()->canUseARGBImages();
507
508 JUCE_DECLARE_NON_COPYABLE (LinuxRepaintManager)
509 };
510
511 //==============================================================================
512 template <typename This>
513 static Point<float> localToGlobal (This& t, Point<float> relativePosition)
514 {
515 return relativePosition + t.getScreenPosition (false).toFloat();
516 }
517
518 template <typename This>
519 static Point<float> globalToLocal (This& t, Point<float> screenPosition)
520 {
521 return screenPosition - t.getScreenPosition (false).toFloat();
522 }
523
524 //==============================================================================
525 void settingChanged (const XWindowSystemUtilities::XSetting& settingThatHasChanged) override
526 {
527 static StringArray possibleSettings { XWindowSystem::getWindowScalingFactorSettingName(),
528 "Gdk/UnscaledDPI",
529 "Xft/DPI" };
530
531 if (possibleSettings.contains (settingThatHasChanged.name))
532 forceDisplayUpdate();
533 }
534
535 void updateScaleFactorFromNewBounds (const Rectangle<int>& newBounds, bool isPhysical)
536 {
537 Point<int> translation = (parentWindow != 0 ? getScreenPosition (isPhysical) : Point<int>());
538 const auto& desktop = Desktop::getInstance();
539
540 if (auto* display = desktop.getDisplays().getDisplayForRect (newBounds.translated (translation.x, translation.y),
541 isPhysical))
542 {
543 auto newScaleFactor = display->scale / desktop.getGlobalScaleFactor();
544
545 if (! approximatelyEqual (newScaleFactor, currentScaleFactor))
546 {
547 currentScaleFactor = newScaleFactor;
548 scaleFactorListeners.call ([&] (ScaleFactorListener& l) { l.nativeScaleFactorChanged (currentScaleFactor); });
549 }
550 }
551 }
552
553 void onVBlank()
554 {
555 vBlankListeners.call ([] (auto& l) { l.onVBlank(); });
556
557 if (repainter != nullptr)
558 repainter->dispatchDeferredRepaints();
559 }
560
561 void updateVBlankTimer()
562 {
563 if (auto* display = Desktop::getInstance().getDisplays().getDisplayForRect (bounds))
564 {
565 // Some systems fail to set an explicit refresh rate, or ask for a refresh rate of 0
566 // (observed on Raspbian Bullseye over VNC). In these situations, use a fallback value.
567 const auto newIntFrequencyHz = roundToInt (display->verticalFrequencyHz.value_or (0.0));
568 const auto frequencyToUse = newIntFrequencyHz != 0 ? newIntFrequencyHz : 100;
569
570 if (vBlankManager.getTimerInterval() != frequencyToUse)
571 vBlankManager.startTimerHz (frequencyToUse);
572 }
573 }
574
575 //==============================================================================
577 TimedCallback vBlankManager { [this]() { onVBlank(); } };
578
579 ::Window windowH = {}, parentWindow = {};
580 Rectangle<int> bounds;
581 ComponentPeer::OptionalBorderSize windowBorder;
582 bool fullScreen = false, isAlwaysOnTop = false;
583 double currentScaleFactor = 1.0;
584 Array<Component*> glRepaintListeners;
585 ScopedWindowAssociation association;
586
587 //==============================================================================
589};
590
591bool LinuxComponentPeer::isActiveApplication = false;
592
593//==============================================================================
594ComponentPeer* Component::createNewPeer (int styleFlags, void* nativeWindowToAttachTo)
595{
596 return new LinuxComponentPeer (*this, styleFlags, (::Window) nativeWindowToAttachTo);
597}
598
599//==============================================================================
600JUCE_API bool JUCE_CALLTYPE Process::isForegroundProcess() { return LinuxComponentPeer::isActiveApplication; }
601
603JUCE_API void JUCE_CALLTYPE Process::hide() {}
604
605//==============================================================================
606void Desktop::setKioskComponent (Component* comp, bool enableOrDisable, bool)
607{
608 if (enableOrDisable)
609 comp->setBounds (getDisplays().getDisplayForRect (comp->getScreenBounds())->totalArea);
610}
611
612void Displays::findDisplays (float masterScale)
613{
614 if (XWindowSystem::getInstance()->getDisplay() != nullptr)
615 {
616 displays = XWindowSystem::getInstance()->findDisplays (masterScale);
617
618 if (! displays.isEmpty())
619 updateToLogical();
620 }
621}
622
624{
625 return XWindowSystem::getInstance()->canUseSemiTransparentWindows();
626}
627
629{
630public:
632 {
633 const auto* windowSystem = XWindowSystem::getInstance();
634
635 if (auto* xSettings = windowSystem->getXSettings())
636 xSettings->addListener (this);
637
638 darkModeEnabled = windowSystem->isDarkModeActive();
639 }
640
642 {
643 if (auto* windowSystem = XWindowSystem::getInstanceWithoutCreating())
644 if (auto* xSettings = windowSystem->getXSettings())
645 xSettings->removeListener (this);
646 }
647
648 bool isDarkModeEnabled() const noexcept { return darkModeEnabled; }
649
650private:
651 void settingChanged (const XWindowSystemUtilities::XSetting& settingThatHasChanged) override
652 {
653 if (settingThatHasChanged.name == XWindowSystem::getThemeNameSettingName())
654 {
655 const auto wasDarkModeEnabled = std::exchange (darkModeEnabled, XWindowSystem::getInstance()->isDarkModeActive());
656
657 if (darkModeEnabled != wasDarkModeEnabled)
658 Desktop::getInstance().darkModeChanged();
659 }
660 }
661
662 bool darkModeEnabled = false;
663
665};
666
667std::unique_ptr<Desktop::NativeDarkModeChangeDetectorImpl> Desktop::createNativeDarkModeChangeDetectorImpl()
668{
669 return std::make_unique<NativeDarkModeChangeDetectorImpl>();
670}
671
673{
674 return nativeDarkModeChangeDetectorImpl->isDarkModeEnabled();
675}
676
677static bool screenSaverAllowed = true;
678
680{
681 if (screenSaverAllowed != isEnabled)
682 {
683 screenSaverAllowed = isEnabled;
684 XWindowSystem::getInstance()->setScreenSaverEnabled (screenSaverAllowed);
685 }
686}
687
689{
690 return screenSaverAllowed;
691}
692
693double Desktop::getDefaultMasterScale() { return 1.0; }
694
696void Desktop::allowedOrientationsChanged() {}
697
698//==============================================================================
699bool detail::MouseInputSourceList::addSource()
700{
701 if (sources.isEmpty())
702 {
703 addSource (0, MouseInputSource::InputSourceType::mouse);
704 return true;
705 }
706
707 return false;
708}
709
710bool detail::MouseInputSourceList::canUseTouch() const
711{
712 return false;
713}
714
715Point<float> MouseInputSource::getCurrentRawMousePosition()
716{
717 return Desktop::getInstance().getDisplays().physicalToLogical (XWindowSystem::getInstance()->getCurrentMousePosition());
718}
719
720void MouseInputSource::setRawMousePosition (Point<float> newPosition)
721{
722 XWindowSystem::getInstance()->setMousePosition (Desktop::getInstance().getDisplays().logicalToPhysical (newPosition));
723}
724
725//==============================================================================
727{
728public:
730 : cursorHandle (makeHandle (type)) {}
731
733 : cursorHandle (makeHandle (info)) {}
734
736 {
737 if (cursorHandle != Cursor{})
738 XWindowSystem::getInstance()->deleteMouseCursor (cursorHandle);
739 }
740
741 static void showInWindow (PlatformSpecificHandle* handle, ComponentPeer* peer)
742 {
743 const auto cursor = handle != nullptr ? handle->cursorHandle : Cursor{};
744
745 if (peer != nullptr)
746 XWindowSystem::getInstance()->showCursor ((::Window) peer->getNativeHandle(), cursor);
747 }
748
749private:
750 static Cursor makeHandle (const detail::CustomMouseCursorInfo& info)
751 {
752 const auto image = info.image.getImage();
753 return XWindowSystem::getInstance()->createCustomMouseCursorInfo (image.rescaled ((int) (image.getWidth() / info.image.getScale()),
754 (int) (image.getHeight() / info.image.getScale())), info.hotspot);
755 }
756
757 static Cursor makeHandle (MouseCursor::StandardCursorType type)
758 {
759 return XWindowSystem::getInstance()->createStandardMouseCursor (type);
760 }
761
762 Cursor cursorHandle;
763
764 //==============================================================================
767};
768
769//==============================================================================
770static LinuxComponentPeer* getPeerForDragEvent (Component* sourceComp)
771{
772 if (sourceComp == nullptr)
773 if (auto* draggingSource = Desktop::getInstance().getDraggingMouseSource (0))
774 sourceComp = draggingSource->getComponentUnderMouse();
775
776 if (sourceComp != nullptr)
777 if (auto* lp = dynamic_cast<LinuxComponentPeer*> (sourceComp->getPeer()))
778 return lp;
779
780 jassertfalse; // This method must be called in response to a component's mouseDown or mouseDrag event!
781 return nullptr;
782}
783
785 Component* sourceComp, std::function<void()> callback)
786{
787 if (files.isEmpty())
788 return false;
789
790 if (auto* peer = getPeerForDragEvent (sourceComp))
791 return XWindowSystem::getInstance()->externalDragFileInit (peer, files, canMoveFiles, std::move (callback));
792
793 // This method must be called in response to a component's mouseDown or mouseDrag event!
795 return false;
796}
797
799 std::function<void()> callback)
800{
801 if (text.isEmpty())
802 return false;
803
804 if (auto* peer = getPeerForDragEvent (sourceComp))
805 return XWindowSystem::getInstance()->externalDragTextInit (peer, text, std::move (callback));
806
807 // This method must be called in response to a component's mouseDown or mouseDrag event!
809 return false;
810}
811
812//==============================================================================
814{
815 XWindowSystem::getInstance()->copyTextToClipboard (clipText);
816}
817
819{
820 return XWindowSystem::getInstance()->getTextFromClipboard();
821}
822
823//==============================================================================
825{
826 return XWindowSystem::getInstance()->isKeyCurrentlyDown (keyCode);
827}
828
830{
831 std::cout << "\a" << std::flush;
832}
833
834//==============================================================================
835Image detail::WindowingHelpers::createIconForFile (const File&)
836{
837 return {};
838}
839
840void juce_LinuxAddRepaintListener (ComponentPeer* peer, Component* dummy);
841void juce_LinuxAddRepaintListener (ComponentPeer* peer, Component* dummy)
842{
843 if (auto* linuxPeer = dynamic_cast<LinuxComponentPeer*> (peer))
844 linuxPeer->addOpenGLRepaintListener (dummy);
845}
846
847void juce_LinuxRemoveRepaintListener (ComponentPeer* peer, Component* dummy);
848void juce_LinuxRemoveRepaintListener (ComponentPeer* peer, Component* dummy)
849{
850 if (auto* linuxPeer = dynamic_cast<LinuxComponentPeer*> (peer))
851 linuxPeer->removeOpenGLRepaintListener (dummy);
852}
853
854} // namespace juce
static AffineTransform scale(float factorX, float factorY) noexcept
Returns a new transform which is a re-scale about the origin.
Specifies a set of gaps to be left around the sides of a rectangle.
Represents the window borders around a window component.
The Component class uses a ComponentPeer internally to create and manage a real operating-system wind...
int getStyleFlags() const noexcept
Returns the set of style flags that were set when the window was created.
virtual bool isKioskMode() const
True if the window is in kiosk-mode.
virtual void * getNativeHandle() const =0
Returns the raw handle to whatever kind of window is being used.
void handleMovedOrResized()
This is called when the window's bounds change.
@ windowIsResizable
Indicates that the window should have a resizable border.
@ windowIsTemporary
Indicates that the window is a temporary popup, like a menu, tooltip, etc.
@ windowIsSemiTransparent
Not intended for public use - makes a window transparent.
@ windowHasTitleBar
Indicates that the window should have a normal OS-specific title bar and frame.
virtual Point< float > localToGlobal(Point< float > relativePosition)=0
Converts a position relative to the top-left of this component to screen coordinates.
void handleBroughtToFront()
Called when the window is brought to the front, either by the OS or by a call to toFront().
virtual Point< float > globalToLocal(Point< float > screenPosition)=0
Converts a screen coordinate to a position relative to the top-left of this component.
The base class for all JUCE user-interface objects.
bool isAlwaysOnTop() const noexcept
Returns true if this component is set to always stay in front of its siblings.
void repaint()
Marks the whole component as needing to be redrawn.
Rectangle< int > getScreenBounds() const
Returns the bounds of this component, relative to the screen's top-left.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
ComponentPeer * getPeer() const
Returns the heavyweight window that contains this component.
String getName() const noexcept
Returns the name of this component.
DisplayOrientation
In a tablet/mobile device which can be turned around, this is used to indicate the orientation.
@ upright
Indicates that the device is the normal way up.
const Displays & getDisplays() const noexcept
Returns the Displays object representing the connected displays.
static Desktop &JUCE_CALLTYPE getInstance()
There's only one desktop object, and this method will return it.
static void setScreenSaverEnabled(bool isEnabled)
This lets you prevent the screensaver from becoming active.
Component * getComponent(int index) const noexcept
Returns one of the top-level desktop window components.
bool isDarkModeActive() const
True if the operating system "dark mode" is active.
static bool canUseSemiTransparentWindows() noexcept
True if the OS supports semitransparent windows.
DisplayOrientation getCurrentOrientation() const
In a tablet device which can be turned around, this returns the current orientation.
static bool isScreenSaverEnabled()
Returns true if the screensaver has not been turned off.
Rectangle< int > userArea
The total area of this display in logical pixels which isn't covered by OS-dependent objects like the...
Rectangle< int > logicalToPhysical(Rectangle< int > logicalRect, const Display *useScaleFactorOfDisplay=nullptr) const noexcept
Converts an integer Rectangle from logical to physical pixels.
const Display * getDisplayForRect(Rectangle< int > rect, bool isPhysical=false) const noexcept
Returns the Display object representing the display containing a given Rectangle (either in logical o...
Array< Display > displays
An Array containing the Display objects for all of the connected displays.
Rectangle< int > physicalToLogical(Rectangle< int > physicalRect, const Display *useScaleFactorOfDisplay=nullptr) const noexcept
Converts an integer Rectangle from physical to logical pixels.
static bool performExternalDragDropOfText(const String &text, Component *sourceComponent=nullptr, std::function< void()> callback=nullptr)
This performs an asynchronous drag-and-drop of a block of text to some external application.
static bool performExternalDragDropOfFiles(const StringArray &files, bool canMoveFiles, Component *sourceComponent=nullptr, std::function< void()> callback=nullptr)
This performs an asynchronous drag-and-drop of a set of files to some external application.
Represents a local file or directory.
Definition juce_File.h:45
Holds a fixed-size bitmap.
Definition juce_Image.h:58
static bool isKeyCurrentlyDown(int keyCode)
Checks whether a particular key is held down, irrespective of modifiers.
void setVisible(bool shouldBeVisible) override
Shows or hides the window.
void performAnyPendingRepaintsNow() override
This can be called (from the message thread) to cause the immediate redrawing of any areas of this wi...
void setAlpha(float) override
Changes the window's transparency.
double getPlatformScaleFactor() const noexcept override
On Windows and Linux this will return the OS scaling factor currently being applied to the native win...
void toBehind(ComponentPeer *other) override
Moves the window to be just behind another one.
void setTitle(const String &title) override
Changes the title of the window.
void setBounds(const Rectangle< int > &newBounds, bool isNowFullScreen) override
Moves and resizes the window.
Rectangle< int > getBounds() const override
Returns the current position and size of the window.
BorderSize< int > getFrameSize() const override
Returns the size of the window frame that's around this window.
void setIcon(const Image &newIcon) override
Attempts to change the icon associated with this window.
void setMinimised(bool shouldBeMinimised) override
Minimises the window.
Point< float > globalToLocal(Point< float > screenPosition) override
Converts a screen coordinate to a position relative to the top-left of this component.
bool contains(Point< int > localPos, bool trueIfInAChildWindow) const override
Checks if a point is in the window.
Point< float > localToGlobal(Point< float > relativePosition) override
Converts a position relative to the top-left of this component to screen coordinates.
bool setAlwaysOnTop(bool) override
Sets this window to either be always-on-top or normal.
void setFullScreen(bool shouldBeFullScreen) override
Enable/disable fullscreen mode for the window.
void repaint(const Rectangle< int > &area) override
Invalidates a region of the window to be repainted asynchronously.
void startHostManagedResize(Point< int >, ResizableBorderComponent::Zone zone) override
Asks the window-manager to begin resizing this window, on platforms where this is useful (currently j...
void * getNativeHandle() const override
Returns the raw handle to whatever kind of window is being used.
bool isFullScreen() const override
True if the window is currently full-screen.
bool isFocused() const override
True if the window has the keyboard focus.
void toFront(bool makeActive) override
Brings the window to the top, optionally also giving it keyboard focus.
void grabFocus() override
Tries to give the window keyboard focus.
bool isMinimised() const override
True if the window is currently minimised.
void textInputRequired(Point< int >, TextInputTarget &) override
Tells the window that text input may be required at the given position.
OptionalBorderSize getFrameSizeIfPresent() const override
Returns the size of the window frame that's around this window.
virtual void playAlertSound()
Plays the system's default 'beep' noise, to alert the user about something very important.
Represents the state of the mouse buttons and modifier keys.
StandardCursorType
The set of available standard mouse cursors.
A pair of (x, y) coordinates.
Definition juce_Point.h:42
constexpr Point< float > toFloat() const noexcept
Casts this point to a Point<float> object.
Definition juce_Point.h:239
constexpr Point< int > roundToInt() const noexcept
Casts this point to a Point<int> object using roundToInt() to convert the values.
Definition juce_Point.h:245
static void JUCE_CALLTYPE makeForegroundProcess()
Attempts to make the current process the active one.
static void JUCE_CALLTYPE hide()
Hides the application (on an OS that supports this, e.g.
static bool JUCE_CALLTYPE isForegroundProcess()
Returns true if this application process is the one that the user is currently using.
Manages a rectangle and allows geometric operations to be performed on it.
bool contains(ValueType xCoord, ValueType yCoord) const noexcept
Returns true if this coordinate is inside the rectangle.
Point< ValueType > getTopLeft() const noexcept
Returns the rectangle's top-left position as a Point.
Rectangle getIntersection(Rectangle other) const noexcept
Returns the region that is the overlap between this and another rectangle.
Rectangle translated(ValueType deltaX, ValueType deltaY) const noexcept
Returns a rectangle which is the same as this one moved by a given amount.
Rectangle withZeroOrigin() const noexcept
Returns a rectangle whose size is the same as this one, but whose top-left position is (0,...
Represents the different sections of a resizable border, which allow it to resized in different ways.
double getScale() const
Returns the image's scale.
Image getImage() const
Returns the image at its original dimensions.
A special array for holding a list of strings.
bool isEmpty() const noexcept
Returns true if the array is empty, false otherwise.
The JUCE String class!
Definition juce_String.h:53
bool isEmpty() const noexcept
Returns true if the string contains no characters.
static String getTextFromClipboard()
Gets the current clipboard's contents.
static void copyTextToClipboard(const String &text)
Copies a string of text onto the clipboard.
An abstract base class which can be implemented by components that function as text editors.
static uint32 getApproximateMillisecondCounter() noexcept
Less-accurate but faster version of getMillisecondCounter().
int getTimerInterval() const noexcept
Returns the timer's interval.
Definition juce_Timer.h:116
void startTimerHz(int timerFrequencyHz) noexcept
Starts the timer with an interval specified in Hertz.
This class acts as a pointer which will automatically become null if the object to which it points is...
T exchange(T... args)
T flush(T... args)
#define JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED
This macro is used to catch unsafe use of functions which expect to only be called on the message thr...
#define jassert(expression)
Platform-independent assertion macro.
#define JUCE_DECLARE_NON_MOVEABLE(className)
This is a shorthand macro for deleting a class's move constructor and move assignment operator.
#define JUCE_DECLARE_NON_COPYABLE(className)
This is a shorthand macro for deleting a class's copy constructor and copy assignment operator.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define jassertfalse
This will always cause an assertion failure.
#define JUCE_CALLTYPE
This macro defines the C calling convention used as the standard for JUCE calls.
typedef int
JUCE Namespace.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.
Represents a setting according to the XSETTINGS specification.