| @@ -1,29 +0,0 @@ | |||
| /* | |||
| Copyright (C) 2012-2020 Filipe Coelho <falktx@falktx.com> | |||
| Permission to use, copy, modify, and/or distribute this software for any | |||
| purpose with or without fee is hereby granted, provided that the above | |||
| copyright notice and this permission notice appear in all copies. | |||
| THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |||
| OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| /** | |||
| @file extras.c pugl extra implementations for DPF. | |||
| */ | |||
| #include "extras.h" | |||
| #include "../pugl-upstream/src/implementation.h" | |||
| const char* | |||
| puglGetWindowTitle(const PuglView* view) | |||
| { | |||
| return view->title; | |||
| } | |||
| @@ -1,50 +0,0 @@ | |||
| /* | |||
| Copyright (C) 2012-2020 Filipe Coelho <falktx@falktx.com> | |||
| Permission to use, copy, modify, and/or distribute this software for any | |||
| purpose with or without fee is hereby granted, provided that the above | |||
| copyright notice and this permission notice appear in all copies. | |||
| THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |||
| OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| /** | |||
| @file pugl.h pugl extra API for DPF. | |||
| */ | |||
| #ifndef PUGL_EXTRAS_PUGL_H | |||
| #define PUGL_EXTRAS_PUGL_H | |||
| #include "../pugl-upstream/include/pugl/pugl.h" | |||
| PUGL_BEGIN_DECLS | |||
| PUGL_API const char* | |||
| puglGetWindowTitle(const PuglView* view); | |||
| PUGL_API int | |||
| puglGetViewHint(const PuglView* view, PuglViewHint hint); | |||
| PUGL_API void | |||
| puglRaiseWindow(PuglView* view); | |||
| PUGL_API void | |||
| puglSetWindowSize(PuglView* view, unsigned int width, unsigned int height); | |||
| PUGL_API void | |||
| puglUpdateGeometryConstraints(PuglView* view, unsigned int width, unsigned int height, bool aspect); | |||
| #ifdef DISTRHO_OS_WINDOWS | |||
| PUGL_API void | |||
| puglWin32SetWindowResizable(PuglView* view, bool resizable); | |||
| #endif | |||
| PUGL_END_DECLS | |||
| #endif // PUGL_EXTRAS_PUGL_H | |||
| @@ -1,48 +0,0 @@ | |||
| /* | |||
| Copyright (C) 2012-2020 Filipe Coelho <falktx@falktx.com> | |||
| Permission to use, copy, modify, and/or distribute this software for any | |||
| purpose with or without fee is hereby granted, provided that the above | |||
| copyright notice and this permission notice appear in all copies. | |||
| THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |||
| OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| /** | |||
| @file mac.m MacOS extra implementation for DPF. | |||
| */ | |||
| #include "pugl/detail/mac.h" | |||
| void | |||
| puglRaiseWindow(PuglView* view) | |||
| { | |||
| } | |||
| void | |||
| puglSetWindowSize(PuglView* view, unsigned int width, unsigned int height) | |||
| { | |||
| // NOTE: pugl mac code does nothing with x and y | |||
| const PuglRect frame = { 0.0, 0.0, (double)width, (double)height }; | |||
| puglSetFrame(view, frame); | |||
| } | |||
| void | |||
| puglUpdateGeometryConstraints(PuglView* view, unsigned int width, unsigned int height, bool aspect) | |||
| { | |||
| // NOTE this is a combination of puglSetMinSize and puglSetAspectRatio | |||
| view->minWidth = width; | |||
| view->minHeight = height; | |||
| [view->impl->window setContentMinSize:sizePoints(view, width, height)]; | |||
| if (aspect) { | |||
| [view->impl->window setContentAspectRatio:sizePoints(view, width, height)]; | |||
| } | |||
| } | |||
| @@ -1,118 +0,0 @@ | |||
| /* | |||
| Copyright (C) 2012-2020 Filipe Coelho <falktx@falktx.com> | |||
| Permission to use, copy, modify, and/or distribute this software for any | |||
| purpose with or without fee is hereby granted, provided that the above | |||
| copyright notice and this permission notice appear in all copies. | |||
| THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |||
| OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| /** | |||
| @file win.c Windows extra implementation for DPF. | |||
| */ | |||
| #include "pugl/detail/win.h" | |||
| #include "pugl/detail/implementation.h" | |||
| void | |||
| puglRaiseWindow(PuglView* view) | |||
| { | |||
| SetForegroundWindow(view->impl->hwnd); | |||
| SetActiveWindow(view->impl->hwnd); | |||
| return PUGL_SUCCESS; | |||
| } | |||
| void | |||
| puglSetWindowSize(PuglView* view, unsigned int width, unsigned int height) | |||
| { | |||
| view->frame.width = width; | |||
| view->frame.height = height; | |||
| // NOTE the following code matches upstream pugl, except we add SWP_NOMOVE flag | |||
| if (view->impl->hwnd) { | |||
| RECT rect = { (long)frame.x, | |||
| (long)frame.y, | |||
| (long)frame.x + (long)frame.width, | |||
| (long)frame.y + (long)frame.height }; | |||
| AdjustWindowRectEx(&rect, puglWinGetWindowFlags(view), | |||
| FALSE, | |||
| puglWinGetWindowExFlags(view)); | |||
| SetWindowPos(view->impl->hwnd, | |||
| HWND_TOP, | |||
| rect.left, | |||
| rect.top, | |||
| rect.right - rect.left, | |||
| rect.bottom - rect.top, | |||
| SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); | |||
| } | |||
| } | |||
| void | |||
| puglUpdateGeometryConstraints(PuglView* view, unsigned int width, unsigned int height, bool aspect) | |||
| { | |||
| // NOTE this is a combination of puglSetMinSize and puglSetAspectRatio, but stilL TODO on pugl | |||
| Display* display = view->world->impl->display; | |||
| view->minWidth = width; | |||
| view->minHeight = height; | |||
| if (aspect) { | |||
| view->minAspectX = width; | |||
| view->minAspectY = height; | |||
| view->maxAspectX = width; | |||
| view->maxAspectY = height; | |||
| } | |||
| } | |||
| void | |||
| puglWin32RestoreWindow(PuglView* view) | |||
| { | |||
| PuglInternals* impl = view->impl; | |||
| ShowWindow(impl->hwnd, SW_RESTORE); | |||
| SetFocus(impl->hwnd); | |||
| } | |||
| void | |||
| puglWin32ShowWindowCentered(PuglView* view) | |||
| { | |||
| PuglInternals* impl = view->impl; | |||
| RECT rectChild, rectParent; | |||
| if (impl->transientParent != 0 && | |||
| GetWindowRect(impl->hwnd, &rectChild) && | |||
| GetWindowRect(impl->transientParent, &rectParent)) | |||
| { | |||
| SetWindowPos(impl->hwnd, (HWND)impl->transientParent, | |||
| rectParent.left + (rectChild.right-rectChild.left)/2, | |||
| rectParent.top + (rectChild.bottom-rectChild.top)/2, | |||
| 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE); | |||
| } | |||
| else | |||
| { | |||
| ShowWindow(hwnd, SW_SHOWNORMAL); | |||
| } | |||
| SetFocus(impl->hwnd); | |||
| } | |||
| void | |||
| puglWin32SetWindowResizable(PuglView* view, bool resizable) | |||
| { | |||
| PuglInternals* impl = view->impl; | |||
| const int winFlags = resizable ? GetWindowLong(hwnd, GWL_STYLE) | WS_SIZEBOX | |||
| : GetWindowLong(hwnd, GWL_STYLE) & ~WS_SIZEBOX; | |||
| SetWindowLong(impl->hwnd, GWL_STYLE, winFlags); | |||
| } | |||
| @@ -1,111 +0,0 @@ | |||
| /* | |||
| Copyright (C) 2012-2020 Filipe Coelho <falktx@falktx.com> | |||
| Permission to use, copy, modify, and/or distribute this software for any | |||
| purpose with or without fee is hereby granted, provided that the above | |||
| copyright notice and this permission notice appear in all copies. | |||
| THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |||
| WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |||
| MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |||
| ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |||
| WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |||
| ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |||
| OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| /** | |||
| @file x11.c X11 extra implementation for DPF. | |||
| */ | |||
| // NOTE can't import this file twice! | |||
| #ifndef PUGL_DETAIL_X11_H_INCLUDED | |||
| #include "../pugl-upstream/src/x11.h" | |||
| #endif | |||
| #include "../pugl-upstream/src/implementation.h" | |||
| #include <sys/types.h> | |||
| #include <unistd.h> | |||
| void | |||
| puglRaiseWindow(PuglView* view) | |||
| { | |||
| XRaiseWindow(view->impl->display, view->impl->win); | |||
| } | |||
| void | |||
| puglSetWindowSize(PuglView* view, unsigned int width, unsigned int height) | |||
| { | |||
| view->frame.width = width; | |||
| view->frame.height = height; | |||
| if (view->impl->win) { | |||
| #if 0 | |||
| if (! fResizable) | |||
| { | |||
| XSizeHints sizeHints; | |||
| memset(&sizeHints, 0, sizeof(sizeHints)); | |||
| sizeHints.flags = PSize|PMinSize|PMaxSize; | |||
| sizeHints.width = static_cast<int>(width); | |||
| sizeHints.height = static_cast<int>(height); | |||
| sizeHints.min_width = static_cast<int>(width); | |||
| sizeHints.min_height = static_cast<int>(height); | |||
| sizeHints.max_width = static_cast<int>(width); | |||
| sizeHints.max_height = static_cast<int>(height); | |||
| XSetWMNormalHints(xDisplay, xWindow, &sizeHints); | |||
| } | |||
| #endif | |||
| XResizeWindow(view->world->impl->display, view->impl->win, width, height); | |||
| } | |||
| } | |||
| void | |||
| puglUpdateGeometryConstraints(PuglView* view, unsigned int width, unsigned int height, bool aspect) | |||
| { | |||
| // NOTE this is a combination of puglSetMinSize and puglSetAspectRatio | |||
| Display* display = view->world->impl->display; | |||
| view->minWidth = width; | |||
| view->minHeight = height; | |||
| if (aspect) { | |||
| view->minAspectX = width; | |||
| view->minAspectY = height; | |||
| view->maxAspectX = width; | |||
| view->maxAspectY = height; | |||
| } | |||
| #if 0 | |||
| if (view->impl->win) { | |||
| XSizeHints sizeHints = getSizeHints(view); | |||
| XSetNormalHints(display, view->impl->win, &sizeHints); | |||
| // NOTE old code used this instead | |||
| // XSetWMNormalHints(display, view->impl->win, &sizeHints); | |||
| } | |||
| #endif | |||
| } | |||
| void | |||
| puglExtraSetWindowTypeAndPID(PuglView* view) | |||
| { | |||
| PuglInternals* const impl = view->impl; | |||
| const pid_t pid = getpid(); | |||
| const Atom _nwp = XInternAtom(impl->display, "_NET_WM_PID", False); | |||
| XChangeProperty(impl->display, impl->win, _nwp, XA_CARDINAL, 32, PropModeReplace, (const uchar*)&pid, 1); | |||
| const Atom _wt = XInternAtom(impl->display, "_NET_WM_WINDOW_TYPE", False); | |||
| // Setting the window to both dialog and normal will produce a decorated floating dialog | |||
| // Order is important: DIALOG needs to come before NORMAL | |||
| const Atom _wts[2] = { | |||
| XInternAtom(impl->display, "_NET_WM_WINDOW_TYPE_DIALOG", False), | |||
| XInternAtom(impl->display, "_NET_WM_WINDOW_TYPE_NORMAL", False) | |||
| }; | |||
| XChangeProperty(impl->display, impl->win, _wt, XA_ATOM, 32, PropModeReplace, (const uchar*)&_wts, 2); | |||
| } | |||