window_size_title_api #61

Merged
MartinFouilleul merged 8 commits from window_size_title_api into main 2023-08-25 13:29:28 +00:00
1 changed files with 49 additions and 16 deletions
Showing only changes of commit fad375c403 - Show all commits

View File

@ -1471,6 +1471,29 @@ bool oc_window_is_focused(oc_window window)
}
}
void oc_window_set_title(oc_window window, oc_str8 title)
{
dispatch_block_t block = ^{
@autoreleasepool
{
oc_window_data* windowData = oc_window_ptr_from_handle(window);
if(windowData)
{
windowData->osx.nsWindow.title = [[NSString alloc] initWithBytes:title.ptr length:title.len encoding:NSUTF8StringEncoding];
}
}
};
if([NSThread isMainThread])
{
block();
}
else
{
dispatch_sync(dispatch_get_main_queue(), block);
}
}
bool oc_window_is_minimized(oc_window window)
{
@autoreleasepool
@ -1634,9 +1657,9 @@ oc_rect oc_window_get_content_rect(oc_window window)
void oc_window_set_content_rect(oc_window window, oc_rect rect)
{
dispatch_block_t block = ^{
@autoreleasepool
{
oc_window_data* windowData = oc_window_ptr_from_handle(window);
if(windowData)
{
@ -1652,6 +1675,16 @@ void oc_window_set_content_rect(oc_window window, oc_rect rect)
[windowData->osx.nsWindow setFrame:frameRect display:YES];
}
}
};
if([NSThread isMainThread])
{
block();
}
else
{
dispatch_sync(dispatch_get_main_queue(), block);
}
}
//--------------------------------------------------------------------