mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
ver: upgrade to wlroots-0.19 version
This commit is contained in:
parent
54de782f90
commit
d636ef97ac
12 changed files with 2179 additions and 1947 deletions
351
IM.h
351
IM.h
|
|
@ -1,7 +1,11 @@
|
|||
#ifdef IM
|
||||
#include <assert.h>
|
||||
#include <wlr/types/wlr_input_method_v2.h>
|
||||
#include <wlr/types/wlr_text_input_v3.h>
|
||||
#include <wlr/types/wlr_input_method_v2.h>
|
||||
|
||||
#ifdef HANDWRITE
|
||||
#include <handwrite-unstable-v1-protocol.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The relay structure manages the relationship between text-input and
|
||||
|
|
@ -53,6 +57,7 @@ struct dwl_text_input {
|
|||
struct wl_listener text_input_destroy;
|
||||
};
|
||||
|
||||
|
||||
struct dwl_input_popup {
|
||||
struct dwl_input_method_relay *relay;
|
||||
struct wlr_input_popup_surface_v2 *popup_surface;
|
||||
|
|
@ -65,6 +70,7 @@ struct dwl_input_popup {
|
|||
int x, y;
|
||||
bool visible;
|
||||
|
||||
|
||||
struct wl_listener popup_map;
|
||||
struct wl_listener popup_unmap;
|
||||
struct wl_listener popup_destroy;
|
||||
|
|
@ -72,6 +78,7 @@ struct dwl_input_popup {
|
|||
//struct wl_listener focused_surface_unmap;
|
||||
};
|
||||
|
||||
|
||||
void dwl_input_method_relay_init(struct dwl_input_method_relay *relay);
|
||||
// Updates currently focused surface. Surface must belong to the same
|
||||
// seat.
|
||||
|
|
@ -82,74 +89,90 @@ static void handle_im_grab_keyboard(struct wl_listener *listener, void *data);
|
|||
static void handle_im_keyboard_grab_destroy(struct wl_listener *listener,
|
||||
void *data);
|
||||
static void input_popup_update(struct dwl_input_popup *popup);
|
||||
static struct dwl_text_input *relay_get_focused_text_input(struct dwl_input_method_relay *relay);
|
||||
|
||||
struct wlr_input_method_manager_v2 *input_method_manager;
|
||||
struct wlr_text_input_manager_v3 *text_input_manager;
|
||||
struct dwl_input_method_relay *input_relay;
|
||||
// static int NO_printstatus=0; // i suspect that printstatus will make dwl hang with fcitx5
|
||||
|
||||
#ifdef HANDWRITE
|
||||
static void receive_handwrite_text_from_handwrite_input_app(struct wl_client *client, struct wl_resource *resource, const char *text){
|
||||
struct dwl_text_input *text_input;
|
||||
|
||||
wlr_log(WLR_INFO,"receive_handwrite_text_from_handwrite_input_app called with:%s",text);
|
||||
text_input = relay_get_focused_text_input(input_relay);
|
||||
|
||||
if (text_input){
|
||||
wlr_log(WLR_INFO,"receive_handwrite_text_from_handwrite_input_app will commit %s",text);
|
||||
wlr_text_input_v3_send_commit_string(text_input->input,text);
|
||||
wlr_text_input_v3_send_done(text_input->input);
|
||||
}else wlr_log(WLR_INFO, "no focused text_input for handwrite");
|
||||
}
|
||||
|
||||
const struct zwp_handwrite_v1_interface handwrite_interface_impl = {
|
||||
.send_handwrite_text = receive_handwrite_text_from_handwrite_input_app,
|
||||
};
|
||||
|
||||
// struct wl_client* handwrite_app=NULL;//TODO: multiple handwrite app instance?
|
||||
// void zwp_handwrite_v1_handle_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id){
|
||||
// wlr_log(WLR_INFO,"zwp_handwrite_v1_handle_bind called");
|
||||
// handwrite_app = client;
|
||||
// struct wl_resource *resource = wl_resource_create(client, &zwp_handwrite_v1_interface, zwp_handwrite_v1_interface.version, id);
|
||||
// wl_resource_set_implementation(resource, &handwrite_interface_impl, NULL, NULL);
|
||||
// }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get keyboard grab of the seat from sway_keyboard if we should forward events
|
||||
* to it.
|
||||
*
|
||||
* Returns NULL if the keyboard is not grabbed by an input method,
|
||||
* or if event is from virtual keyboard of the same client as grab.
|
||||
* TODO: see https://github.com/swaywm/wlroots/issues/2322
|
||||
* or if event is from virtual keyboard
|
||||
*/
|
||||
static struct wlr_input_method_keyboard_grab_v2 *
|
||||
keyboard_get_im_grab(Keyboard *kb) {
|
||||
static struct wlr_input_method_keyboard_grab_v2 *keyboard_get_im_grab(KeyboardGroup* kb) {
|
||||
struct wlr_input_method_v2 *input_method = input_relay->input_method;
|
||||
struct wlr_virtual_keyboard_v1 *virtual_keyboard =
|
||||
wlr_input_device_get_virtual_keyboard(&kb->wlr_keyboard->base);
|
||||
if (!input_method || !input_method->keyboard_grab ||
|
||||
(virtual_keyboard &&
|
||||
wl_resource_get_client(virtual_keyboard->resource) ==
|
||||
wl_resource_get_client(input_method->keyboard_grab->resource))) {
|
||||
|
||||
if (!input_method){
|
||||
wlr_log(WLR_DEBUG,
|
||||
"keypress keyboard_get_im_grab return NULL:no input_method");
|
||||
} else if (!input_method->keyboard_grab) {
|
||||
wlr_log(WLR_DEBUG, "keypress keyboard_get_im_grab return NULL:no "
|
||||
"input_method->keyboard_grab");
|
||||
}
|
||||
|
||||
if (virtual_keyboard) {
|
||||
wlr_log(WLR_DEBUG,
|
||||
"keypress keyboard_get_im_grab return NULL:virtual_keyboard");
|
||||
}
|
||||
|
||||
wlr_log(WLR_DEBUG, "keypress keyboard_get_im_grab return NULL:no input_method");
|
||||
return NULL;
|
||||
}
|
||||
return input_method->keyboard_grab;
|
||||
} else if (!input_method->keyboard_grab){
|
||||
wlr_log(WLR_DEBUG, "keypress keyboard_get_im_grab return NULL:no input_method->keyboard_grab");
|
||||
return NULL;
|
||||
} else if (kb != kb_group) {
|
||||
wlr_log(WLR_DEBUG, "keypress keyboard_get_im_grab return NULL:virtual_keyboard");
|
||||
return NULL;
|
||||
} else return input_method->keyboard_grab;
|
||||
}
|
||||
|
||||
static void handle_im_grab_keyboard(struct wl_listener *listener, void *data) {
|
||||
struct dwl_input_method_relay *relay =
|
||||
wl_container_of(listener, relay, input_method_grab_keyboard);
|
||||
// wl_container_of 宏的第二个参数sample,
|
||||
// 这里是relay,无须是已经初始化的变量,只要是返回值类型的变量就可以了,这里就是dwl_input_method_relay类型的变量
|
||||
struct dwl_input_method_relay *relay = wl_container_of(listener, relay,
|
||||
input_method_grab_keyboard);
|
||||
//wl_container_of 宏的第二个参数sample, 这里是relay,无须是已经初始化的变量,只要是返回值类型的变量就可以了,这里就是dwl_input_method_relay类型的变量
|
||||
struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = data;
|
||||
|
||||
// send modifier state to grab
|
||||
struct wlr_keyboard *active_keyboard = wlr_seat_get_keyboard(seat);
|
||||
if (active_keyboard){
|
||||
wlr_log(WLR_INFO,"im_grab_keyboard");
|
||||
wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab,
|
||||
active_keyboard);
|
||||
wlr_input_method_keyboard_grab_v2_send_modifiers(
|
||||
keyboard_grab, &active_keyboard->modifiers);
|
||||
} else
|
||||
wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab,active_keyboard);
|
||||
wlr_input_method_keyboard_grab_v2_send_modifiers(keyboard_grab, &active_keyboard->modifiers);
|
||||
}
|
||||
else
|
||||
wlr_log(WLR_INFO,"im_grab_keyboard but no active keyboard");
|
||||
|
||||
|
||||
wl_signal_add(&keyboard_grab->events.destroy,
|
||||
&relay->input_method_keyboard_grab_destroy);
|
||||
relay->input_method_keyboard_grab_destroy.notify =
|
||||
handle_im_keyboard_grab_destroy;
|
||||
}
|
||||
|
||||
static void handle_im_keyboard_grab_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct dwl_input_method_relay *relay =
|
||||
wl_container_of(listener, relay, input_method_keyboard_grab_destroy);
|
||||
static void handle_im_keyboard_grab_destroy(struct wl_listener *listener, void *data) {
|
||||
struct dwl_input_method_relay *relay = wl_container_of(listener, relay,
|
||||
input_method_keyboard_grab_destroy);
|
||||
struct wlr_input_method_keyboard_grab_v2 *keyboard_grab = data;
|
||||
wlr_log(WLR_DEBUG,"im_keyboard_grab_destroy");
|
||||
wl_list_remove(&relay->input_method_keyboard_grab_destroy.link);
|
||||
|
|
@ -160,8 +183,9 @@ static void handle_im_keyboard_grab_destroy(struct wl_listener *listener,
|
|||
}
|
||||
}
|
||||
|
||||
static struct dwl_text_input *
|
||||
relay_get_focusable_text_input(struct dwl_input_method_relay *relay) {
|
||||
|
||||
static struct dwl_text_input *relay_get_focusable_text_input(
|
||||
struct dwl_input_method_relay *relay) {
|
||||
struct dwl_text_input *text_input = NULL;
|
||||
wl_list_for_each(text_input, &relay->text_inputs, link) {
|
||||
if (text_input->pending_focused_surface) {
|
||||
|
|
@ -171,8 +195,8 @@ relay_get_focusable_text_input(struct dwl_input_method_relay *relay) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct dwl_text_input *
|
||||
relay_get_focused_text_input(struct dwl_input_method_relay *relay) {
|
||||
static struct dwl_text_input *relay_get_focused_text_input(
|
||||
struct dwl_input_method_relay *relay) {
|
||||
struct dwl_text_input *text_input = NULL;
|
||||
wl_list_for_each(text_input, &relay->text_inputs, link) {
|
||||
if (text_input->input->focused_surface) {
|
||||
|
|
@ -185,8 +209,8 @@ relay_get_focused_text_input(struct dwl_input_method_relay *relay) {
|
|||
static void handle_im_commit(struct wl_listener *listener, void *data) {
|
||||
struct wlr_input_method_v2 *context;
|
||||
|
||||
struct dwl_input_method_relay *relay =
|
||||
wl_container_of(listener, relay, input_method_commit);
|
||||
struct dwl_input_method_relay *relay = wl_container_of(listener, relay,
|
||||
input_method_commit);
|
||||
|
||||
struct dwl_text_input *text_input = relay_get_focused_text_input(relay);
|
||||
if (!text_input) {
|
||||
|
|
@ -207,18 +231,17 @@ static void handle_im_commit(struct wl_listener *listener, void *data) {
|
|||
context->current.commit_text);
|
||||
wlr_log(WLR_DEBUG,"commit_text: %s", context->current.commit_text);
|
||||
}
|
||||
if (context->current.delete.before_length ||
|
||||
context->current.delete.after_length) {
|
||||
wlr_text_input_v3_send_delete_surrounding_text(
|
||||
text_input->input, context->current.delete.before_length,
|
||||
if (context->current.delete.before_length
|
||||
|| context->current.delete.after_length) {
|
||||
wlr_text_input_v3_send_delete_surrounding_text(text_input->input,
|
||||
context->current.delete.before_length,
|
||||
context->current.delete.after_length);
|
||||
}
|
||||
wlr_text_input_v3_send_done(text_input->input);
|
||||
}
|
||||
|
||||
static void
|
||||
text_input_set_pending_focused_surface(struct dwl_text_input *text_input,
|
||||
struct wlr_surface *surface) {
|
||||
static void text_input_set_pending_focused_surface(
|
||||
struct dwl_text_input *text_input, struct wlr_surface *surface) {
|
||||
wl_list_remove(&text_input->pending_focused_surface_destroy.link);
|
||||
text_input->pending_focused_surface = surface;
|
||||
|
||||
|
|
@ -233,11 +256,17 @@ text_input_set_pending_focused_surface(struct dwl_text_input *text_input,
|
|||
static void handle_im_destroy(struct wl_listener *listener, void *data) {
|
||||
struct dwl_text_input *text_input;
|
||||
|
||||
struct dwl_input_method_relay *relay =
|
||||
wl_container_of(listener, relay, input_method_destroy);
|
||||
struct dwl_input_method_relay *relay = wl_container_of(listener, relay,
|
||||
input_method_destroy);
|
||||
struct wlr_input_method_v2 *context = data;
|
||||
wlr_log(WLR_INFO,"IM destroy");
|
||||
assert(context == relay->input_method);
|
||||
|
||||
wl_list_remove(&relay->input_method_commit.link);
|
||||
wl_list_remove(&relay->input_method_grab_keyboard.link);
|
||||
wl_list_remove(&relay->input_method_new_popup_surface.link);
|
||||
wl_list_remove(&relay->input_method_destroy.link);
|
||||
|
||||
relay->input_method = NULL;
|
||||
|
||||
text_input = relay_get_focused_text_input(relay);
|
||||
|
|
@ -258,21 +287,20 @@ static void relay_send_im_state(struct dwl_input_method_relay *relay,
|
|||
return;
|
||||
}
|
||||
// TODO: only send each of those if they were modified
|
||||
wlr_input_method_v2_send_surrounding_text(
|
||||
input_method, input->current.surrounding.text,
|
||||
input->current.surrounding.cursor, input->current.surrounding.anchor);
|
||||
wlr_input_method_v2_send_surrounding_text(input_method,
|
||||
input->current.surrounding.text, input->current.surrounding.cursor,
|
||||
input->current.surrounding.anchor);
|
||||
wlr_input_method_v2_send_text_change_cause(input_method,
|
||||
input->current.text_change_cause);
|
||||
wlr_input_method_v2_send_content_type(input_method,
|
||||
input->current.content_type.hint,
|
||||
input->current.content_type.purpose);
|
||||
input->current.content_type.hint, input->current.content_type.purpose);
|
||||
wlr_input_method_v2_send_done(input_method);
|
||||
// TODO: pass intent, display popup size
|
||||
}
|
||||
|
||||
static void handle_text_input_enable(struct wl_listener *listener, void *data) {
|
||||
struct dwl_text_input *text_input =
|
||||
wl_container_of(listener, text_input, text_input_enable);
|
||||
struct dwl_text_input *text_input = wl_container_of(listener, text_input,
|
||||
text_input_enable);
|
||||
if (text_input->relay->input_method == NULL) {
|
||||
wlr_log(WLR_INFO, "text_input_enable but input method is NULL");
|
||||
return;
|
||||
|
|
@ -289,16 +317,14 @@ static void handle_text_input_enable(struct wl_listener *listener, void *data) {
|
|||
|
||||
/* static void handle_text_input_commit(struct wl_listener *listener, */
|
||||
/* void *data) { */
|
||||
/* struct dwl_text_input *text_input = wl_container_of(listener,
|
||||
* text_input, */
|
||||
/* struct dwl_text_input *text_input = wl_container_of(listener, text_input, */
|
||||
/* text_input_commit); */
|
||||
/* if (!text_input->input->current_enabled) { */
|
||||
/* wlr_log(WLR_INFO, "text_input_commit but not enabled"); */
|
||||
/* return; */
|
||||
/* } */
|
||||
/* if (text_input->relay->input_method == NULL) { */
|
||||
/* wlr_log(WLR_INFO, "text_input_commit but input method is NULL");
|
||||
*/
|
||||
/* wlr_log(WLR_INFO, "text_input_commit but input method is NULL"); */
|
||||
/* return; */
|
||||
/* } */
|
||||
/* wlr_log(WLR_DEBUG, "text_input_commit"); */
|
||||
|
|
@ -318,20 +344,21 @@ static void relay_disable_text_input(struct dwl_input_method_relay *relay,
|
|||
wlr_input_method_v2_send_deactivate(relay->input_method);
|
||||
wlr_log(WLR_INFO,"input_method deactivate for xwayland");
|
||||
#endif
|
||||
// but if you keep the line above while remove the line below, input Chinese
|
||||
// in geogebra(xwayland) won't work
|
||||
//but if you keep the line above while remove the line below, input Chinese in geogebra(xwayland) won't work
|
||||
relay_send_im_state(relay, text_input->input);
|
||||
}
|
||||
|
||||
|
||||
static void handle_text_input_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct dwl_text_input *text_input =
|
||||
wl_container_of(listener, text_input, text_input_destroy);
|
||||
struct dwl_text_input *text_input = wl_container_of(listener, text_input,
|
||||
text_input_destroy);
|
||||
|
||||
if (text_input->input->current_enabled) {
|
||||
wlr_log(WLR_INFO,"text_input_destroy when still enabled");
|
||||
relay_disable_text_input(text_input->relay, text_input);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
wlr_log(WLR_INFO,"text_input_destroy");
|
||||
}
|
||||
|
||||
|
|
@ -346,8 +373,8 @@ static void handle_text_input_destroy(struct wl_listener *listener,
|
|||
|
||||
static void handle_pending_focused_surface_destroy(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct dwl_text_input *text_input =
|
||||
wl_container_of(listener, text_input, pending_focused_surface_destroy);
|
||||
struct dwl_text_input *text_input = wl_container_of(listener, text_input,
|
||||
pending_focused_surface_destroy);
|
||||
struct wlr_surface *surface = data;
|
||||
assert(text_input->pending_focused_surface == surface);
|
||||
text_input->pending_focused_surface = NULL;
|
||||
|
|
@ -355,10 +382,11 @@ static void handle_pending_focused_surface_destroy(struct wl_listener *listener,
|
|||
wl_list_init(&text_input->pending_focused_surface_destroy.link);
|
||||
}
|
||||
|
||||
|
||||
static void relay_handle_text_input_new(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct dwl_input_method_relay *relay =
|
||||
wl_container_of(listener, relay, text_input_new);
|
||||
struct dwl_input_method_relay *relay = wl_container_of(listener, relay,
|
||||
text_input_new);
|
||||
struct wlr_text_input_v3 *wlr_text_input = data;
|
||||
if (seat != wlr_text_input->seat) {
|
||||
return;
|
||||
|
|
@ -393,22 +421,20 @@ static void relay_handle_text_input_new(struct wl_listener *listener,
|
|||
wl_list_init(&input->pending_focused_surface_destroy.link);
|
||||
}
|
||||
|
||||
|
||||
static LayerSurface* layer_surface_from_wlr_layer_surface_v1(
|
||||
struct wlr_layer_surface_v1* layer_surface) {
|
||||
return layer_surface->data;
|
||||
}
|
||||
|
||||
|
||||
static void get_parent_and_output_box(struct wlr_surface *focused_surface,
|
||||
struct wlr_box *parent,
|
||||
struct wlr_box *output_box) {
|
||||
struct wlr_box *parent, struct wlr_box *output_box) {
|
||||
struct wlr_output *output;
|
||||
struct wlr_box output_box_tmp;
|
||||
struct wlr_layer_surface_v1 *layer_surface;
|
||||
Client *client = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
|
||||
if ((layer_surface =
|
||||
wlr_layer_surface_v1_try_from_wlr_surface(focused_surface))) {
|
||||
if ((layer_surface=wlr_layer_surface_v1_try_from_wlr_surface(focused_surface))) {
|
||||
LayerSurface* layer =
|
||||
layer_surface_from_wlr_layer_surface_v1(layer_surface);
|
||||
output = layer->layer_surface->output;
|
||||
|
|
@ -416,51 +442,39 @@ static void get_parent_and_output_box(struct wlr_surface *focused_surface,
|
|||
*parent = layer->geom;
|
||||
parent->x += output_box_tmp.x;
|
||||
parent->y += output_box_tmp.y;
|
||||
wlr_log(WLR_INFO,
|
||||
"get_parent_and_output_box layersurface output_box_tmp->x %d y %d",
|
||||
output_box_tmp.x, output_box_tmp.y);
|
||||
wlr_log(WLR_INFO,
|
||||
"get_parent_and_output_box layersurface parent->x %d y %d",
|
||||
parent->x, parent->y);
|
||||
wlr_log(WLR_INFO,"get_parent_and_output_box layersurface output_box_tmp->x %d y %d",output_box_tmp.x, output_box_tmp.y);
|
||||
wlr_log(WLR_INFO,"get_parent_and_output_box layersurface parent->x %d y %d",parent->x,parent->y);
|
||||
} else {
|
||||
//Client *client = client_from_wlr_surface(focused_surface);
|
||||
Client *client = NULL;
|
||||
LayerSurface *l = NULL;
|
||||
toplevel_from_wlr_surface(focused_surface, &client, &l);
|
||||
|
||||
output = wlr_output_layout_output_at(output_layout, client->geom.x,
|
||||
client->geom.y);
|
||||
output = wlr_output_layout_output_at(output_layout,
|
||||
client->geom.x, client->geom.y);
|
||||
wlr_output_layout_get_box(output_layout, output,&output_box_tmp);
|
||||
|
||||
parent->x = client->geom.x + client->bw;
|
||||
parent->y = client->geom.y + client->bw;
|
||||
parent->width = client->geom.width;
|
||||
parent->height = client->geom.height;
|
||||
wlr_log(WLR_INFO,
|
||||
"get_parent_and_output_box client output_box_tmp->x %d y %d",
|
||||
output_box_tmp.x, output_box_tmp.y);
|
||||
wlr_log(WLR_INFO,
|
||||
"get_parent_and_output_box client client->geom.x %d y %d",
|
||||
client->geom.x, client->geom.y);
|
||||
wlr_log(WLR_INFO, "get_parent_and_output_box client client->bw %d",
|
||||
client->bw);
|
||||
wlr_log(WLR_INFO, "get_parent_and_output_box client parent->x %d y %d",
|
||||
parent->x, parent->y);
|
||||
wlr_log(WLR_INFO,"get_parent_and_output_box client output_box_tmp->x %d y %d",output_box_tmp.x, output_box_tmp.y);
|
||||
wlr_log(WLR_INFO,"get_parent_and_output_box client client->geom.x %d y %d",client->geom.x,client->geom.y);
|
||||
wlr_log(WLR_INFO,"get_parent_and_output_box client client->bw %d",client->bw);
|
||||
wlr_log(WLR_INFO,"get_parent_and_output_box client parent->x %d y %d",parent->x,parent->y);
|
||||
}
|
||||
|
||||
//*output_box = output_box_tmp;
|
||||
memcpy(output_box,&output_box_tmp,sizeof(struct wlr_box));
|
||||
wlr_log(WLR_INFO,
|
||||
"get_parent_and_output_box output_box x %d y %d width %d height %d",
|
||||
output_box->x, output_box->y, output_box->width, output_box->height);
|
||||
wlr_log(WLR_INFO,"get_parent_and_output_box output_box x %d y %d width %d height %d",output_box->x,output_box->y,output_box->width,output_box->height);
|
||||
}
|
||||
|
||||
// 如果当前focused wlr_text_input_v3.features 满足
|
||||
// WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE,
|
||||
// 不含这个feature就弹出在父窗口左上角 根据
|
||||
// wlr_text_input_v3.current.cursor_rectangle 计算出一个wlr_box 再调用
|
||||
// wlr_input_popup_surface_v2_send_text_input_rectangle 和
|
||||
// wlr_scene_node_set_position
|
||||
// 如果当前focused wlr_text_input_v3.features 满足 WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE, 不含这个feature就弹出在父窗口左上角
|
||||
// 根据 wlr_text_input_v3.current.cursor_rectangle 计算出一个wlr_box
|
||||
// 再调用 wlr_input_popup_surface_v2_send_text_input_rectangle 和 wlr_scene_node_set_position
|
||||
static void input_popup_update(struct dwl_input_popup *popup) {
|
||||
struct wlr_surface* focused_surface;
|
||||
struct wlr_box output_box, parent, input_cursor;
|
||||
struct wlr_box output_box, parent, cursor;
|
||||
int x1, x2, y1, y2, x, y, available_right, available_left, available_down,
|
||||
available_up, popup_width, popup_height;
|
||||
bool cursor_rect, x1_in_bounds, y1_in_bounds, x2_in_bounds, y2_in_bounds;
|
||||
|
|
@ -471,18 +485,17 @@ static void input_popup_update(struct dwl_input_popup *popup) {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/743da5c0ae723098fe772aadb93810f60e700ab9
|
||||
//TODO: https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/743da5c0ae723098fe772aadb93810f60e700ab9
|
||||
|
||||
if (!popup->popup_surface->surface->mapped) {
|
||||
return;
|
||||
}
|
||||
|
||||
cursor_rect = text_input->input->current.features &
|
||||
WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE;
|
||||
cursor_rect = text_input->input->current.features
|
||||
& WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE;
|
||||
|
||||
focused_surface = text_input->input->focused_surface;
|
||||
input_cursor = text_input->input->current.cursor_rectangle;
|
||||
cursor = text_input->input->current.cursor_rectangle;
|
||||
|
||||
get_parent_and_output_box(focused_surface, &parent, &output_box);
|
||||
|
||||
|
|
@ -490,92 +503,80 @@ static void input_popup_update(struct dwl_input_popup *popup) {
|
|||
popup_height = popup->popup_surface->surface->current.height;
|
||||
|
||||
if (!cursor_rect) {
|
||||
input_cursor.x = 0;
|
||||
input_cursor.y = 0;
|
||||
input_cursor.width = parent.width;
|
||||
input_cursor.height = parent.height;
|
||||
cursor.x = 0;
|
||||
cursor.y = 0;
|
||||
cursor.width = parent.width;
|
||||
cursor.height = parent.height;
|
||||
wlr_log(WLR_INFO,"input_popup_update !cursor_rect");
|
||||
|
||||
popup->x=parent.x;
|
||||
popup->y=parent.y;
|
||||
popup->visible=true;
|
||||
} else {
|
||||
wlr_log(WLR_INFO,
|
||||
"input_popup_update input_cursor x %d y %d width %d height %d",
|
||||
input_cursor.x, input_cursor.y, input_cursor.width,
|
||||
input_cursor.height);
|
||||
}
|
||||
else {
|
||||
wlr_log(WLR_INFO,"input_popup_update cursor x %d y %d width %d height %d",cursor.x,cursor.y,cursor.width,cursor.height);
|
||||
|
||||
x1 = parent.x + input_cursor.x;
|
||||
x2 = parent.x + input_cursor.x + input_cursor.width;
|
||||
y1 = parent.y + input_cursor.y;
|
||||
y2 = parent.y + input_cursor.y + input_cursor.height;
|
||||
x1 = parent.x + cursor.x;
|
||||
x2 = parent.x + cursor.x + cursor.width;
|
||||
y1 = parent.y + cursor.y;
|
||||
y2 = parent.y + cursor.y + cursor.height;
|
||||
x = x1;
|
||||
y = y2;
|
||||
|
||||
wlr_log(WLR_INFO, "input_popup_update x1 %d x2 %d y1 %d y2 %d; x %d y %d",
|
||||
x1, x2, y1, y2, x, y);
|
||||
wlr_log(WLR_INFO,"input_popup_update x1 %d x2 %d y1 %d y2 %d; x %d y %d",x1,x2,y1,y2,x,y);
|
||||
available_right = output_box.x + output_box.width - x1;
|
||||
available_left = x2 - output_box.x;
|
||||
if (available_right < popup_width && available_left > available_right) {
|
||||
x = x2 - popup_width;
|
||||
wlr_log(WLR_INFO,
|
||||
"input_popup_update available_left %d popup_width %d "
|
||||
"available_right %d; x %d",
|
||||
available_left, popup_width, available_right, x);
|
||||
wlr_log(WLR_INFO,"input_popup_update available_left %d popup_width %d available_right %d; x %d",available_left,popup_width,available_right,x);
|
||||
}
|
||||
|
||||
available_down = output_box.y + output_box.height - y2;
|
||||
available_up = y1 - output_box.y;
|
||||
if (available_down < popup_height && available_up > available_down) {
|
||||
y = y1 - popup_height;
|
||||
wlr_log(WLR_INFO,
|
||||
"input_popup_update available up %d popup_height %d "
|
||||
"available_down %d; y %d",
|
||||
available_up, popup_height, available_down, y);
|
||||
wlr_log(WLR_INFO,"input_popup_update available up %d popup_height %d available_down %d; y %d",available_up,popup_height,available_down,y);
|
||||
}
|
||||
|
||||
popup->x = x;
|
||||
popup->y = y;
|
||||
|
||||
// Hide popup if input_cursor position is completely out of bounds
|
||||
x1_in_bounds = (input_cursor.x >= 0 && input_cursor.x < parent.width);
|
||||
y1_in_bounds = (input_cursor.y >= 0 && input_cursor.y < parent.height);
|
||||
x2_in_bounds = (input_cursor.x + input_cursor.width >= 0 &&
|
||||
input_cursor.x + input_cursor.width < parent.width);
|
||||
y2_in_bounds = (input_cursor.y + input_cursor.height >= 0 &&
|
||||
input_cursor.y + input_cursor.height < parent.height);
|
||||
// Hide popup if cursor position is completely out of bounds
|
||||
x1_in_bounds = (cursor.x >= 0 && cursor.x < parent.width);
|
||||
y1_in_bounds = (cursor.y >= 0 && cursor.y < parent.height);
|
||||
x2_in_bounds = (cursor.x + cursor.width >= 0
|
||||
&& cursor.x + cursor.width < parent.width);
|
||||
y2_in_bounds = (cursor.y + cursor.height >= 0
|
||||
&& cursor.y + cursor.height < parent.height);
|
||||
popup->visible =
|
||||
(x1_in_bounds && y1_in_bounds) || (x2_in_bounds && y2_in_bounds);
|
||||
|
||||
struct wlr_box box = {
|
||||
.x = x1 - x,
|
||||
.y = y1 - y,
|
||||
.width = input_cursor.width,
|
||||
.height = input_cursor.height,
|
||||
.width = cursor.width,
|
||||
.height = cursor.height,
|
||||
};
|
||||
wlr_input_popup_surface_v2_send_text_input_rectangle(popup->popup_surface,
|
||||
&box);
|
||||
wlr_log(WLR_INFO,
|
||||
"input_popup_update send_text_input_rect box.x %d box.y %d", box.x,
|
||||
box.y);
|
||||
wlr_input_popup_surface_v2_send_text_input_rectangle(
|
||||
popup->popup_surface, &box);
|
||||
wlr_log(WLR_INFO,"input_popup_update send_text_input_rect box.x %d box.y %d",box.x,box.y);
|
||||
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "input_popup_update x %d y %d visible %s", popup->x,
|
||||
popup->y, popup->visible ? "true" : "false");
|
||||
wlr_log(WLR_INFO,"input_popup_update x %d y %d visible %s",popup->x,popup->y,popup->visible?"true":"false");
|
||||
wlr_scene_node_set_position(&popup->scene->node, popup->x, popup->y);
|
||||
}
|
||||
|
||||
static void handle_im_popup_map(struct wl_listener *listener, void *data) {
|
||||
struct dwl_input_popup *popup = wl_container_of(listener, popup, popup_map);
|
||||
struct dwl_input_popup *popup =
|
||||
wl_container_of(listener, popup, popup_map);
|
||||
|
||||
wlr_log(WLR_INFO, "IM_popup_map");
|
||||
|
||||
//popup->scene = &wlr_scene_tree_create(layers[LyrIMPopup])->node;
|
||||
popup->scene = wlr_scene_tree_create(layers[LyrIMPopup]);
|
||||
popup->scene_surface = wlr_scene_subsurface_tree_create(
|
||||
popup->scene, popup->popup_surface->surface);
|
||||
// popup->scene_surface =
|
||||
// &wlr_scene_subsurface_tree_create(popup->scene->parent,popup->popup_surface->surface)->node;
|
||||
popup->scene_surface = wlr_scene_subsurface_tree_create(popup->scene,popup->popup_surface->surface);
|
||||
//popup->scene_surface = &wlr_scene_subsurface_tree_create(popup->scene->parent,popup->popup_surface->surface)->node;
|
||||
//popup->scene_surface->data = popup;
|
||||
popup->scene_surface->node.data = popup;
|
||||
|
||||
|
|
@ -585,7 +586,8 @@ static void handle_im_popup_map(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
static void handle_im_popup_unmap(struct wl_listener *listener, void *data) {
|
||||
struct dwl_input_popup *popup = wl_container_of(listener, popup, popup_unmap);
|
||||
struct dwl_input_popup *popup =
|
||||
wl_container_of(listener, popup, popup_unmap);
|
||||
//input_popup_update(popup);
|
||||
|
||||
wlr_log(WLR_INFO,"im_popup_unmap");
|
||||
|
|
@ -608,12 +610,12 @@ static void handle_im_popup_destroy(struct wl_listener *listener, void *data) {
|
|||
relay->popup=NULL;
|
||||
}
|
||||
|
||||
static void handle_im_new_popup_surface(struct wl_listener *listener,
|
||||
void *data) {
|
||||
|
||||
static void handle_im_new_popup_surface(struct wl_listener *listener, void *data) {
|
||||
// struct dwl_text_input* text_input;
|
||||
|
||||
struct dwl_input_method_relay *relay =
|
||||
wl_container_of(listener, relay, input_method_new_popup_surface);
|
||||
struct dwl_input_method_relay *relay = wl_container_of(listener, relay,
|
||||
input_method_new_popup_surface);
|
||||
struct dwl_input_popup *popup = calloc(1, sizeof(*popup));
|
||||
|
||||
wlr_log(WLR_INFO, "IM_new_popup_surface");
|
||||
|
|
@ -623,23 +625,25 @@ static void handle_im_new_popup_surface(struct wl_listener *listener,
|
|||
popup->popup_surface = data;
|
||||
popup->popup_surface->data = popup;
|
||||
|
||||
|
||||
wl_signal_add(&popup->popup_surface->surface->events.map, &popup->popup_map);
|
||||
popup->popup_map.notify = handle_im_popup_map;
|
||||
|
||||
wl_signal_add(&popup->popup_surface->surface->events.unmap,
|
||||
&popup->popup_unmap);
|
||||
wl_signal_add(&popup->popup_surface->surface->events.unmap, &popup->popup_unmap);
|
||||
popup->popup_unmap.notify = handle_im_popup_unmap;
|
||||
|
||||
wl_signal_add(&popup->popup_surface->events.destroy, &popup->popup_destroy);
|
||||
wl_signal_add(
|
||||
&popup->popup_surface->events.destroy, &popup->popup_destroy);
|
||||
popup->popup_destroy.notify = handle_im_popup_destroy;
|
||||
}
|
||||
|
||||
|
||||
static void relay_handle_input_method_new(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct dwl_text_input *text_input;
|
||||
|
||||
struct dwl_input_method_relay *relay =
|
||||
wl_container_of(listener, relay, input_method_new);
|
||||
struct dwl_input_method_relay *relay = wl_container_of(listener, relay,
|
||||
input_method_new);
|
||||
|
||||
struct wlr_input_method_v2 *input_method = data;
|
||||
if (seat != input_method->seat) {
|
||||
|
|
@ -648,9 +652,7 @@ static void relay_handle_input_method_new(struct wl_listener *listener,
|
|||
}
|
||||
|
||||
if (relay->input_method != NULL) {
|
||||
wlr_log(
|
||||
WLR_INFO,
|
||||
"input_method_new Attempted to connect second input method to a seat");
|
||||
wlr_log(WLR_INFO, "input_method_new Attempted to connect second input method to a seat");
|
||||
wlr_input_method_v2_send_unavailable(input_method);
|
||||
return;
|
||||
}
|
||||
|
|
@ -687,7 +689,8 @@ void dwl_input_method_relay_init(struct dwl_input_method_relay *relay) {
|
|||
relay->popup=NULL;
|
||||
|
||||
relay->text_input_new.notify = relay_handle_text_input_new;
|
||||
wl_signal_add(&text_input_manager->events.text_input, &relay->text_input_new);
|
||||
wl_signal_add(&text_input_manager->events.text_input,
|
||||
&relay->text_input_new);
|
||||
|
||||
relay->input_method_new.notify = relay_handle_input_method_new;
|
||||
wl_signal_add(&input_method_manager->events.input_method,
|
||||
|
|
@ -715,13 +718,13 @@ void dwl_input_method_relay_set_focus(struct dwl_input_method_relay *relay,
|
|||
}
|
||||
}
|
||||
|
||||
if (surface && wl_resource_get_client(text_input->input->resource) ==
|
||||
wl_resource_get_client(surface->resource)) {
|
||||
if (surface
|
||||
&& wl_resource_get_client(text_input->input->resource)
|
||||
== wl_resource_get_client(surface->resource)) {
|
||||
if (relay->input_method) {
|
||||
wlr_text_input_v3_send_enter(text_input->input, surface);
|
||||
wlr_log(WLR_INFO, "wlr_text_input_send_enter");
|
||||
if (relay->popup)
|
||||
input_popup_update(relay->popup);
|
||||
if (relay->popup) input_popup_update(relay->popup);
|
||||
} else {
|
||||
text_input_set_pending_focused_surface(text_input, surface);
|
||||
}
|
||||
|
|
|
|||
28
README.md
28
README.md
|
|
@ -69,32 +69,16 @@ See below for more features.
|
|||
yay -S glibc wayland libinput libdrm pixman libxkbcommon git meson ninja wayland-protocols libdisplay-info libliftoff hwdata seatd
|
||||
```
|
||||
|
||||
## stable - wlroots(0.17)
|
||||
|
||||
Since 0.18 has some bugs that affect the experience,
|
||||
I chose the more stable 0.17.4.
|
||||
|
||||
```
|
||||
git clone -b 0.17.4 https://gitlab.freedesktop.org/wlroots/wlroots.git
|
||||
cd wlroots
|
||||
meson build -Dprefix=/usr
|
||||
sudo ninja -C build install
|
||||
|
||||
git clone https://github.com/DreamMaoMao/maomaowm.git
|
||||
cd maomaowm
|
||||
meson build -Dprefix=/usr
|
||||
sudo ninja -C build install
|
||||
## arch
|
||||
```bash
|
||||
yay -S maomaowm-git
|
||||
|
||||
```
|
||||
|
||||
## unstable wlroots(0.19)
|
||||
|
||||
This is the latest version of wlroots, it doesn't own enough test.
|
||||
you can try it out if you want to help to test.
|
||||
|
||||
```
|
||||
## other
|
||||
```bash
|
||||
yay -S wlroots-git
|
||||
git clone -b wlroots-0.19 https://github.com/DreamMaoMao/maomaowm.git
|
||||
git clone https://github.com/DreamMaoMao/maomaowm.git
|
||||
cd maomaowm
|
||||
meson build -Dprefix=/usr
|
||||
sudo ninja -C build install
|
||||
|
|
|
|||
230
client.h
230
client.h
|
|
@ -6,14 +6,18 @@
|
|||
*/
|
||||
|
||||
/* Leave these functions first; they're used in the others */
|
||||
static inline int client_is_x11(Client *c) {
|
||||
static inline int
|
||||
client_is_x11(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
return c->type == X11;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct wlr_surface *client_surface(Client *c) {
|
||||
static inline struct wlr_surface *
|
||||
client_surface(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->surface;
|
||||
|
|
@ -21,8 +25,9 @@ static inline struct wlr_surface *client_surface(Client *c) {
|
|||
return c->surface.xdg->surface;
|
||||
}
|
||||
|
||||
static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
|
||||
LayerSurface **pl) {
|
||||
static inline int
|
||||
toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
|
||||
{
|
||||
struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
|
||||
struct wlr_surface *root_surface;
|
||||
struct wlr_layer_surface_v1 *layer_surface;
|
||||
|
|
@ -45,8 +50,7 @@ static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
|
|||
}
|
||||
#endif
|
||||
|
||||
if ((layer_surface =
|
||||
wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
|
||||
if ((layer_surface = wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
|
||||
l = layer_surface->data;
|
||||
type = LayerShell;
|
||||
goto end;
|
||||
|
|
@ -60,8 +64,7 @@ static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
|
|||
if (!xdg_surface->popup || !xdg_surface->popup->parent)
|
||||
return -1;
|
||||
|
||||
tmp_xdg_surface =
|
||||
wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
|
||||
tmp_xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
|
||||
|
||||
if (!tmp_xdg_surface)
|
||||
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
|
||||
|
|
@ -86,8 +89,9 @@ end:
|
|||
}
|
||||
|
||||
/* The others */
|
||||
static inline void client_activate_surface(struct wlr_surface *s,
|
||||
int activated) {
|
||||
static inline void
|
||||
client_activate_surface(struct wlr_surface *s, int activated)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
#ifdef XWAYLAND
|
||||
struct wlr_xwayland_surface *xsurface;
|
||||
|
|
@ -100,16 +104,16 @@ static inline void client_activate_surface(struct wlr_surface *s,
|
|||
wlr_xdg_toplevel_set_activated(toplevel, activated);
|
||||
}
|
||||
|
||||
static inline uint32_t client_set_bounds(Client *c, int32_t width,
|
||||
int32_t height) {
|
||||
static inline uint32_t
|
||||
client_set_bounds(Client *c, int32_t width, int32_t height)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return 0;
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION &&
|
||||
width >= 0 && height >= 0 &&
|
||||
(c->bounds.width != width || c->bounds.height != height)) {
|
||||
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0
|
||||
&& (c->bounds.width != width || c->bounds.height != height)) {
|
||||
c->bounds.width = width;
|
||||
c->bounds.height = height;
|
||||
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
|
||||
|
|
@ -117,16 +121,31 @@ static inline uint32_t client_set_bounds(Client *c, int32_t width,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline const char *client_get_appid(Client *c) {
|
||||
static inline const char *
|
||||
client_get_appid(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->class;
|
||||
return c->surface.xwayland->class ? c->surface.xwayland->class : "broken";
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->app_id;
|
||||
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id : "broken";
|
||||
}
|
||||
|
||||
static inline void client_get_clip(Client *c, struct wlr_box *clip) {
|
||||
struct wlr_box xdg_geom = {0};
|
||||
static inline int
|
||||
client_get_pid(Client *c)
|
||||
{
|
||||
pid_t pid;
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->pid;
|
||||
#endif
|
||||
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||
return pid;
|
||||
}
|
||||
|
||||
static inline void
|
||||
client_get_clip(Client *c, struct wlr_box *clip)
|
||||
{
|
||||
*clip = (struct wlr_box){
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
|
|
@ -139,12 +158,13 @@ static inline void client_get_clip(Client *c, struct wlr_box *clip) {
|
|||
return;
|
||||
#endif
|
||||
|
||||
wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom);
|
||||
clip->x = xdg_geom.x;
|
||||
clip->y = xdg_geom.y;
|
||||
clip->x = c->surface.xdg->geometry.x;
|
||||
clip->y = c->surface.xdg->geometry.y;
|
||||
}
|
||||
|
||||
static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
|
||||
static inline void
|
||||
client_get_geometry(Client *c, struct wlr_box *geom)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
geom->x = c->surface.xwayland->x;
|
||||
|
|
@ -154,10 +174,12 @@ static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
wlr_xdg_surface_get_geometry(c->surface.xdg, geom);
|
||||
*geom = c->surface.xdg->geometry;
|
||||
}
|
||||
|
||||
static inline Client *client_get_parent(Client *c) {
|
||||
static inline Client *
|
||||
client_get_parent(Client *c)
|
||||
{
|
||||
Client *p = NULL;
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
|
|
@ -167,12 +189,13 @@ static inline Client *client_get_parent(Client *c) {
|
|||
}
|
||||
#endif
|
||||
if (c->surface.xdg->toplevel->parent)
|
||||
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface,
|
||||
&p, NULL);
|
||||
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL);
|
||||
return p;
|
||||
}
|
||||
|
||||
static inline int client_has_children(Client *c) {
|
||||
static inline int
|
||||
client_has_children(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return !wl_list_empty(&c->surface.xwayland->children);
|
||||
|
|
@ -182,15 +205,19 @@ static inline int client_has_children(Client *c) {
|
|||
return wl_list_length(&c->surface.xdg->link) > 1;
|
||||
}
|
||||
|
||||
static inline const char *client_get_title(Client *c) {
|
||||
static inline const char *
|
||||
client_get_title(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->title;
|
||||
return c->surface.xwayland->title ? c->surface.xwayland->title : "broken";
|
||||
#endif
|
||||
return c->surface.xdg->toplevel->title;
|
||||
return c->surface.xdg->toplevel->title ? c->surface.xdg->toplevel->title : "broken";
|
||||
}
|
||||
|
||||
static inline int client_is_float_type(Client *c) {
|
||||
static inline int
|
||||
client_is_float_type(Client *c)
|
||||
{
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
struct wlr_xdg_toplevel_state state;
|
||||
|
||||
|
|
@ -198,32 +225,32 @@ static inline int client_is_float_type(Client *c) {
|
|||
if (client_is_x11(c)) {
|
||||
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||
xcb_size_hints_t *size_hints = surface->size_hints;
|
||||
size_t i;
|
||||
if (surface->modal)
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < surface->window_type_len; i++)
|
||||
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] ||
|
||||
surface->window_type[i] == netatom[NetWMWindowTypeSplash] ||
|
||||
surface->window_type[i] == netatom[NetWMWindowTypeToolbar] ||
|
||||
surface->window_type[i] == netatom[NetWMWindowTypeUtility])
|
||||
if (wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DIALOG)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLBAR)
|
||||
|| wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return size_hints && size_hints->min_width > 0 &&
|
||||
size_hints->min_height > 0 &&
|
||||
(size_hints->max_width == size_hints->min_width ||
|
||||
size_hints->max_height == size_hints->min_height);
|
||||
return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
|
||||
&& (size_hints->max_width == size_hints->min_width
|
||||
|| size_hints->max_height == size_hints->min_height);
|
||||
}
|
||||
#endif
|
||||
|
||||
toplevel = c->surface.xdg->toplevel;
|
||||
state = toplevel->current;
|
||||
return toplevel->parent || (state.min_width != 0 && state.min_height != 0 &&
|
||||
(state.min_width == state.max_width ||
|
||||
state.min_height == state.max_height));
|
||||
return toplevel->parent || (state.min_width != 0 && state.min_height != 0
|
||||
&& (state.min_width == state.max_width
|
||||
|| state.min_height == state.max_height));
|
||||
}
|
||||
|
||||
static inline int client_is_rendered_on_mon(Client *c, Monitor *m) {
|
||||
static inline int
|
||||
client_is_rendered_on_mon(Client *c, Monitor *m)
|
||||
{
|
||||
/* This is needed for when you don't want to check formal assignment,
|
||||
* but rather actual displaying of the pixels.
|
||||
* Usually VISIBLEON suffices and is also faster. */
|
||||
|
|
@ -231,12 +258,15 @@ static inline int client_is_rendered_on_mon(Client *c, Monitor *m) {
|
|||
int unused_lx, unused_ly;
|
||||
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
|
||||
return 0;
|
||||
wl_list_for_each(s, &client_surface(c)->current_outputs,
|
||||
link) if (s->output == m->wlr_output) return 1;
|
||||
wl_list_for_each(s, &client_surface(c)->current_outputs, link)
|
||||
if (s->output == m->wlr_output)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int client_is_stopped(Client *c) {
|
||||
static inline int
|
||||
client_is_stopped(Client *c)
|
||||
{
|
||||
int pid;
|
||||
siginfo_t in = {0};
|
||||
#ifdef XWAYLAND
|
||||
|
|
@ -260,7 +290,9 @@ static inline int client_is_stopped(Client *c) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline int client_is_unmanaged(Client *c) {
|
||||
static inline int
|
||||
client_is_unmanaged(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->override_redirect;
|
||||
|
|
@ -268,25 +300,19 @@ static inline int client_is_unmanaged(Client *c) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static inline void client_notify_enter(struct wlr_surface *s,
|
||||
struct wlr_keyboard *kb) {
|
||||
static inline void
|
||||
client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
|
||||
{
|
||||
if (kb)
|
||||
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes, kb->num_keycodes,
|
||||
&kb->modifiers);
|
||||
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes,
|
||||
kb->num_keycodes, &kb->modifiers);
|
||||
else
|
||||
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
static inline void client_restack_surface(Client *c) {
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
wlr_xwayland_surface_restack(c->surface.xwayland, NULL,
|
||||
XCB_STACK_MODE_ABOVE);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void client_send_close(Client *c) {
|
||||
static inline void
|
||||
client_send_close(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_close(c->surface.xwayland);
|
||||
|
|
@ -296,26 +322,17 @@ static inline void client_send_close(Client *c) {
|
|||
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel);
|
||||
}
|
||||
|
||||
static inline int
|
||||
client_get_pid(Client *c)
|
||||
static inline void
|
||||
client_set_border_color(Client *c, const float color[static 4])
|
||||
{
|
||||
pid_t pid;
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->pid;
|
||||
#endif
|
||||
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
||||
return pid;
|
||||
}
|
||||
|
||||
static inline void client_set_border_color(Client *c,
|
||||
const float color[static 4]) {
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
wlr_scene_rect_set_color(c->border[i], color);
|
||||
}
|
||||
|
||||
static inline void client_set_fullscreen(Client *c, int fullscreen) {
|
||||
static inline void
|
||||
client_set_fullscreen(Client *c, int fullscreen)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, fullscreen);
|
||||
|
|
@ -325,42 +342,50 @@ static inline void client_set_fullscreen(Client *c, int fullscreen) {
|
|||
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
|
||||
}
|
||||
|
||||
static inline void client_set_scale(struct wlr_surface *s, float scale) {
|
||||
static inline void
|
||||
client_set_scale(struct wlr_surface *s, float scale)
|
||||
{
|
||||
wlr_fractional_scale_v1_notify_scale(s, scale);
|
||||
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
|
||||
}
|
||||
|
||||
static inline uint32_t client_set_size(Client *c, uint32_t width,
|
||||
uint32_t height) {
|
||||
static inline uint32_t
|
||||
client_set_size(Client *c, uint32_t width, uint32_t height)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_configure(c->surface.xwayland, c->geom.x, c->geom.y,
|
||||
width, height);
|
||||
wlr_xwayland_surface_configure(c->surface.xwayland,
|
||||
c->geom.x + c->bw, c->geom.y + c->bw, width, height);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if ((int32_t)width == c->surface.xdg->toplevel->current.width &&
|
||||
(int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||
if ((int32_t)width == c->surface.xdg->toplevel->current.width
|
||||
&& (int32_t)height == c->surface.xdg->toplevel->current.height)
|
||||
return 0;
|
||||
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width,
|
||||
(int32_t)height);
|
||||
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
|
||||
}
|
||||
|
||||
static inline void client_set_tiled(Client *c, uint32_t edges) {
|
||||
static inline void
|
||||
client_set_tiled(Client *c, uint32_t edges)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
if (client_is_x11(c)) {
|
||||
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
|
||||
edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
||||
XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
||||
if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
|
||||
>= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
||||
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
||||
} else {
|
||||
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel,
|
||||
edges != WLR_EDGE_NONE);
|
||||
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != WLR_EDGE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void client_set_suspended(Client *c, int suspended) {
|
||||
static inline void
|
||||
client_set_suspended(Client *c, int suspended)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return;
|
||||
|
|
@ -369,17 +394,20 @@ static inline void client_set_suspended(Client *c, int suspended) {
|
|||
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
|
||||
}
|
||||
|
||||
static inline int client_wants_focus(Client *c) {
|
||||
static inline int
|
||||
client_wants_focus(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
return client_is_unmanaged(c) &&
|
||||
wlr_xwayland_or_surface_wants_focus(c->surface.xwayland) &&
|
||||
wlr_xwayland_icccm_input_model(c->surface.xwayland) !=
|
||||
WLR_ICCCM_INPUT_MODEL_NONE;
|
||||
return client_is_unmanaged(c)
|
||||
&& wlr_xwayland_surface_override_redirect_wants_focus(c->surface.xwayland)
|
||||
&& wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int client_wants_fullscreen(Client *c) {
|
||||
static inline int
|
||||
client_wants_fullscreen(Client *c)
|
||||
{
|
||||
#ifdef XWAYLAND
|
||||
if (client_is_x11(c))
|
||||
return c->surface.xwayland->fullscreen;
|
||||
|
|
|
|||
125
flake.lock
generated
125
flake.lock
generated
|
|
@ -1,5 +1,20 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"locked": {
|
||||
"lastModified": 1717312683,
|
||||
"narHash": "sha256-FrlieJH50AuvagamEvWMIE6D2OAnERuDboFDYAED/dE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flake-compat",
|
||||
"rev": "38fd3954cf65ce6faf3d0d45cd26059e059f07ea",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
|
|
@ -36,6 +51,43 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"lib-aggregate": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs-lib": "nixpkgs-lib_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1742732002,
|
||||
"narHash": "sha256-fznNOUwLtsnaFHIeHfmj1QxOhjiohM2oiGj/54IO+AI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "lib-aggregate",
|
||||
"rev": "00480968bd30f3f43bcd520046bb647833bf2cf2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "lib-aggregate",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"mmsg": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts_2",
|
||||
|
|
@ -59,11 +111,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1740019556,
|
||||
"narHash": "sha256-vn285HxnnlHLWnv59Og7muqECNMS33mWLM14soFIv2g=",
|
||||
"lastModified": 1742800061,
|
||||
"narHash": "sha256-oDJGK1UMArK52vcW9S5S2apeec4rbfNELgc50LqiPNs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "dad564433178067be1fbdfcce23b546254b6d641",
|
||||
"rev": "1750f3c1c89488e2ffdd47cab9d05454dddfb734",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -100,14 +152,81 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-lib_3": {
|
||||
"locked": {
|
||||
"lastModified": 1742692082,
|
||||
"narHash": "sha256-s3XOULQj7BVO7myY5V4Sob0tRZ7nRpwEOIzXg/MkD/Q=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "a09310bc940f245e51b1ffea68731244ca38f2bd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-wayland": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"lib-aggregate": "lib-aggregate",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1742870145,
|
||||
"narHash": "sha256-ik+6+EorpRPqEVazsJhjyP9z7N83Tkq0F/Ky7GKHEso=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs-wayland",
|
||||
"rev": "b2bfc4d198ca1ff4e9278c0e984f74a6a086b2ee",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs-wayland",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1742669843,
|
||||
"narHash": "sha256-G5n+FOXLXcRx+3hCJ6Rt6ZQyF1zqQ0DL0sWAMn2Nk0w=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1e5b653dff12029333a6546c11e108ede13052eb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-parts": "flake-parts",
|
||||
"mmsg": "mmsg",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-wayland": "nixpkgs-wayland",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
|
|
|||
10
flake.nix
10
flake.nix
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
|
|
@ -25,8 +26,8 @@
|
|||
];
|
||||
|
||||
flake = {
|
||||
hmModules.maomaowm = import ./nix/hm-modules.nix;
|
||||
nixosModules.maomaowm = import ./nix/nixos-modules.nix { inherit inputs self; };
|
||||
hmModules.maomaowm = import ./nix/hm-modules.nix self;
|
||||
nixosModules.maomaowm = import ./nix/nixos-modules.nix self;
|
||||
};
|
||||
|
||||
perSystem =
|
||||
|
|
@ -39,7 +40,10 @@
|
|||
inherit (pkgs)
|
||||
callPackage
|
||||
;
|
||||
maomaowm = callPackage ./nix { };
|
||||
maomaowm = callPackage ./nix {
|
||||
inherit (inputs.nixpkgs-wayland.packages.${pkgs.system}) wlroots;
|
||||
inherit (inputs.mmsg.packages.${pkgs.system}) mmsg;
|
||||
};
|
||||
shellOverride = old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ ];
|
||||
buildInputs = old.buildInputs ++ [ ];
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ libm = cc.find_library('m')
|
|||
xcb = dependency('xcb', required : get_option('xwayland'))
|
||||
xlibs = dependency('xcb-icccm', required : get_option('xwayland'))
|
||||
wayland_server_dep = dependency('wayland-server')
|
||||
wlroots_dep = dependency('wlroots', version : ['>=0.17.0', '<0.18.0'])
|
||||
wlroots_dep = dependency('wlroots-0.19')
|
||||
xkbcommon_dep = dependency('xkbcommon')
|
||||
libinput_dep = dependency('libinput')
|
||||
libwayland_client_dep = dependency('wayland-client')
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@
|
|||
wayland,
|
||||
wayland-protocols,
|
||||
wayland-scanner,
|
||||
wlroots_0_17,
|
||||
xcbutilwm,
|
||||
xwayland,
|
||||
enableXWayland ? true,
|
||||
meson,
|
||||
ninja,
|
||||
wlroots,
|
||||
mmsg,
|
||||
}:
|
||||
let
|
||||
pname = "maomaowm";
|
||||
|
|
@ -41,7 +42,7 @@ stdenv.mkDerivation {
|
|||
pixman
|
||||
wayland
|
||||
wayland-protocols
|
||||
wlroots_0_17
|
||||
wlroots
|
||||
]
|
||||
++ lib.optionals enableXWayland [
|
||||
libX11
|
||||
|
|
@ -51,6 +52,7 @@ stdenv.mkDerivation {
|
|||
|
||||
passthru = {
|
||||
providedSessions = [ "maomao" ];
|
||||
inherit mmsg;
|
||||
};
|
||||
|
||||
meta = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
self:
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
|
|
@ -5,7 +6,7 @@
|
|||
...
|
||||
}:
|
||||
let
|
||||
maomaowm = pkgs.callPackage ./. { };
|
||||
inherit (self.packages.${pkgs.system}) maomaowm;
|
||||
cfg = config.wayland.windowManager.maomaowm;
|
||||
variables = lib.concatStringsSep " " cfg.systemd.variables;
|
||||
extraCommands = lib.concatStringsSep " && " cfg.systemd.extraCommands;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{ inputs, self }:
|
||||
self:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
|
|
@ -7,16 +7,6 @@
|
|||
}:
|
||||
let
|
||||
cfg = config.programs.maomaowm;
|
||||
mmsg = lib.types.submodule {
|
||||
options = {
|
||||
enable = lib.mkEnableOption "Enable mmsg, the ipc for maomaowm";
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = inputs.mmsg.packages.${pkgs.system}.mmsg;
|
||||
description = "The mmsg package to use";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
|
@ -27,19 +17,13 @@ in
|
|||
default = self.packages.${pkgs.system}.maomaowm;
|
||||
description = "The maomaowm package to use";
|
||||
};
|
||||
mmsg = lib.mkOption {
|
||||
type = mmsg;
|
||||
default = {
|
||||
enable = true;
|
||||
};
|
||||
description = "Options for mmsg, the ipc for maomaowm";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [
|
||||
cfg.package
|
||||
] ++ (if (builtins.hasAttr "mmsg" cfg.package) then [ cfg.package.mmsg ] else [ ]);
|
||||
|
||||
xdg.portal = {
|
||||
enable = lib.mkDefault true;
|
||||
|
|
@ -59,10 +43,5 @@ in
|
|||
graphical-desktop.enable = lib.mkDefault true;
|
||||
};
|
||||
|
||||
})
|
||||
|
||||
(lib.mkIf cfg.mmsg.enable {
|
||||
environment.systemPackages = [ cfg.mmsg.package ];
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
23
util.c
23
util.c
|
|
@ -3,10 +3,12 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void die(const char *fmt, ...) {
|
||||
void
|
||||
die(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
|
@ -23,10 +25,27 @@ void die(const char *fmt, ...) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
void *ecalloc(size_t nmemb, size_t size) {
|
||||
void *
|
||||
ecalloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if (!(p = calloc(nmemb, size)))
|
||||
die("calloc:");
|
||||
return p;
|
||||
}
|
||||
|
||||
int
|
||||
fd_set_nonblock(int fd) {
|
||||
int flags = fcntl(fd, F_GETFL);
|
||||
if (flags < 0) {
|
||||
perror("fcntl(F_GETFL):");
|
||||
return -1;
|
||||
}
|
||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
|
||||
perror("fcntl(F_SETFL):");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
1
util.h
1
util.h
|
|
@ -2,3 +2,4 @@
|
|||
|
||||
void die(const char *fmt, ...);
|
||||
void *ecalloc(size_t nmemb, size_t size);
|
||||
int fd_set_nonblock(int fd);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue