Xlib ConfigureRequest with custom configuration not working












1















I am using python and python3-xlib (which is a pure python implementation of the Xlib interface but basically is very similar to the C Xlib). For educational purposes, I am trying to create a simple window manager which should be able to force windows to have some specific sizes, when they are opened. In my example, I want to force the windows to have a width and height of 500px.



I listen for the ConfigureRequest event and for the MapRequest event. If I don't change width and height, but directly pass the hints of the opening window without changing them, to the window's configuration, everything works as expected.



However, when I specify a size that is not the intended size of the newly opening window, the MapRequest is delayed by more than 3 seconds (window becomes visible >3s after ConfigureRequest). This was the case, when I tested this using xterm. When I tested gnome-terminal, the MapRequest was fired before the ConfigureRequest, became immediately visible, but did not redraw (although I could close it by blindly typing exit Return).



This is obviously not the expected behavior. Am I doing anything wrong?



The relevant code:



def handle_event(self):
try:
event = self.display.next_event()
except Xlib.error.ConnectionClosedError:
print("The connection to display '"+self.display.get_display_name()+"' was closed by the server")
print("Exiting now")
sys.exit(0)
if event.type in self.event_map:
self.event_map[event.type](event) # calls on_configure_request or on_map_request depending on event type


.



def handle_configure_request(self, event):
window = event.window
args = { 'border_width': 3 }
if event.value_mask & Xlib.X.CWX:
args['x'] = event.x
if event.value_mask & Xlib.X.CWY:
args['y'] = event.y
if event.value_mask & Xlib.X.CWWidth:
args['width'] = event.width
if event.value_mask & Xlib.X.CWHeight:
args['height'] = event.height
if event.value_mask & Xlib.X.CWSibling:
args['sibling'] = event.above
if event.value_mask & Xlib.X.CWStackMode:
args['stack_mode'] = event.stack_mode
args["width"] = 500
args["height"] = 500
window.configure(**args)
print("Configured") # printed twice for every window -> is this normal?


.



def on_map_request(self, event):
print("Mapping now") # when width and height are changed like above, this is printed more than 3s after on_configure_request when testing with xterm
event.window.map()
print("Mapped")









share|improve this question























  • git.suckless.org/dwm/file/dwm.c.html#l614 Peeking at the source for my favorite window manager, it seems to make a call to XMoveResizeWindow() if it's going to explicitly change the window size to something other than the intended size. Also see this other question that also seems to be related to the performance problems you are observing: stackoverflow.com/questions/17504025/…

    – Jason Brown
    Dec 4 '18 at 20:29
















1















I am using python and python3-xlib (which is a pure python implementation of the Xlib interface but basically is very similar to the C Xlib). For educational purposes, I am trying to create a simple window manager which should be able to force windows to have some specific sizes, when they are opened. In my example, I want to force the windows to have a width and height of 500px.



I listen for the ConfigureRequest event and for the MapRequest event. If I don't change width and height, but directly pass the hints of the opening window without changing them, to the window's configuration, everything works as expected.



However, when I specify a size that is not the intended size of the newly opening window, the MapRequest is delayed by more than 3 seconds (window becomes visible >3s after ConfigureRequest). This was the case, when I tested this using xterm. When I tested gnome-terminal, the MapRequest was fired before the ConfigureRequest, became immediately visible, but did not redraw (although I could close it by blindly typing exit Return).



This is obviously not the expected behavior. Am I doing anything wrong?



The relevant code:



def handle_event(self):
try:
event = self.display.next_event()
except Xlib.error.ConnectionClosedError:
print("The connection to display '"+self.display.get_display_name()+"' was closed by the server")
print("Exiting now")
sys.exit(0)
if event.type in self.event_map:
self.event_map[event.type](event) # calls on_configure_request or on_map_request depending on event type


.



def handle_configure_request(self, event):
window = event.window
args = { 'border_width': 3 }
if event.value_mask & Xlib.X.CWX:
args['x'] = event.x
if event.value_mask & Xlib.X.CWY:
args['y'] = event.y
if event.value_mask & Xlib.X.CWWidth:
args['width'] = event.width
if event.value_mask & Xlib.X.CWHeight:
args['height'] = event.height
if event.value_mask & Xlib.X.CWSibling:
args['sibling'] = event.above
if event.value_mask & Xlib.X.CWStackMode:
args['stack_mode'] = event.stack_mode
args["width"] = 500
args["height"] = 500
window.configure(**args)
print("Configured") # printed twice for every window -> is this normal?


.



def on_map_request(self, event):
print("Mapping now") # when width and height are changed like above, this is printed more than 3s after on_configure_request when testing with xterm
event.window.map()
print("Mapped")









share|improve this question























  • git.suckless.org/dwm/file/dwm.c.html#l614 Peeking at the source for my favorite window manager, it seems to make a call to XMoveResizeWindow() if it's going to explicitly change the window size to something other than the intended size. Also see this other question that also seems to be related to the performance problems you are observing: stackoverflow.com/questions/17504025/…

    – Jason Brown
    Dec 4 '18 at 20:29














1












1








1








I am using python and python3-xlib (which is a pure python implementation of the Xlib interface but basically is very similar to the C Xlib). For educational purposes, I am trying to create a simple window manager which should be able to force windows to have some specific sizes, when they are opened. In my example, I want to force the windows to have a width and height of 500px.



I listen for the ConfigureRequest event and for the MapRequest event. If I don't change width and height, but directly pass the hints of the opening window without changing them, to the window's configuration, everything works as expected.



