minha nova paixão é discordar de post de dev caga regra no linkedin, aqueles nego que posta só pro click bait que posta o obvio.
Java8 with JavaFX: A Challenging Task to Update a Legacy System 200 Updates Behind A legacy system, running on a dedicated Linux totem-like device with the "twm" minimal window manager, and only the main application running in X, presented a significant challenge. The system, using Java8 with JavaFX, was 200 updates behind, necessitating a major update. Upon upgrading to the latest version, the same ".jar" binary exhibited window positioning issues. Despite setX(0) and setY(0) being set in the code, the window no longer appeared at the top-left corner. Since the window manager remained the same, the issue was clearly attributed to Java. To accommodate the need for the latest Java version, a workaround was devised to move the application window via a script. This approach leveraged the window ID, reminiscent of techniques used in keyloggers that monitor application title bars. xdotool proved to be an invaluable tool for simulating X input. image ChatGPT struggled to provide a simple script for this task. It became apparent that for complex tasks, breaking them into smaller, manageable problems was more effective for AI assistance. However, the ultimate solution was found in the documentation. The AI's suggestion to retrieve the window ID by application title worked for the initial window, but became impractical for subsequent forms with varying titles. The getwindowfocus option in xdotool provided the necessary solution. image By running the script every 2 seconds, the focused window was moved to X(0) and Y(0), effectively centering it (assuming full-screen windows). This type of solution highlights the limitations of AI in handling complex, macro-level problems. While AI can be helpful, it often lacks the ability to grasp the bigger picture. #blog #tech
Java8 com JavaFX, difícil tarefa de atualizar um sistema legado que esta a 200 updates atrás, sistema roda em um Linux dedicado tipo totem, com mini gerenciador de janelas o "twm", apenas aplicação principal no X. Ao pular para última versão o mesmo "binário" .jar roda deslocado (posição da janela não nasce no topo e esquerda), mesmo na programação estar com setX(0) e setY(0), o gerenciador de janelas é o mesmo então a culpa é do Java. Com necessidade de ter o último java entra a astúcia de mover a janela da aplicação via script. Eu já tinha ideia de como fazer isso buscando o ID da janela, quem nunca fez um keylogger que monitorava a barra de título da aplicação? `xdotool` essa ferramenta é o canivete suiço de simulação de input no X. image Chatgpt não ajudou com um script simples, quando se trata de uma tarefa complexa é melhor quebrar o problema em pequenos problemas e dai ele pode ajudar. Mas o que resolveu mesmo foi ler a documentação, pois a solução dada pela I.A era pegar o id da janela pelo título da aplicação. Funcionou pra primeira janela porém saber o título de todos os outros forms ficou inviável, a solução foi ler a documentação e achar a opção `getwindowfocus do xdotool. image Assim rodando o script a cada 2 segundos a janela que tiver o foco é movida ao X(0) e Y(0) resultando na centralização da janela, considerando que as janelas tem o tamanho total da tela. Esse tipo de solução que acho díficil a IA se virar sozinha, ela ajuda mas não consegue ver o macro. #blog #tech