cmderdev / cmder

Lovely console emulator package for Windows
https://cmder.app
MIT License
25.74k stars 2.02k forks source link

[Bug] SDL2 Event_Drop do not work with CMder #2881

Closed bovacu closed 8 months ago

bovacu commented 9 months ago

Version Information

Cmder version: 1.5.9
Operating system: Windows 11

Cmder Edition

Cmder Full (with Git)

Description of the issue

I'm working on my C-GameEngine on Windows 11 and I use Cmder as my working terminal and I compile with plain clang (no IDE). When I use any other native windows terminal (CMD or PowerShell) both support SDL2 Drop events, such as DropBegin, DropComplete, DropFile and DropText, but with Cmder those events are simply not working, they are not even poll at all, it is like they do not exist for Cmder. If I simply run my program by double clicking they work as expected, it is just by running the program on Cmder. It can be reproduced with the simple example of the wiki, here it is:

#include "SDL.h"

int main(int argc, char *argv[]) {
    SDL_bool done;
    SDL_Window *window;
    SDL_Event event;                        // Declare event handle
    char* dropped_filedir;                  // Pointer for directory of dropped file

    SDL_Init(SDL_INIT_VIDEO);               // SDL2 initialization

    window = SDL_CreateWindow(  // Create a window
        "SDL_DropEvent usage, please drop the file on window",
        SDL_WINDOWPOS_CENTERED,
        SDL_WINDOWPOS_CENTERED,
        640,
        480,
        SDL_WINDOW_OPENGL
    );

    // Check that the window was successfully made
    if (window == NULL) {
        // In the event that the window could not be made...
        SDL_Log("Could not create window: %s", SDL_GetError());
        SDL_Quit();
        return 1;
    }

    SDL_EventState(SDL_DROPFILE, SDL_ENABLE);

    done = SDL_FALSE;
    while (!done) {                         // Program loop
        while (!done && SDL_PollEvent(&event)) {
            switch (event.type) {
                case (SDL_QUIT): {          // In case of exit
                    done = SDL_TRUE;
                    break;
                }

                case (SDL_DROPFILE): {      // In case if dropped file
                    dropped_filedir = event.drop.file;
                    // Shows directory of dropped file
                    SDL_ShowSimpleMessageBox(
                        SDL_MESSAGEBOX_INFORMATION,
                        "File dropped on window",
                        dropped_filedir,
                        window
                    );
                    SDL_free(dropped_filedir);    // Free dropped_filedir memory
                    break;
               }
            }
        }
        SDL_Delay(0);
    }

    SDL_DestroyWindow(window);        // Close and destroy the window

    SDL_Quit();                       // Clean up
    return 0;
}

Just compile that program and see how it behaves in from the terminal and just from double clicking. Is this a known error? I could not find that much information about this problem. If anyone knows something on why this is happening or how to fix it, let me know pls!

Thank you so much in advance.

How to reproduce

  1. Windows 11
  2. Use Cmder
  3. Compile (above program) with clang -g -O0 main.cpp -I path/to/sdl2/include -L path/to/sdl/lib -lSDL2main -lSDL2 -lwinmm -lgdi32 -Xlinker /subsystem:console -lShell32 -o main.exe
  4. Run the generated program with Cmder (do not work), then run it by double click on the file explorer (works) and also on other terminal (like CMD, and it works)

Additional context

No response

Checklist

chrisant996 commented 9 months ago

Terminals show output from programs and accept input and pass the input to programs.

CMD and Powershell are shell programs, not terminals.

ConEmu and Windows Terminal are terminals. When no terminal program is launched, then the default terminal is launched. On older versions of Windows it's the legacy conhost terminal, and on newer versions it's Windows Terminal.

Cmder is a package that bundles some scripts and the ConEmu terminal.

Try posting the question in the ConEmu repo. Cmder doesn't own or modify the ConEmu terminal.

Also, it may be an issue in the SDL code, so posting the question to the SDL maintainers could also be useful.