mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
Merge branch 'libsdl-org:main' into patch-1
This commit is contained in:
commit
1472e822b5
2 changed files with 39 additions and 19 deletions
|
|
@ -120,8 +120,6 @@ bool DBUS_ApplyWindowProgress(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
|
||||
const char *progress_visible_str = "progress-visible";
|
||||
const char *progress_str = "progress";
|
||||
int dbus_type_boolean_str = DBUS_TYPE_BOOLEAN;
|
||||
int dbus_type_double_str = DBUS_TYPE_DOUBLE;
|
||||
|
||||
const int progress_visible = ShouldShowProgress(window->progress_state);
|
||||
double progress = (double)window->progress_value;
|
||||
|
|
@ -134,14 +132,14 @@ bool DBUS_ApplyWindowProgress(SDL_VideoDevice *_this, SDL_Window *window)
|
|||
// Set progress visible property
|
||||
dbus->message_iter_open_container(&props, DBUS_TYPE_DICT_ENTRY, NULL, &key_it);
|
||||
dbus->message_iter_append_basic(&key_it, DBUS_TYPE_STRING, &progress_visible_str); // Append progress-visible key data
|
||||
dbus->message_iter_open_container(&key_it, DBUS_TYPE_VARIANT, (const char *)&dbus_type_boolean_str, &value_it);
|
||||
dbus->message_iter_open_container(&key_it, DBUS_TYPE_VARIANT, "b", &value_it);
|
||||
dbus->message_iter_append_basic(&value_it, DBUS_TYPE_BOOLEAN, &progress_visible); // Append progress-visible value data
|
||||
dbus->message_iter_close_container(&key_it, &value_it);
|
||||
dbus->message_iter_close_container(&props, &key_it);
|
||||
// Set progress value property
|
||||
dbus->message_iter_open_container(&props, DBUS_TYPE_DICT_ENTRY, NULL, &key_it);
|
||||
dbus->message_iter_append_basic(&key_it, DBUS_TYPE_STRING, &progress_str); // Append progress key data
|
||||
dbus->message_iter_open_container(&key_it, DBUS_TYPE_VARIANT, (const char *)&dbus_type_double_str, &value_it);
|
||||
dbus->message_iter_open_container(&key_it, DBUS_TYPE_VARIANT, "d", &value_it);
|
||||
dbus->message_iter_append_basic(&value_it, DBUS_TYPE_DOUBLE, &progress); // Append progress value data
|
||||
dbus->message_iter_close_container(&key_it, &value_it);
|
||||
dbus->message_iter_close_container(&props, &key_it);
|
||||
|
|
|
|||
|
|
@ -791,7 +791,11 @@ static void RedrawWindow(WindowState *ctx)
|
|||
break;
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a);
|
||||
if (SDL_TextInputActive(ctx->window)) {
|
||||
SDL_SetRenderDrawColor(renderer, backColor.r, backColor.g, backColor.b, backColor.a);
|
||||
} else {
|
||||
SDL_SetRenderDrawColor(renderer, 0x80, 0x80, 0x80, 0xFF);
|
||||
}
|
||||
SDL_RenderFillRect(renderer, &ctx->textRect);
|
||||
|
||||
/* Initialize the drawn text rectangle for the cursor */
|
||||
|
|
@ -876,20 +880,22 @@ static void RedrawWindow(WindowState *ctx)
|
|||
}
|
||||
|
||||
/* Draw the cursor */
|
||||
Uint64 now = SDL_GetTicks();
|
||||
if ((now - ctx->last_cursor_change) >= CURSOR_BLINK_INTERVAL_MS) {
|
||||
ctx->cursor_visible = !ctx->cursor_visible;
|
||||
ctx->last_cursor_change = now;
|
||||
}
|
||||
if (ctx->cursor_length > 0) {
|
||||
/* We'll show a highlight */
|
||||
SDL_SetRenderDrawBlendMode(renderer, highlight_mode);
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDL_RenderFillRect(renderer, &cursorRect);
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
|
||||
} else if (ctx->cursor_visible) {
|
||||
SDL_SetRenderDrawColor(renderer, lineColor.r, lineColor.g, lineColor.b, lineColor.a);
|
||||
SDL_RenderFillRect(renderer, &cursorRect);
|
||||
if (SDL_TextInputActive(ctx->window)) {
|
||||
Uint64 now = SDL_GetTicks();
|
||||
if ((now - ctx->last_cursor_change) >= CURSOR_BLINK_INTERVAL_MS) {
|
||||
ctx->cursor_visible = !ctx->cursor_visible;
|
||||
ctx->last_cursor_change = now;
|
||||
}
|
||||
if (ctx->cursor_length > 0) {
|
||||
/* We'll show a highlight */
|
||||
SDL_SetRenderDrawBlendMode(renderer, highlight_mode);
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDL_RenderFillRect(renderer, &cursorRect);
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
|
||||
} else if (ctx->cursor_visible) {
|
||||
SDL_SetRenderDrawColor(renderer, lineColor.r, lineColor.g, lineColor.b, lineColor.a);
|
||||
SDL_RenderFillRect(renderer, &cursorRect);
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the candidates */
|
||||
|
|
@ -912,6 +918,9 @@ static void Redraw(void)
|
|||
|
||||
RedrawWindow(&windowstate[i]);
|
||||
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
SDL_RenderDebugTextFormat(renderer, 4, 4, "Window %d", 1 + i);
|
||||
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
}
|
||||
|
|
@ -1076,6 +1085,19 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
break;
|
||||
default:
|
||||
if ((event.key.mod & SDL_KMOD_CTRL) && (event.key.key >= SDLK_KP_1 && event.key.key <= SDLK_KP_9)) {
|
||||
int index = (event.key.key - SDLK_KP_1);
|
||||
if (index < state->num_windows) {
|
||||
SDL_Window *window = state->windows[index];
|
||||
if (SDL_TextInputActive(window)) {
|
||||
SDL_Log("Disabling text input for window %d\n", 1 + index);
|
||||
SDL_StopTextInput(window);
|
||||
} else {
|
||||
SDL_Log("Enabling text input for window %d\n", 1 + index);
|
||||
SDL_StartTextInput(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue