Skip to content

Commit

Permalink
Merge branch 'boss-window-args' of https://github.com/ad-chaos/kitty
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jan 19, 2024
2 parents bea8fd2 + c2acc24 commit 4a64f81
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kitty/fast_data_types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,12 @@ def get_os_window_size(os_window_id: int) -> Optional[OSWindowSize]:
pass


def get_os_window_pos(os_window_id: int) -> Tuple[int, int]:
pass

def set_os_window_pos(os_window_id: int, x: int, y: int) -> None:
pass

def get_all_processes() -> Tuple[int, ...]:
pass

Expand Down
10 changes: 10 additions & 0 deletions kitty/glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,16 @@ set_os_window_size(OSWindow *os_window, int x, int y) {
glfwSetWindowSize(os_window->handle, x, y);
}

void
get_os_window_pos(OSWindow *os_window, int *x, int *y) {
glfwGetWindowPos(os_window->handle, x, y);
}

void
set_os_window_pos(OSWindow *os_window, int x, int y) {
glfwSetWindowPos(os_window->handle, x, y);
}

static void
get_window_content_scale(GLFWwindow *w, float *xscale, float *yscale, double *xdpi, double *ydpi) {
// if you change this function also change createSurface() in wl_window.c
Expand Down
22 changes: 22 additions & 0 deletions kitty/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,26 @@ PYWRAP1(get_os_window_size) {
Py_RETURN_NONE;
}

PYWRAP1(get_os_window_pos) {
id_type os_window_id;
PA("K", &os_window_id);
WITH_OS_WINDOW(os_window_id)
int x, y;
get_os_window_pos(os_window, &x, &y);
return Py_BuildValue("ii", x, y);
END_WITH_OS_WINDOW
Py_RETURN_NONE;
}

PYWRAP1(set_os_window_pos) {
id_type os_window_id;
int x, y;
PA("Kii", &os_window_id, &x, &y);
WITH_OS_WINDOW(os_window_id)
set_os_window_pos(os_window, x, y);
END_WITH_OS_WINDOW
Py_RETURN_NONE;
}

PYWRAP1(set_boss) {
Py_CLEAR(global_state.boss);
Expand Down Expand Up @@ -1393,6 +1413,8 @@ static PyMethodDef module_methods[] = {
MW(sync_os_window_title, METH_VARARGS),
MW(get_os_window_title, METH_VARARGS),
MW(set_os_window_title, METH_VARARGS),
MW(get_os_window_pos, METH_VARARGS),
MW(set_os_window_pos, METH_VARARGS),
MW(global_font_size, METH_VARARGS),
MW(set_background_image, METH_VARARGS),
MW(os_window_font_size, METH_VARARGS),
Expand Down
2 changes: 2 additions & 0 deletions kitty/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ bool remove_os_window(id_type os_window_id);
void* make_os_window_context_current(OSWindow *w);
void set_os_window_size(OSWindow *os_window, int x, int y);
void get_os_window_size(OSWindow *os_window, int *w, int *h, int *fw, int *fh);
void get_os_window_pos(OSWindow *os_window, int *x, int *y);
void set_os_window_pos(OSWindow *os_window, int x, int y);
void get_os_window_content_scale(OSWindow *os_window, double *xdpi, double *ydpi, float *xscale, float *yscale);
void update_os_window_references(void);
void mark_os_window_for_close(OSWindow* w, CloseRequest cr);
Expand Down

0 comments on commit 4a64f81

Please sign in to comment.