Signed-off-by: falkTX <falktx@falktx.com>tags/v2.1-rc1
@@ -128,7 +128,7 @@ typedef struct _CarlaCachedPluginInfo { | |||
} CarlaCachedPluginInfo; | |||
/* ------------------------------------------------------------------------------------------------------------ | |||
/* -------------------------------------------------------------------------------------------------------------------- | |||
* get stuff */ | |||
/*! | |||
@@ -164,7 +164,7 @@ CARLA_EXPORT uint carla_get_cached_plugin_count(PluginType ptype, const char* pl | |||
*/ | |||
CARLA_EXPORT const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint index); | |||
/* ------------------------------------------------------------------------------------------------------------ | |||
/* -------------------------------------------------------------------------------------------------------------------- | |||
* set stuff */ | |||
/*! | |||
@@ -182,7 +182,7 @@ CARLA_EXPORT void carla_fputs(bool err, const char* string); | |||
*/ | |||
CARLA_EXPORT void carla_set_process_name(const char* name); | |||
/* ------------------------------------------------------------------------------------------------------------ | |||
/* -------------------------------------------------------------------------------------------------------------------- | |||
* pipes */ | |||
/*! | |||
@@ -241,7 +241,7 @@ CARLA_EXPORT bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handl | |||
CARLA_EXPORT void carla_pipe_client_destroy(CarlaPipeClientHandle handle); | |||
#ifndef CARLA_HOST_H_INCLUDED | |||
/* ------------------------------------------------------------------------------------------------------------ | |||
/* -------------------------------------------------------------------------------------------------------------------- | |||
* info about current library */ | |||
/*! | |||
@@ -255,12 +255,18 @@ CARLA_EXPORT const char* carla_get_library_filename(); | |||
CARLA_EXPORT const char* carla_get_library_folder(); | |||
#endif | |||
// ------------------------------------------------------------------------------------------------------------------- | |||
// TESTING | |||
/* -------------------------------------------------------------------------------------------------------------------- | |||
* window control */ | |||
CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr); | |||
// ------------------------------------------------------------------------------------------------------------------- | |||
CARLA_EXPORT void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2); | |||
CARLA_EXPORT void carla_x11_move_window(uintptr_t winId, int x, int y); | |||
CARLA_EXPORT int* carla_x11_get_window_pos(uintptr_t winId); | |||
/* ----------------------------------------------------------------------------------------------------------------- */ | |||
/** @} */ | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* Carla Plugin Host | |||
* Copyright (C) 2011-2018 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2011-2019 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
@@ -23,6 +23,10 @@ | |||
# import <Cocoa/Cocoa.h> | |||
#endif | |||
#ifdef HAVE_X11 | |||
# include <X11/Xlib.h> | |||
#endif | |||
namespace CB = CarlaBackend; | |||
// ------------------------------------------------------------------------------------------------------------------- | |||
@@ -39,4 +43,72 @@ int carla_cocoa_get_window(void* nsViewPtr) | |||
#endif | |||
} | |||
void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2) | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(winId1 != 0,); | |||
CARLA_SAFE_ASSERT_RETURN(winId2 != 0,); | |||
#ifdef HAVE_X11 | |||
if (::Display* const disp = XOpenDisplay(nullptr)) | |||
{ | |||
XReparentWindow(disp, winId1, winId2, 0, 0); | |||
XMapWindow(disp, winId1); | |||
XCloseDisplay(disp); | |||
} | |||
#endif | |||
} | |||
void carla_x11_move_window(uintptr_t winId, int x, int y) | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(winId != 0,); | |||
#ifdef HAVE_X11 | |||
if (::Display* const disp = XOpenDisplay(nullptr)) | |||
{ | |||
XMoveWindow(disp, winId, x, y); | |||
XCloseDisplay(disp); | |||
} | |||
#else | |||
// unused | |||
return; (void)x; (void)y; | |||
#endif | |||
} | |||
int* carla_x11_get_window_pos(uintptr_t winId) | |||
{ | |||
static int pos[4]; | |||
if (winId == 0) | |||
{ | |||
pos[0] = 0; | |||
pos[1] = 0; | |||
pos[2] = 0; | |||
pos[3] = 0; | |||
} | |||
#ifdef HAVE_X11 | |||
else if (::Display* const disp = XOpenDisplay(nullptr)) | |||
{ | |||
int x, y; | |||
Window child; | |||
XWindowAttributes xwa; | |||
XTranslateCoordinates(disp, winId, XRootWindow(disp, 0), 0, 0, &x, &y, &child); | |||
XGetWindowAttributes(disp, winId, &xwa); | |||
XCloseDisplay(disp); | |||
pos[0] = x - xwa.x; | |||
pos[1] = y - xwa.y; | |||
pos[2] = xwa.x; | |||
pos[3] = xwa.y; | |||
} | |||
#endif | |||
else | |||
{ | |||
pos[0] = 0; | |||
pos[1] = 0; | |||
pos[2] = 0; | |||
pos[3] = 0; | |||
} | |||
return pos; | |||
} | |||
// ------------------------------------------------------------------------------------------------------------------- |
@@ -235,6 +235,15 @@ class CarlaUtils(object): | |||
self.lib.carla_cocoa_get_window.argtypes = [c_uintptr] | |||
self.lib.carla_cocoa_get_window.restype = c_int | |||
self.lib.carla_x11_reparent_window.argtypes = [c_uintptr, c_uintptr] | |||
self.lib.carla_x11_reparent_window.restype = None | |||
self.lib.carla_x11_move_window.argtypes = [c_uintptr, c_int, c_int] | |||
self.lib.carla_x11_move_window.restype = None | |||
self.lib.carla_x11_get_window_pos.argtypes = [c_uintptr] | |||
self.lib.carla_x11_get_window_pos.restype = POINTER(c_int) | |||
# use _putenv on windows | |||
if not WINDOWS: | |||
self.msvcrt = None | |||
@@ -348,4 +357,14 @@ class CarlaUtils(object): | |||
def cocoa_get_window(self, winId): | |||
return self.lib.carla_cocoa_get_window(winId) | |||
def x11_reparent_window(self, winId1, winId2): | |||
self.lib.carla_x11_reparent_window(winId1, winId2) | |||
def x11_move_window(self, winId, x, y): | |||
self.lib.carla_x11_move_window(winId, x, y) | |||
def x11_get_window_pos(self, winId): | |||
data = self.lib.carla_x11_get_window_pos(winId) | |||
return tuple(int(data[i]) for i in range(4)) | |||
# ------------------------------------------------------------------------------------------------------------ |