However, when I specify a size that is not the intended size of the newly opening window, the MapRequest is delayed by more than 3 seconds (window becomes visible >3s after ConfigureRequest). This was the case, when I tested this using xterm. When I tested gnome-terminal, the MapRequest was fired before the ConfigureRequest, became immediately visible, but did not redraw (although I could close it by blindly typing exit Return).



This is obviously not the expected behavior. Am I doing anything wrong?



The relevant code:



def handle_event(self):
try:
event = self.display.next_event()
except Xlib.error.ConnectionClosedError:
print("The connection to display '"+self.display.get_display_name()+"' was closed by the server")
print("Exiting now")
sys.exit(0)
if event.type in self.event_map:
self.event_map[event.type](event) # calls on_configure_request or on_map_request depending on event type


.



def handle_configure_request(self, event):
window = event.window
args = { 'border_width': 3 }
if event.value_mask & Xlib.X.CWX:
args['x'] = event.x
if event.value_mask & Xlib.X.CWY:
args['y'] = event.y
if event.value_mask & Xlib.X.CWWidth:
args['width'] = event.width
if event.value_mask & Xlib.X.CWHeight:
args['height'] = event.height
if event.value_mask & Xlib.X.CWSibling:
args['sibling'] = event.above
if event.value_mask & Xlib.X.CWStackMode:
args['stack_mode'] = event.stack_mode
args["width"] = 500
args["height"] = 500
window.configure(**args)
print("Configured") # printed twice for every window -> is this normal?


.



def on_map_request(self, event):
print("Mapping now") # when width and height are changed like above, this is printed more than 3s after on_configure_request when testing with xterm
event.window.map()
print("Mapped")









share|improve this question














I am using python and python3-xlib (which is a pure python implementation of the Xlib interface but basically is very similar to the C Xlib). For educational purposes, I am trying to create a simple window manager which should be able to force windows to have some specific sizes, when they are opened. In my example, I want to force the windows to have a width and height of 500px.



I listen for the ConfigureRequest event and for the MapRequest event. If I don't change width and height, but directly pass the hints of the opening window without changing them, to the window's configuration, everything works as expected.



However, when I specify a size that is not the intended size of the newly opening window, the MapRequest is delayed by more than 3 seconds (window becomes visible >3s after ConfigureRequest). This was the case, when I tested this using xterm. When I tested gnome-terminal, the MapRequest was fired before the ConfigureRequest, became immediately visible, but did not redraw (although I could close it by blindly typing exit Return).



This is obviously not the expected behavior. Am I doing anything wrong?



The relevant code:



def handle_event(self):
try:
event = self.display.next_event()
except Xlib.error.ConnectionClosedError:
print("The connection to display '"+self.display.get_display_name()+"' was closed by the server")
print("Exiting now")
sys.exit(0)
if event.type in self.event_map:
self.event_map[event.type](event) # calls on_configure_request or on_map_request depending on event type


.



def handle_configure_request(self, event):
window = event.window
args = { 'border_width': 3 }
if event.value_mask & Xlib.X.CWX:
args['x'] = event.x
if event.value_mask & Xlib.X.CWY:
args['y'] = event.y
if event.value_mask & Xlib.X.CWWidth:
args['width'] = event.width
if event.value_mask & Xlib.X.CWHeight:
args['height'] = event.height
if event.value_mask & Xlib.X.CWSibling:
args['sibling'] = event.above
if event.value_mask & Xlib.X.CWStackMode:
args['stack_mode'] = event.stack_mode
args["width"] = 500
args["height"] = 500
window.configure(**args)
print("Configured") # printed twice for every window -> is this normal?


.



def on_map_request(self, event):
print("Mapping now") # when width and height are changed like above, this is printed more than 3s after on_configure_request when testing with xterm
event.window.map()
print("Mapped")






python c x11 xlib window-managers






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 25 '18 at 15:59









famemanfameman

491515




491515













  • git.suckless.org/dwm/file/dwm.c.html#l614 Peeking at the source for my favorite window manager, it seems to make a call to XMoveResizeWindow() if it's going to explicitly change the window size to something other than the intended size. Also see this other question that also seems to be related to the performance problems you are observing: stackoverflow.com/questions/17504025/…

    – Jason Brown
    Dec 4 '18 at 20:29



















  • git.suckless.org/dwm/file/dwm.c.html#l614 Peeking at the source for my favorite window manager, it seems to make a call to XMoveResizeWindow() if it's going to explicitly change the window size to something other than the intended size. Also see this other question that also seems to be related to the performance problems you are observing: stackoverflow.com/questions/17504025/…

    – Jason Brown
    Dec 4 '18 at 20:29

















git.suckless.org/dwm/file/dwm.c.html#l614 Peeking at the source for my favorite window manager, it seems to make a call to XMoveResizeWindow() if it's going to explicitly change the window size to something other than the intended size. Also see this other question that also seems to be related to the performance problems you are observing: stackoverflow.com/questions/17504025/…

– Jason Brown
Dec 4 '18 at 20:29





git.suckless.org/dwm/file/dwm.c.html#l614 Peeking at the source for my favorite window manager, it seems to make a call to XMoveResizeWindow() if it's going to explicitly change the window size to something other than the intended size. Also see this other question that also seems to be related to the performance problems you are observing: stackoverflow.com/questions/17504025/…

– Jason Brown
Dec 4 '18 at 20:29












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53469254%2fxlib-configurerequest-with-custom-configuration-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53469254%2fxlib-configurerequest-with-custom-configuration-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

To store a contact into the json file from server.js file using a class in NodeJS

Redirect URL with Chrome Remote Debugging Android Devices

Dieringhausen