Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App doesn't redraw on unmaximize properly #103

Open
rdbende opened this issue Mar 6, 2022 · 7 comments
Open

App doesn't redraw on unmaximize properly #103

rdbende opened this issue Mar 6, 2022 · 7 comments
Assignees
Labels
bug Something isn't working triage-approved

Comments

@rdbende
Copy link
Contributor

rdbende commented Mar 6, 2022

@sumeshir26 i see, you copied this part from Tukaan, but did you ever test it? (No). This code won't work as it is.

TimerX/main.py

Lines 62 to 69 in f1a8375

def fullredraw(e):
global prev_state
if prev_state == "zoomed":
app._dwm_set_window_attribute(app.DWMWA_TRANSITIONS_FORCEDISABLED, 1)
app.minimize()
app.restore()
app._dwm_set_window_attribute(app.DWMWA_TRANSITIONS_FORCEDISABLED, 0)
prev_state = app.state()

tkinter.Tk (app in this case) doesn't have neither _dwm_set_window_attribute, DWMWA_TRANSITIONS_FORCEDISABLED, minimize nor restore attribute.

In tkinter you should use iconify instead of minimize and deiconify instead of restore.
Instead of _dwm_set_window_attribute and DWMWA_TRANSITIONS_FORCEDISABLED you can use these two snippets:

# To disable transitions
true_value = ctypes.c_int(1)
ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(true_value), ctypes.sizeof(true_value))


# To enable transitions again
false_value = ctypes.c_int(0)
ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(false_value), ctypes.sizeof(false_value))

So the full function should look like this:

def fullredraw(e): 
    global prev_state 
    if prev_state == "zoomed": 
        true_value = ctypes.c_int(1)
        ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(true_value), ctypes.sizeof(true_value))

        app.iconify()
        app.deiconify()

        false_value = ctypes.c_int(0)
        ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(false_value), ctypes.sizeof(false_value))

        prev_state = app.state()
@sumeshir26
Copy link
Member

sumeshir26 commented Mar 7, 2022

I realized that, but I forgot to fix it before commiting. Fixing now... Thanks for reporting!

@sumeshir26 sumeshir26 changed the title Problem App dosent redraw on unmaximize properley Mar 7, 2022
@sumeshir26 sumeshir26 self-assigned this Mar 7, 2022
@sumeshir26 sumeshir26 added the bug Something isn't working label Mar 7, 2022
@sumeshir26
Copy link
Member

Well, it iconifies and deiconifies, but it turns out thta on Windows 11, the expose function gets called about 25 times with the prev_state as zoomed (Probably due to te smooth animation that playes while unmaximizing) and the animations dont get disabled properley, so my entire PC became unusable due to TimerX maximizing and unmaximizing, then the expose function gets called again due to the window showing up again and I couldent even click end task on taskmanger so I literallay had to restart my pc

@sumeshir26
Copy link
Member

Any idea on how to fix this?

@rdbende
Copy link
Contributor Author

rdbende commented Mar 7, 2022

Uhh, stange. Try binding to <Configure>.

Also, I updated the function (unindent the last line) because prev_state would have been updated only the first time the window was unmaximized (and not anymore), which could cause problems.

def fullredraw(e): 
    global prev_state 
    if prev_state == "zoomed": 
        true_value = ctypes.c_int(1)
        ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(true_value), ctypes.sizeof(true_value))

        app.iconify()
        app.deiconify()

        false_value = ctypes.c_int(0)
        ctypes.windll.dwmapi.DwmSetWindowAttribute(app.wm_frame(), 3, ctypes.byref(false_value), ctypes.sizeof(false_value))

    prev_state = app.state()

@sumeshir26
Copy link
Member

Yeah, I also did that, will try soon

@rdbende rdbende changed the title App dosent redraw on unmaximize properley App doesn't redraw on unmaximize properly Mar 7, 2022
@sumeshir26
Copy link
Member

Configure does not work either, it just keeps maximizing and unmaximizing

@im-coder-lg
Copy link
Member

What if you could control the minimum number of resizes? Maybe only once or twice, nothing more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage-approved
Projects
Development

No branches or pull requests

3 participants