1 /*
2   Copyright 2012-2019 David Robillard <http://drobilla.net>
3   Copyright 2019-2020 Filipe Coelho <falktx@falktx.com>
4 
5   Permission to use, copy, modify, and/or distribute this software for any
6   purpose with or without fee is hereby granted, provided that the above
7   copyright notice and this permission notice appear in all copies.
8 
9   THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17 
18 /**
19    @file mac.cpp HaikuOS implementation.
20 */
21 
22 #include "haiku.h"
23 
24 #include "pugl/detail/implementation.h"
25 
26 PuglStatus
puglGrabFocus(PuglView * view)27 puglGrabFocus(PuglView* view)
28 {
29     view->impl->bView->MakeFocus(true);
30     return PUGL_SUCCESS;
31 }
32 
33 // extras follow
34 
35 void
puglRaiseWindow(PuglView * view)36 puglRaiseWindow(PuglView* view)
37 {
38 }
39 
40 void
puglSetWindowSize(PuglView * view,unsigned int width,unsigned int height)41 puglSetWindowSize(PuglView* view, unsigned int width, unsigned int height)
42 {
43     bView->ResizeTo(width, height);
44 
45     if (bWindow != nullptr && bWindow->LockLooper())
46     {
47         bWindow->MoveTo(50, 50);
48         bWindow->ResizeTo(width, height);
49 
50         if (! forced)
51             bWindow->Flush();
52 
53         bWindow->UnlockLooper();
54     }
55     // TODO resizable
56 }
57 
setVisible(const bool yesNo)58 void setVisible(const bool yesNo)
59 {
60     if (bWindow != nullptr)
61     {
62         if (bWindow->LockLooper())
63         {
64             if (yesNo)
65                 bWindow->Show();
66             else
67                 bWindow->Hide();
68 
69             // TODO use flush?
70             bWindow->Sync();
71             bWindow->UnlockLooper();
72         }
73     }
74     else
75     {
76         if (yesNo)
77             bView->Show();
78         else
79             bView->Hide();
80     }
81 }
82